Skip to content

Migrate the extension to Manifest V3 - #1

Open
InventivetalentDev wants to merge 1 commit into
masterfrom
claude/manifest-v3-migration-xm48e8
Open

Migrate the extension to Manifest V3#1
InventivetalentDev wants to merge 1 commit into
masterfrom
claude/manifest-v3-migration-xm48e8

Conversation

@InventivetalentDev

Copy link
Copy Markdown
Member

Manifest:

  • manifest_version 3, browser_action -> action
  • persistent background page -> background.service_worker
  • host permissions (<all_urls>, http:///, https:///) moved to
    host_permissions; added "scripting" for the popup's injection
  • content_security_policy is now an object. MV3 forbids remote script
    sources, so the remote-sli.de/cdnjs/jquery/google-analytics entries are
    gone and the policy is the MV3 default
  • web_accessible_resources entries carry the now-required "matches"

Background page -> service worker (background.js):

  • imports sessionGrabber.js via importScripts; jQuery is dropped from the
    worker ($.extend -> Object.assign) since it needs a DOM
  • resizeImage() has no DOM to work with, so it decodes the capture with
    createImageBitmap and scales it on an OffscreenCanvas, then serialises
    through FileReader. Output is unchanged: a 40%-scale PNG payload with
    the data URL header stripped
  • chrome.browserAction -> chrome.action
  • chrome.tabs.getSelected is gone; the badge now targets sender.tab (the
    tab the controller actually runs in) and falls back to the active tab
  • takeScreenshot() is promise-based and reports failures instead of
    leaving the caller waiting on a response that never comes

Popup (index.js):

  • chrome.tabs.getSelected -> chrome.tabs.query, via a withActiveTab helper
  • chrome.tabs.executeScript -> chrome.scripting.executeScript. MV3 has no
    {code: ...}, so remote_slide is handed over with func/args, and the
    injections are chained so pageController.js only runs once jQuery and
    socket.io are in place
  • chrome.extension.onMessage -> chrome.runtime.onMessage
  • chrome.browserAction -> chrome.action, and the badge calls now use the
    stored controlledTab id instead of a non-existent .id on that number

Content scripts:

  • chrome.extension.onMessage/getURL -> chrome.runtime equivalents in
    injector.js and preziInjector.js

Other:

  • util/mv3-compat.js restores chrome.extension.onMessage/sendMessage/getURL
    for the bundled inject/controller submodule, which still targets MV2. It
    is injected just before pageController.js and can be removed once that
    submodule is migrated
  • lib/analytics.js loaded ga.js from a remote origin, which MV3 does not
    allow; removed along with its script tag

Co-Authored-By: Claude noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01TwwH67Z38ZV9GaWAtPZhfP

Manifest:
- manifest_version 3, browser_action -> action
- persistent background page -> background.service_worker
- host permissions (<all_urls>, http://*/, https://*/) moved to
  host_permissions; added "scripting" for the popup's injection
- content_security_policy is now an object. MV3 forbids remote script
  sources, so the remote-sli.de/cdnjs/jquery/google-analytics entries are
  gone and the policy is the MV3 default
- web_accessible_resources entries carry the now-required "matches"

Background page -> service worker (background.js):
- imports sessionGrabber.js via importScripts; jQuery is dropped from the
  worker ($.extend -> Object.assign) since it needs a DOM
- resizeImage() has no DOM to work with, so it decodes the capture with
  createImageBitmap and scales it on an OffscreenCanvas, then serialises
  through FileReader. Output is unchanged: a 40%-scale PNG payload with
  the data URL header stripped
- chrome.browserAction -> chrome.action
- chrome.tabs.getSelected is gone; the badge now targets sender.tab (the
  tab the controller actually runs in) and falls back to the active tab
- takeScreenshot() is promise-based and reports failures instead of
  leaving the caller waiting on a response that never comes

Popup (index.js):
- chrome.tabs.getSelected -> chrome.tabs.query, via a withActiveTab helper
- chrome.tabs.executeScript -> chrome.scripting.executeScript. MV3 has no
  {code: ...}, so remote_slide is handed over with func/args, and the
  injections are chained so pageController.js only runs once jQuery and
  socket.io are in place
- chrome.extension.onMessage -> chrome.runtime.onMessage
- chrome.browserAction -> chrome.action, and the badge calls now use the
  stored controlledTab id instead of a non-existent .id on that number

Content scripts:
- chrome.extension.onMessage/getURL -> chrome.runtime equivalents in
  injector.js and preziInjector.js

Other:
- util/mv3-compat.js restores chrome.extension.onMessage/sendMessage/getURL
  for the bundled inject/controller submodule, which still targets MV2. It
  is injected just before pageController.js and can be removed once that
  submodule is migrated
- lib/analytics.js loaded ga.js from a remote origin, which MV3 does not
  allow; removed along with its script tag

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwwH67Z38ZV9GaWAtPZhfP
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.

2 participants