« Back to History
background.js
|
20260920_164915.php
Initial Domain Snapshot
Copy Code
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { if (msg?.type === "GET_WINDOW_ID") { chrome.windows.get(sender.tab.windowId, {}, (w) => sendResponse({ windowId: w.id })); return true; // async } if (msg?.type === "GET_DATA") { chrome.storage.local.get([`w:${msg.windowId}`], (res) => { sendResponse(res[`w:${msg.windowId}`] || { name: "", notes: "", visible: true }); }); return true; } if (msg?.type === "SAVE_DATA") { const key = `w:${msg.windowId}`; chrome.storage.local.set({ [key]: msg.payload }, () => sendResponse({ ok: true })); return true; } }); // keyboard shortcut to toggle chrome.commands.onCommand.addListener(async (command) => { if (command !== "toggle-overlay") return; const [tab] = await chrome.tabs.query({ active: true, currentWindow: true }); if (tab?.id) chrome.tabs.sendMessage(tab.id, { type: "TOGGLE_OVERLAY" }); });