From 61e27eef33da20a9f174d2debee151cb8b100389 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Wed, 17 Sep 2025 20:14:09 +0100 Subject: Initial commit --- content.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 content.js (limited to 'content.js') diff --git a/content.js b/content.js new file mode 100644 index 0000000..545fa6d --- /dev/null +++ b/content.js @@ -0,0 +1,23 @@ +function getMetaValue(propName) { + const meta = Array.from(document.getElementsByTagName("meta")).find( + (meta) => + meta.getAttribute("property") === propName || + meta.getAttribute("name") === propName + ); + return meta ? meta.getAttribute("content") : undefined; +} + +function extractMetadata() { + const title = document.title; + const url = window.location.href; + const description = + getMetaValue("og:description") || getMetaValue("description"); + + return { title, url, description }; +} + +browser.runtime.onMessage.addListener(function (request, sender, sendResponse) { + if (request.action === "getMetadata") { + sendResponse(extractMetadata()); + } +}); -- cgit v1.2.3-70-g09d2