diff --git a/background.js b/background.js index 1c797da..46e9e64 100644 --- a/background.js +++ b/background.js @@ -1,27 +1,27 @@ -browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { +chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { if (changeInfo.status !== 'complete') { - browser.pageAction.hide(tabId); - browser.storage.local.remove(`nl_tab_${sender.tab.id}`); + chrome.action.disable(tabId); + chrome.storage.local.remove(`nl_tab_${tabId}`); return; } -}, { properties: ["status"] }); +}); -browser.runtime.onMessage.addListener((message, sender, sendResponse) => { - if (message.action === "showNostrLinksPageAction" && sender.tab?.id) { +chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { + if (message.action === 'showNostrLinksPageAction' && sender.tab?.id) { const tabLinks = { [`nl_tab_${sender.tab.id}`]: message.links }; - browser.storage.local.set(tabLinks, () => { - browser.pageAction.show(sender.tab.id); + chrome.storage.local.set(tabLinks, () => { + chrome.action.enable(sender.tab.id); }); } - if (message.action === "getNostrLinks" && message.tabId) { - browser.storage.local.get(`nl_tab_${message.tabId}`, (result) => { + if (message.action === 'getNostrLinks' && message.tabId) { + chrome.storage.local.get(`nl_tab_${message.tabId}`, (result) => { sendResponse({ links: result[`nl_tab_${message.tabId}`] || [] }); }); return true; // Keep message channel open for async response } }); -browser.tabs.onRemoved.addListener((tabId) => { - browser.storage.local.remove(`nl_tab_${tabId}`); +chrome.tabs.onRemoved.addListener((tabId) => { + chrome.storage.local.remove(`nl_tab_${tabId}`); }); diff --git a/content.js b/content.js index 1e7901b..d2ac529 100644 --- a/content.js +++ b/content.js @@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', function() { }); }); - browser.runtime.sendMessage({ + chrome.runtime.sendMessage({ action: "showNostrLinksPageAction", links: Array.from(linkMap.values()) }); diff --git a/manifest.json b/manifest.json index 1005851..a4c661b 100644 --- a/manifest.json +++ b/manifest.json @@ -15,9 +15,7 @@ "activeTab" ], "background": { - "scripts": [ - "background.js" - ] + "service_worker": "background.js" }, "content_scripts": [ { @@ -26,7 +24,7 @@ "run_at": "document_start" } ], - "page_action": { + "action": { "default_icon": "icons/nostr.svg", "default_title": "Nostr", "default_popup": "popup/nostr-links.html" diff --git a/popup/nostr-links.js b/popup/nostr-links.js index 3feb3bb..af197c2 100644 --- a/popup/nostr-links.js +++ b/popup/nostr-links.js @@ -1,7 +1,7 @@ -browser.tabs.query({ active: true, currentWindow: true }, (tabs) => { +chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { const tabId = tabs[0].id; - browser.runtime.sendMessage({ action: "getNostrLinks", tabId }, (response) => { + chrome.runtime.sendMessage({ action: "getNostrLinks", tabId }, (response) => { const menu = document.getElementById("link-menu"); if (response.links && response.links.length > 0) { menu.innerHTML = response.links