(callback: (...args: any[]) => T, args?: any[])
| 1 | /** Execute a script in the active tab. */ |
| 2 | export async function executeScript<T>(callback: (...args: any[]) => T, args?: any[]): Promise<any> { |
| 3 | const [tab] = await browser.tabs.query({ currentWindow: true, active: true }) |
| 4 | if (!tab?.id) { |
| 5 | throw new Error('No active tab found') |
| 6 | } |
| 7 | return browser.scripting.executeScript({ |
| 8 | target: { tabId: tab.id }, |
| 9 | func: callback, |
| 10 | args, |
| 11 | }) |
| 12 | } |
| 13 | |
| 14 | /** Show a brief toast notification in the active tab. */ |
| 15 | export async function showPageToast(message: string): Promise<void> { |
no outgoing calls
no test coverage detected