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

31 lines
677 B
TypeScript
Raw Normal View History

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);
});