Skip to content

Drop support for MV2 Chrome - #76

Open
fregante wants to merge 16 commits into
mainfrom
future
Open

Drop support for MV2 Chrome#76
fregante wants to merge 16 commits into
mainfrom
future

Conversation

@fregante

@fregante fregante commented Jan 8, 2025

Copy link
Copy Markdown
Owner

MV2 Firefox presumably still works, but no more official support in v11+

Need MV2? Use v10

@fregante
fregante marked this pull request as ready for review January 8, 2025 22:31
Comment thread .github/workflows/esm-lint.yml Outdated
Comment thread .github/workflows/esm-lint.yml
Comment thread .github/workflows/ci.yml
sed -i 's/webNavigation/tabs/' test/demo-extension/mv${{ matrix.version }}/manifest.json
- run: xvfb-run --auto-servernum npm run jest:core
env:
TARGET: ${{ matrix.version }}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No MV2, no Firefox tests:

So I'm dropping MV2 tests altogether

Comment thread package.json
"these-are-just-mocks-for-parcel-tests": "yolo",
"webext-permissions": "./test/demo-extension/webext-permissions.js",
"webext-dynamic-content-scripts": "./source/"
},

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related:

In this case I was able to move these to sub-folders so they don't get published.

"allFrames": undefined,
"css": undefined,
"excludeMatches": [
"https://content-script.example.com/*",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade. However not really useful because Chrome natively deduplicates scripts now.

Comment thread source/deduplicator.ts

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files can be registered multiple times; Chrome only injects them once (just like native content scripts)

Comment thread source/lib.ts
if (origins.includes(origin)) {
// eslint-disable-next-line no-await-in-loop
const script = await scriptPromise;
void script.unregister();

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this did not work in event pages and service workers. Nothing happened then, they'd just be left behind but never injected.

Comment thread source/lib.ts
}

// Registration successful, now inject into existing tabs
await injectToExistingTabs([origin], [config]);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally the browser still remembers scripts registered in past sessions, so this this now only runs when the scripts were not previously registered.

@@ -1,38 +0,0 @@
import registerContentScriptPonyfill from 'content-scripts-register-polyfill/ponyfill.js';

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bye ponyfill 🙏

Comment thread test/demo-extension/manifest.json Outdated
"version": "0.0.0",
"manifest_version": 3,
"permissions": ["webNavigation", "scripting", "contextMenus", "activeTab", "storage"],

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mistake. webNavigation is still needed for including-active-tab

@fregante fregante Jan 19, 2025

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted to dedicated module:

https://github.com/fregante/webext-active-tab

@fregante
fregante marked this pull request as draft January 8, 2025 23:30
This was referenced Feb 1, 2025
@fregante
fregante marked this pull request as ready for review February 1, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant