mirror of
https://github.com/Zetaphor/browser-recall.git
synced 2025-12-06 02:19:37 +00:00
32 lines
790 B
JavaScript
32 lines
790 B
JavaScript
console.log("Content script starting initialization...");
|
|
|
|
function sendPageContent() {
|
|
const pageContent = {
|
|
url: window.location.href,
|
|
html: document.documentElement.outerHTML,
|
|
timestamp: new Date().toISOString().replace(/\.\d{3}Z$/, 'Z')
|
|
};
|
|
|
|
browser.runtime.sendMessage({
|
|
type: "SEND_PAGE_CONTENT",
|
|
data: pageContent
|
|
});
|
|
}
|
|
|
|
// Listen for messages from the background script
|
|
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
if (message.type === "PING") {
|
|
return Promise.resolve({ status: "ready" });
|
|
}
|
|
|
|
if (message.type === "GET_PAGE_CONTENT") {
|
|
sendPageContent();
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
// Send initial page content
|
|
sendPageContent();
|
|
|
|
console.log("Content script initialization complete for:", window.location.href); |