Skip to content

Port Chrome extension to Manifest V3#116

Draft
chtx wants to merge 2 commits into
lydell:mainfrom
chtx:main
Draft

Port Chrome extension to Manifest V3#116
chtx wants to merge 2 commits into
lydell:mainfrom
chtx:main

Conversation

@chtx

@chtx chtx commented Jul 3, 2026

Copy link
Copy Markdown

Summary

This is a draft Manifest V3 port for the Chrome build while keeping Firefox on Manifest V2.

The goal is to keep the extension usable in Chromium browsers after MV2 deprecation.

Architectural Changes

  • Chrome now builds as Manifest V3 with a background service worker.
  • Firefox continues to build as Manifest V2 with the existing background script model.
  • Replaced MV2-only APIs with MV3 equivalents where needed:
    • browserAction / action
    • tabs.executeScript / scripting.executeScript
    • tabs.insertCSS / scripting.insertCSS
  • Added an MV3 service worker wrapper so the browser polyfill is loaded before the background bundle.
  • Added packaged MAIN world script injection for Chromium MV3 instead of inline page-script injection.
  • Adjusted background/content-script lifecycle handling for MV3 service worker suspension.
  • Added short-lived hint-session cleanup for MV3 so stale in-memory background state fails closed.

Testing

Tested locally with: npm test

Also tested manually in Brave (Chromium) and Firefox via unpacked developer install.

Known Issues

  • After the extension has been idle for more than 30 seconds (more or less) Chromium suspends the Manifest V3 service worker. The next hint activation can have a small wake-up delay before hints appear.
  • Some messaging errors may still appear during page navigation or unload, such as Could not establish connection or Extension context invalidated. These seem to come from content scripts being torn down while the background worker is still sending cleanup messages.

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