Gathering detailed insights and metrics for webpack-webextension-runtime-plugin
Gathering detailed insights and metrics for webpack-webextension-runtime-plugin
Gathering detailed insights and metrics for webpack-webextension-runtime-plugin
Gathering detailed insights and metrics for webpack-webextension-runtime-plugin
Quick & Dirty runtime mods for webextension dependency loading [runtime.getURL]
npm install webpack-webextension-runtime-plugin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
67.3
Supply Chain
85.4
Quality
75.1
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Unlicense License
5 Commits
7 Watchers
1 Branches
1 Contributors
Updated on Aug 27, 2019
Latest Version
1.0.3
Package Id
webpack-webextension-runtime-plugin@1.0.3
Unpacked Size
6.59 kB
Size
3.10 kB
File Count
4
NPM Version
6.9.0
Node Version
12.5.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
Quick & Dirty runtime mods for webextension dependency loading with
runtime.getURL
Webpack imports from __webpack_import_path__
, which is usually set to the
homepage
of whatever you are building. This will not work with content
scripts of webextensions, as everything must be resolved relative to
manifest.json
for the paths to work. We can't dynamically resolve this
in the injected scripts either as they do not get access to the extension
API. The injector must somehow pass it in!
Simply do:
1config.optimization.runtimeChunk = 'single' 2config.plugins.push(new (require('webpack-webextension-runtime-plugin'))({ 3 globalObject: config.output.globalObject, // I cannot read the config! 4 chunks: ['runtime'], // this is the default; adjust if not using "single" 5 bareRuntime: true // false if you are throwing entry points at us 6}))
When it's time to inject the scripts:
1const quoteRuntimeURL = (s) => JSON.stringify(browser.runtime.getURL(s))
2 const contentScript = `{
3 const promisifyLoad = function (tag) {
4 return new Promise((res, _) => {
5 document.documentElement.appendChild(tag)
6 tag.onload = () => res() })}
7
8 const rt = document.createElement('script')
9 rt.src = ${quoteRuntimeURL('js/runtime.js')}
10 const pp = document.createElement('script')
11 pp.src = 'data:text/javascript;charset=utf-8,' +
12 encodeURIComponent('globalThis["webpackSetPublicPath"](${quoteRuntimeURL('/')})')
13 const is = document.createElement('script')
14 is.src = ${quoteRuntimeURL('js/injectedscript.js')}
15
16 promisifyLoad(rt)
17 .then(_ => promisifyLoad(pp))
18 .then(_ => promisifyLoad(is))
19 }`
20browser.webNavigation.onCommitted.addListener(async arg => {
21 browser.tabs
22 .executeScript(arg.tabId, {
23 runAt: 'document_start',
24 frameId: arg.frameId,
25 code: contentScript
26 })
27 .catch(IgnoreError(arg))
28})
Oh I just try to throw a line global["webpackSetPublicPath"] = (s) => __webpack_require__.p = s;
into the runtime definitions. It should work on plain runtime libraries, but I
think the matching is also lax enough to accomendate runtimes thrown into
entry points. Hell I know how to do this with ed
commands better than I do
with this wacky code.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More