webext-content-scripts
Advanced tools
Comparing version 0.10.1 to 0.11.0
@@ -6,4 +6,4 @@ import type { Manifest } from 'webextension-polyfill'; | ||
} | ||
export declare function executeFunction<Fn extends (...args: any[]) => unknown>(target: number | Target, function_: string | Fn, ...args: unknown[]): Promise<ReturnType<Fn>>; | ||
export declare function executeFunction<Fn extends (...args: any[]) => unknown>(target: number | Target, function_: Fn, ...args: unknown[]): Promise<ReturnType<Fn>>; | ||
export declare function injectContentScript(target: number | Target, scripts: Manifest.ContentScript | Manifest.ContentScript[]): Promise<void>; | ||
export {}; |
11
index.js
@@ -13,2 +13,13 @@ import chromeP from 'webext-polyfill-kinda'; | ||
}; | ||
if ('scripting' in chrome) { | ||
const [result] = await chrome.scripting.executeScript({ | ||
target: { | ||
tabId, | ||
frameIds: [frameId], | ||
}, | ||
func: function_, | ||
args, | ||
}); | ||
return result; | ||
} | ||
const [result] = await chromeP.tabs.executeScript(tabId, { | ||
@@ -15,0 +26,0 @@ code: `(${function_.toString()})(...${JSON.stringify(args)})`, |
{ | ||
"name": "webext-content-scripts", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"description": "Utility functions to inject content scripts from a WebExtension.", | ||
@@ -42,2 +42,3 @@ "keywords": [ | ||
"@sindresorhus/tsconfig": "^2.0.0", | ||
"@types/chrome": "^0.0.170", | ||
"@types/webextension-polyfill": "^0.8.1", | ||
@@ -44,0 +45,0 @@ "typescript": "^4.4.4", |
7898
66
5