import messages from '../../shared/messages'; export default class ContentMessageClient { async broadcastSettingsChanged(): Promise { let tabs = await browser.tabs.query({}); for (let tab of tabs) { if (!tab.id || tab.url && tab.url.startsWith('about:')) { continue; } browser.tabs.sendMessage(tab.id, { type: messages.SETTINGS_CHANGED, }); } } async getAddonEnabled(tabId: number): Promise { let { enabled } = await browser.tabs.sendMessage(tabId, { type: messages.ADDON_ENABLED_QUERY, }) as { enabled: boolean }; return enabled; } toggleAddonEnabled(tabId: number): Promise { return browser.tabs.sendMessage(tabId, { type: messages.ADDON_TOGGLE_ENABLED, }); } scrollTo(tabId: number, x: number, y: number): Promise { return browser.tabs.sendMessage(tabId, { type: messages.TAB_SCROLL_TO, x, y, }); } }