Skip to content

Migrate Extension to Manifest V3#12

Open
praseetht wants to merge 1 commit intonovotnyllc:masterfrom
praseetht:users/praseetht/support-mainfest-v3
Open

Migrate Extension to Manifest V3#12
praseetht wants to merge 1 commit intonovotnyllc:masterfrom
praseetht:users/praseetht/support-mainfest-v3

Conversation

@praseetht
Copy link
Copy Markdown

@praseetht praseetht commented Oct 1, 2025

Summary

This PR updates the "Use My Current Account" extension from Manifest V2 to Manifest V3, addressing the deprecation of Manifest V2 and ensuring compatibility with modern browser extension standards.

Changes

Manifest Updates (manifest.json)

  • Bumped version from 1.3 to 1.4
  • Updated manifest_version from 2 to 3
  • Replaced browser_action with action (MV3 standard)
  • Updated background configuration:
    • Removed persistent: true and scripts array
    • Migrated to service_worker architecture with service_worker: "src/background.js"
  • Replaced blocking webRequest API with declarativeNetRequest:
    • Removed webRequest and webRequestBlocking permissions
    • Added declarativeNetRequestWithHostAccess permission
  • Separated host permissions:
    • Moved *://login.microsoftonline.com/* from permissions to new host_permissions array

Background Script Refactor (src/background.js)

  • Migrated from blocking webRequest to declarativeNetRequest API:

    • Replaced synchronous webRequest listeners with dynamic redirect rules
    • Rules are created/updated when extension loads or state changes
    • Rule 1: Adds login_hint parameter to /authorize URLs
    • Rule 2: Adds whr parameter to /saml2 and /wsfed URLs
  • Modernized code to use Promises/async-await:

    • Created getEmail() async function using promise-based chrome.identity.getProfileUserInfo()
    • Replaced callback patterns with modern async/await syntax
  • Migrated from chrome.browserAction to chrome.action:

    • Updated all references to use the MV3 API
  • Added debug logging system:

    • Implemented DEBUG flag for optional logging
    • Created helper functions: debugLog(), debugWarn(), debugError()
    • Errors always logged; other messages only when DEBUG = true
    • All logs prefixed with [UseMyCurrentAccount] for easy identification

Testing

  • ✅ Extension loads without errors in Edge
  • ✅ Email is properly retrieved from browser profile
  • ✅ Redirect rules are created successfully
  • ✅ Toggle functionality works (on/off via icon click)
  • ✅ Login hint and domain parameters added correctly to Microsoft login URLs

Breaking Changes

None - all functionality remains the same from a user perspective.

Notes

  • Microsoft Edge (unlike Chrome) still supports some webRequest capabilities in MV3, but declarativeNetRequest is the recommended and future-proof approach
  • The extension now runs as a service worker instead of a persistent background page, which is more efficient and aligned with MV3 standards
  • fixes Extension stopped to work #11

@alberto-ingenito
Copy link
Copy Markdown

Hello, I tried testing this PR using a local unpacked installation, but it doesn’t seem to work. Have you managed to get it working? Maybe I’m missing something

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.

Extension stopped to work

2 participants