Skip to content

Commit 20d308f

Browse files
authored
Add optional support for activeTab injection (#44)
1 parent 07fe554 commit 20d308f

18 files changed

+309
-233
lines changed

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
!/distribution/*
3+
*.test.*
4+
!/utils.*
5+
!/including-active-tab.*

including-active-tab.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Temporary entry point until the `exports` key is added to the package.json
2+
export {};

including-active-tab.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Temporary entry point until the `exports` key is added to the package.json
2+
import './distribution/including-active-tab.js';

package-lock.json

Lines changed: 15 additions & 203 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "webext-dynamic-content-scripts",
3-
"version": "9.1.0",
4-
"description": "WebExtension module: Automatically registers your `content_scripts` on domains added via `permission.request`",
3+
"version": "9.2.0-6",
4+
"description": "WebExtension module: Automatically registers your `content_scripts` on domains added via `permission.request` or on `activeTab`",
55
"keywords": [
66
"contentscript",
77
"register",
@@ -10,21 +10,18 @@
1010
"request",
1111
"optional_permissions",
1212
"manifest",
13+
"new hosts",
1314
"chrome",
1415
"firefox",
1516
"browser",
17+
"activetab",
1618
"extension"
1719
],
1820
"repository": "fregante/webext-dynamic-content-scripts",
1921
"funding": "https://github.com/sponsors/fregante",
2022
"license": "MIT",
2123
"author": "Federico Brigante <[email protected]> (https://fregante.com)",
2224
"module": "distribution/index.js",
23-
"files": [
24-
"distribution",
25-
"utils.js",
26-
"utils.d.ts"
27-
],
2825
"scripts": {
2926
"build": "tsc",
3027
"demo:build": "parcel build --no-cache",
@@ -67,7 +64,9 @@
6764
"content-scripts-register-polyfill": "^3.2.2",
6865
"webext-additional-permissions": "^2.3.0",
6966
"webext-content-scripts": "^2.4.0",
70-
"webext-patterns": "^1.2.0"
67+
"webext-detect-page": "^4.0.1",
68+
"webext-patterns": "^1.2.0",
69+
"webext-polyfill-kinda": "^0.10.0"
7170
},
7271
"devDependencies": {
7372
"@parcel/config-webextension": "^2.8.2",
@@ -88,7 +87,7 @@
8887
"alias": {
8988
"these-are-just-mocks-for-parcel-tests": "yolo",
9089
"webext-additional-permissions": "./test/demo-extension/webext-additional-permissions.js",
91-
"webext-dynamic-content-scripts": "./source/index.ts",
90+
"webext-dynamic-content-scripts": "./source/",
9291
"./source/*.js": "./source/$1.ts"
9392
},
9493
"targets": {
@@ -124,8 +123,6 @@
124123
"https://extra-ephiframe.vercel.app/Inject-via-context-menu-please",
125124
"https://extra-ephiframe.vercel.app/Inject-via-context-menu-please?iframe=https://static-ephiframe.vercel.app/Static-inner",
126125
"https://extra-ephiframe.vercel.app/Inject-via-context-menu-please?iframe=https://dynamic-ephiframe.vercel.app/Dynamic-inner",
127-
"https://static-ephiframe.vercel.app/Static?iframe=https://extra-ephiframe.vercel.app/Inject-via-context-menu-please",
128-
"https://dynamic-ephiframe.vercel.app/Dynamic?iframe=https://extra-ephiframe.vercel.app/Inject-via-context-menu-please",
129126
"chrome://extensions/"
130127
]
131128
}

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ navigator.importScripts('webext-dynamic-content-scripts.js');
5959
}
6060
```
6161

62+
### `activeTab` tracking
63+
64+
By default, the module will only inject the content scripts into newly-permitted hosts, but it will ignore temporary permissions like `activeTab`. If you also want to automatically inject the content scripts into every frame of tabs as soon as they receive the `activeTab` permission, import a different entry point **instead of the default one.**
65+
66+
```js
67+
import 'webext-dynamic-content-scripts/including-active-tab.js';
68+
```
69+
6270
### Additional APIs
6371

6472
#### `isContentScriptRegistered(url)`

0 commit comments

Comments
 (0)