webext-content-scripts
Advanced tools
Comparing version 0.8.0 to 0.9.0
/// <reference types="chrome" /> | ||
declare type ContentScripts = NonNullable<chrome.runtime.Manifest['content_scripts']>; | ||
export declare function injectContentScript(tabId: number, scripts: ContentScripts | ContentScripts[0]): Promise<void>; | ||
interface Target { | ||
tabId: number; | ||
frameId: number; | ||
} | ||
export declare function injectContentScript(target: number | Target, scripts: ContentScripts | ContentScripts[0]): Promise<void>; | ||
export {}; |
@@ -7,4 +7,8 @@ function castArray(possibleArray) { | ||
} | ||
export async function injectContentScript(tabId, scripts) { | ||
export async function injectContentScript(target, scripts) { | ||
var _a, _b; | ||
const { frameId, tabId } = typeof target === 'object' ? target : { | ||
tabId: target, | ||
frameId: 0, | ||
}; | ||
const injections = []; | ||
@@ -15,2 +19,3 @@ for (const script of castArray(scripts)) { | ||
file, | ||
frameId, | ||
runAt: script.run_at, | ||
@@ -24,2 +29,3 @@ allFrames: script.all_frames, | ||
file, | ||
frameId, | ||
runAt: script.run_at, | ||
@@ -26,0 +32,0 @@ allFrames: script.all_frames, |
{ | ||
"name": "webext-content-scripts", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Utility functions to inject content scripts from a WebExtension.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -44,4 +44,6 @@ # webext-content-scripts [](https://www.npmjs.com/package/webext-content-scripts) | ||
```js | ||
const tabId = 42; | ||
injectContentScript(tabId, [ | ||
injectContentScript({ | ||
tabId: 42, | ||
frameId: 56 | ||
}, [ | ||
{ | ||
@@ -48,0 +50,0 @@ js: [ |
6071
43
80