Skip to content

Migrate extension to Manifest V3 and add dark mode theme option#394

Open
eevmanu wants to merge 7 commits into
tulios:masterfrom
eevmanu:main
Open

Migrate extension to Manifest V3 and add dark mode theme option#394
eevmanu wants to merge 7 commits into
tulios:masterfrom
eevmanu:main

Conversation

@eevmanu

@eevmanu eevmanu commented Jul 4, 2026

Copy link
Copy Markdown

Summary

Migrate the extension from Manifest V2 to Manifest V3 (MV3) to comply with modern browser extension standards. This includes transitioning the background script and omnibox listener into a unified service worker, refactoring storage access to use asynchronous chrome.storage.local, and introducing a dark and light mode selector to the options page with updated themes.


Detailed Changes

Extension Architecture (Manifest V3 Migration)

  • Manifest Updates: Upgraded manifest_version to 3 in manifest.json.
  • Background Service Worker: Replaced background scripts backend.js with background service worker registration.
  • Unified Entry Point: Merged background scripts and omnibox listeners into a single background service worker bundle via Webpack config.
  • Modern APIs: Replaced deprecated chrome.extension.getURL with modern chrome.runtime.getURL in omnibox routing.
  • Web Accessible Resources: Updated theme resource listings format to follow the newer Manifest V3 schema structure.

Storage & Options Layer (Asynchronous Transition)

  • Asynchronous Storage: Migrated storage.js from synchronous localStorage (which is unavailable in MV3 background workers) to the asynchronous chrome.storage.local API.
  • Backward Compatibility: Implemented a robust fallback system in storage.js that automatically reads, parses, and migrates existing settings from localStorage to chrome.storage.local when available.
  • Promise API: Rewrote Storage.load() and Storage.save() to return Promises.
  • UI & Messaging Integration: Updated options pages and backend listeners to load/save options asynchronously, leveraging returning true on Chrome message listeners to allow asynchronous responses.

UI Improvements (Dark Mode Support)

  • Options Theme: Added a dark/light mode option selector (optionsTheme) to the extension options page.
  • Dark Style Overrides: Added styles for body backgrounds, custom headers, CodeMirror editor zones, actions bar, and key syntax-highlighting elements under active .dark-mode body classes.

Build System & Documentation

  • Sass Upgrade: Transitioned the build pipeline from deprecated binary-native node-sass to modern sass (Dart Sass).
  • Dependency Upgrades: Upgraded fs-extra to ^10.1.0.
  • Release Automation: Swapped out the deprecated fs.createOutputStream call with standard fs.createWriteStream in the release scripts.
  • Developer Documentation: Updated README.md with instructions on building and loading the modern Manifest V3 extension.

eevmanu added 5 commits July 3, 2026 20:48
…ce worker entry points

- Upgrade 'fs-extra' to ^10.1.0 and replace legacy 'node-sass' with Dart 'sass' to fix build compatibility.
- Update 'lib/release-script/release-script.js' to use standard Node.js 'fs.createWriteStream' due to fs-extra updates.
- Combine 'backend' and 'omnibox' webpack entry points into a single 'background' bundle for MV3 compatibility.
…for MV3 worker compatibility

- Rewrite 'Storage.load' and 'Storage.save' using 'Promise' and 'chrome.storage.local' since 'localStorage' is not accessible within MV3 background service workers.
- Add a fallback and migration path to load and save legacy options from 'localStorage' when available.
…ure to Manifest V3

- Upgrade manifest_version to 3 and increase minimum_chrome_version to 88.
- Register the merged 'assets/background.js' as background service_worker instead of scripts array.
- Split host permissions from permissions into host_permissions block.
- Update 'web_accessible_resources' format to match the new MV3 object array schema.
- Adapt 'GET_OPTIONS' messenger listener to handle asynchronous Promise resolution.
- Migrate all 'chrome.extension.getURL' calls to recommended 'chrome.runtime.getURL' API.
- Add a dropdown selector '#optionsTheme' to 'options.html' to let users toggle the options page theme.
- Define default 'optionsTheme' configuration as 'dark'.
- Support setting and saving the theme choice asynchronously, dynamically toggling '.dark-mode' and '.light-mode' classes on body.
- Design complete SCSS styling rules for options page dark mode, including customized background, headers, buttons, and custom CodeMirror syntax coloring.
- Implement optionsTheme reset handler in reset button event binding.
Copilot AI review requested due to automatic review settings July 4, 2026 02:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the extension toward Manifest V3 compatibility and updates build/runtime pieces accordingly (background/service worker wiring, storage API usage, and dependency updates).

Changes:

  • Migrates the extension manifest to Manifest V3 (service worker background, storage permission, MV3-style web_accessible_resources, updated minimum Chrome version).
  • Switches options persistence from localStorage to chrome.storage.local and updates callers to use async load/save.
  • Consolidates background-related webpack entries and updates build/docs (Sass tooling, README instructions).

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
yarn.lock Regenerated lockfile reflecting updated dependency graph and integrity metadata.
webpack.config.js Merges backend + omnibox into a single background bundle entry.
README.md Updates build/load-from-source instructions and clarifies MV3 build output location.
package.json Updates fs-extra, replaces node-sass with a sass alias, and adds sass.
lib/release-script/release-script.js Updates zip output stream creation for newer fs-extra.
lib/build-extension-webpack-plugin/build-extension.js Adds MV3-style web_accessible_resources entry for generated theme CSS files.
extension/styles/options-custom.scss Adds dark/light options-page styling (dark-mode class driven).
extension/src/options.js Updates options load/save flow to async and wires the options theme selector.
extension/src/omnibox.js Updates URL generation to chrome.runtime.getURL for MV3.
extension/src/json-viewer/viewer/render-extras.js Updates options link to chrome.runtime.getURL for MV3.
extension/src/json-viewer/storage.js Moves persistence to chrome.storage.local with Promise-based API and migration path.
extension/src/json-viewer/options/defaults.js Adds default optionsTheme.
extension/src/json-viewer/options/bind-reset-button.js Updates reset flow to async save with error handling.
extension/src/json-viewer/load-css.js Updates URL generation to chrome.runtime.getURL for MV3.
extension/src/backend.js Updates GET_OPTIONS handler to async Storage.load with return true.
extension/pages/options.html Sets default body class and adds the options theme select control.
extension/manifest.json Migrates to MV3 (service worker, permissions/host_permissions, MV3 web_accessible_resources).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread extension/src/json-viewer/storage.js Outdated
Comment thread extension/manifest.json
@eevmanu eevmanu changed the title Your PR Title Migrate extension to Manifest V3 and add dark mode theme option Jul 4, 2026
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