{"_id":"@ajayyy/content-scripts-register-polyfill","name":"@ajayyy/content-scripts-register-polyfill","dist-tags":{"latest":"4.0.2-safari-fix"},"versions":{"4.0.2-safari-fix":{"name":"@ajayyy/content-scripts-register-polyfill","version":"4.0.2-safari-fix","description":"Chrome/Safari extension polyfill for Firefox's browser.contentScripts.register()","keywords":["browser","content scripts","contentScripts","programmatic injection","executescript","RequestContentScript","declarative","declarativecontent","extension","firefox","css","scripts","web-ext","webext"],"repository":{"type":"git","url":"git+https://github.com/fregante/content-scripts-register-polyfill.git"},"funding":"https://github.com/sponsors/fregante","license":"MIT","author":{"name":"Federico Brigante","email":"me@fregante.com","url":"https://fregante.com"},"type":"module","main":"index.js","scripts":{"build":"tsc","demo:build":"parcel build --no-cache","demo:watch":"parcel watch --no-cache --no-hmr","prejest":"npm run demo:build","jest":"NODE_OPTIONS=--experimental-vm-modules JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs jest","prepack":"tsc --sourceMap false","test":"xo && tsc --noEmit && npm run jest","test:watch":"npm run jest -- --watch","watch":"tsc --watch"},"xo":{"envs":["browser"],"globals":["chrome"],"rules":{"@typescript-eslint/triple-slash-reference":"off","import/extensions":"off","import/no-unassigned-import":"off","n/file-extension-in-import":"off"}},"jest":{"injectGlobals":false,"preset":"jest-puppeteer","testMatch":["**/test/*.js"]},"dependencies":{"@ajayyy/webext-content-scripts":"^2.5.4-safari-fix","webext-patterns":"^1.3.0","webext-polyfill-kinda":"^1.0.0"},"devDependencies":{"@parcel/config-webextension":"2.8.3","@sindresorhus/tsconfig":"^3.0.1","@types/chrome":"^0.0.211","@types/firefox-webext-browser":"^109.0.0","jest":"^29.4.1","jest-puppeteer":"^6.2.0","parcel":"2.8.3","puppeteer":"^17.1.3","typescript":"^4.9.5","xo":"^0.53.1"},"targets":{"main":false,"default":{"source":"./test/demo-extension/manifest.json","distDir":"./test/dist","sourceMap":{"inline":true},"optimize":false}},"webExt":{"sourceDir":"test/dist","run":{"startUrl":["https://ephiframe.vercel.app/Parent-page?iframe=./Framed-page","https://ephiframe.vercel.app/Parent-page?iframe=https://extra-ephiframe.vercel.app/Cross-domain-iframe"]}},"_id":"@ajayyy/content-scripts-register-polyfill@4.0.2-safari-fix","gitHead":"4527dc24672e7484535f9f786eeac8d10835a793","types":"./index.d.ts","bugs":{"url":"https://github.com/fregante/content-scripts-register-polyfill/issues"},"homepage":"https://github.com/fregante/content-scripts-register-polyfill#readme","_nodeVersion":"20.5.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-okyqlFmLUmOZQrkZ6ChUbfcNXadamlaIGqzb6fi5MRnzvr+myoG4sK+whxhCY9hPmU///dqMGtV8FVom8sJpHA==","shasum":"eef8289fba79560d975c5dd4c1cfc8724a5977b0","tarball":"https://registry.npmjs.org/@ajayyy/content-scripts-register-polyfill/-/content-scripts-register-polyfill-4.0.2-safari-fix.tgz","fileCount":8,"unpackedSize":12473,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBvLmHdyWjzbhmsyhIfpVeCjjmCNo2+tYjWuwJEsXWJkAiBOHYQRj5X7OO+9N9aHGmx1BLP3RrfHByPUGOHZW2gWJw=="}]},"_npmUser":{"name":"ajayyy","email":"dev@ajay.app"},"directories":{},"maintainers":[{"name":"ajayyy","email":"dev@ajay.app"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/content-scripts-register-polyfill_4.0.2-safari-fix_1693009219810_0.5737504662886255"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-26T00:20:19.713Z","4.0.2-safari-fix":"2023-08-26T00:20:20.004Z","modified":"2023-08-26T00:20:20.306Z"},"maintainers":[{"name":"ajayyy","email":"dev@ajay.app"}],"description":"Chrome/Safari extension polyfill for Firefox's browser.contentScripts.register()","homepage":"https://github.com/fregante/content-scripts-register-polyfill#readme","keywords":["browser","content scripts","contentScripts","programmatic injection","executescript","RequestContentScript","declarative","declarativecontent","extension","firefox","css","scripts","web-ext","webext"],"repository":{"type":"git","url":"git+https://github.com/fregante/content-scripts-register-polyfill.git"},"author":{"name":"Federico Brigante","email":"me@fregante.com","url":"https://fregante.com"},"bugs":{"url":"https://github.com/fregante/content-scripts-register-polyfill/issues"},"license":"MIT","readme":"# content-scripts-register-polyfill [![][badge-gzip]][link-bundlephobia]\n\n[badge-gzip]: https://img.shields.io/bundlephobia/minzip/content-scripts-register-polyfill.svg?label=gzipped\n[link-bundlephobia]: https://bundlephobia.com/result?p=content-scripts-register-polyfill\n\n> WebExtensions: Polyfill for [browser.contentScripts.register()](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contentScripts/register) for Chrome and Safari.\n\n> **Warning** `contentScripts.register` by design is not compatible with Event Pages (MV2) and Service Workers (MV3).\n>\n> You should prefer [chrome.scripting.registerContentScripts()](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/registerContentScripts) where available: Chrome Manifest v3, Firefox 102+. Extended details on how they differ can be found in issue [#11](https://github.com/fregante/content-scripts-register-polyfill/issues/11#issuecomment-1157679839)\n\n## Install\n\nYou can download the [standalone bundle](https://bundle.fregante.com/?pkg=content-scripts-register-polyfill) and include it in your `manifest.json`.\n\n```sh\nnpm install content-scripts-register-polyfill\n```\n\n```js\nimport 'content-scripts-register-polyfill';\n```\n\n## Usage\n\nInclude the script via `manifest.json`, then refer to the original [`contentScripts.register()`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contentScripts/register) documentation.\n\n```js\nconst registeredScript = await chrome.contentScripts.register({\n\tjs: [{\n\t\tfile: 'myfile.js'\n\t}],\n\tmatches: [\n\t\t'https://google.com/*'\n\t]\n});\n```\n\nAdditionally, if you're using [webextension-polyfill](https://github.com/mozilla/webextension-polyfill), you can also use it with the original `browser.*` name: `browser.contentsScripts.register()`\n\n```js\nconst registeredScript = await browser.contentScripts.register({\n\tjs: [{\n\t\tfile: 'myfile.js'\n\t}],\n\tmatches: [\n\t\t'https://google.com/*'\n\t]\n});\n```\n\n### Usage as ponyfill\n\nThis package also exports a [ponyfill](https://ponyfill.com/), meaning you can also use it as a normal API instead of treating it as a polyfill. This way it will always use the current code and never rely on Firefox’ native implementation.\n\n```js\nimport registerContentScript from 'content-scripts-register-polyfill/ponyfill.js';\n\nconst registeredScript = await registerContentScript({\n\tjs: [{\n\t\tfile: 'myfile.js'\n\t}],\n\tmatches: [\n\t\t'https://google.com/*'\n\t],\n\texcludeMatches: [ // Also supported\n\t\t'https://google.com/search*'\n\t]\n});\n```\n\n### TypeScript\n\nStarting in v3, the types are no longer included. You have a few options:\n\n- if you're using [webextension-polyfill](https://github.com/mozilla/webextension-polyfill) and the `browser.*` API, install its types\n  ```sh\n  npm install -D @types/webextension-polyfill\n  ```\n- if you want to use it as `chrome.contentScripts.register()` or as a [ponyfill](#ponyfill), you might need to install two type packages:\n  ```sh\n  npm install -D @types/webextension-polyfill @types/chrome\n  ```\n\n## Permission\n\nGenerally you don't need any permissions other than the host permission you want to register a script on.\n\nHowever, in order to use `allFrames: true` you should the add [`webNavigation` permission](https://developer.chrome.com/docs/extensions/reference/webNavigation/). Without it, `allFrames: true` won’t work:\n\n- when the iframe is not on the same domain as the top frame\n- when the iframe reloads or navigates to another page\n- when the iframe is not ready when `runAt` is configured to run (`runAt: 'start'` is unlikely to work)\n\nIf available, the `webNavigation` API will be automatically used in every situation for better performance.\n\n## Related\n\n- [webext-options-sync](https://github.com/fregante/webext-options-sync) - Helps you manage and autosave your extension's options.\n- [webext-domain-permission-toggle](https://github.com/fregante/webext-domain-permission-toggle) - Browser-action context menu to request permission for the current tab.\n- [webext-dynamic-content-scripts](https://github.com/fregante/webext-dynamic-content-scripts) - Automatically inject your `content_scripts` on custom domains.\n- [webext-detect-page](https://github.com/fregante/webext-detect-page) - Detects where the current browser extension code is being run.\n- [webext-content-script-ping](https://github.com/fregante/webext-content-script-ping) - One-file interface to detect whether your content script have loaded.\n- [`Awesome WebExtensions`](https://github.com/fregante/Awesome-WebExtensions): A curated list of awesome resources for Web Extensions development.\n\n## License\n\nMIT © [Federico Brigante](https://fregante.com)\n","readmeFilename":"readme.md"}