1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00
FrankerFaceZ/src/worker.ts
SirStendec 5c06461a0e 4.75.1
* Fixed: Bug in the sidebar processing code that may log errors when combined with other add-ons.
* API Changed: Improve messaging for manifest v3 extension mode.
2024-10-11 17:12:54 -04:00

30 lines
677 B
TypeScript

const browser = ((globalThis as any).browser ?? globalThis.chrome) as typeof globalThis.chrome;
browser.runtime.onInstalled.addListener(() => {
browser.action.disable();
});
browser.action.onClicked.addListener(tab => {
if ( ! tab?.id )
return;
browser.tabs.sendMessage(tab.id, {
type: 'ffz_to_page',
data: {
ffz_type: 'open-settings'
}
});
});
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
const type = message?.type;
if ( ! type || ! sender?.tab?.id )
return;
if ( type === 'ffz_not_supported' )
browser.action.disable(sender.tab.id);
else if ( type === 'ffz_injecting' )
browser.action.enable(sender.tab.id);
});