Adrià Vilanova MartÃnez | 5f5b3e0 | 2023-07-23 00:08:17 +0200 | [diff] [blame] | 1 | export default class UpdateNotifier { |
| 2 | getCommunityConsoleTabs() { |
| 3 | return new Promise(res => { |
| 4 | chrome.tabs.query( |
| 5 | {url: 'https://support.google.com/s/community*'}, tabs => res(tabs)); |
| 6 | }); |
| 7 | } |
| 8 | |
| 9 | notify(reason) { |
| 10 | this.getCommunityConsoleTabs().then(tabs => { |
| 11 | for (const tab of tabs) { |
| 12 | const script = reason === 'install' ? 'handleInstall.bundle.js' : |
| 13 | 'handleUpdate.bundle.js'; |
| 14 | // #!if browser_target == 'chromium_mv3' |
| 15 | chrome.scripting.executeScript({ |
| 16 | target: {tabId: tab.id}, |
| 17 | files: [script], |
| 18 | }); |
| 19 | // #!else |
| 20 | chrome.tabs.executeScript(tab.id, {file: script}); |
| 21 | // #!endif |
| 22 | } |
| 23 | }); |
| 24 | } |
| 25 | } |