GM
This commit is contained in:
28
background.js
Normal file
28
background.js
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
|
||||
if (changeInfo.status !== 'complete') {
|
||||
browser.pageAction.hide(tabId);
|
||||
await browser.storage.local.remove(`nl_tab_${sender.tab.id}`);
|
||||
return;
|
||||
}
|
||||
}, { properties: ["status"] });
|
||||
|
||||
browser.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);
|
||||
});
|
||||
}
|
||||
|
||||
if (message.action === "getNostrLinks" && message.tabId) {
|
||||
browser.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}`);
|
||||
});
|
||||
Reference in New Issue
Block a user