Skip to content

Add cross-browser extension support via window.postMessage bridge#326

Open
HarmlessHarm wants to merge 10 commits intodevelopfrom
feature/firefox_edge_ext
Open

Add cross-browser extension support via window.postMessage bridge#326
HarmlessHarm wants to merge 10 commits intodevelopfrom
feature/firefox_edge_ext

Conversation

@HarmlessHarm
Copy link
Collaborator

@HarmlessHarm HarmlessHarm commented Feb 28, 2026

Summary

  • Replaces chrome.runtime.sendMessage with a window.postMessage bridge protocol, enabling the D&D Character Sync extension to work in Chrome, Firefox, and Edge
  • Removes all browser-specific extension ID routing (getExtensionId, character_sync_chrome/firefox/edge_id constants)
  • Adds a checkExtensionInstalled Vuex action that caches the result of the bridge check, so the 2-second timeout is only incurred once per session instead of on every page/component mount
  • Guards sync_player in the players store to bail out immediately if the extension is known to be absent

Test plan (on staging)

  • Open the app in Chrome, Firefox, and Edge with the extension installed — extensionInstalled check returns a version string and character sync features are accessible
  • Navigate between pages multiple times — only the first page load waits on the bridge; subsequent navigations resolve instantly from Vuex state
  • Open the app with the extension NOT installed — all three extension functions gracefully return undefined/{} after the 2-second timeout, with no further bridge calls on navigation
  • Trigger a character sync (sync_player) without the extension installed — action throws immediately without hitting the bridge

🤖 Generated with Claude Code

HarmlessHarm and others added 5 commits February 27, 2026 10:50
- Refactor extension detection/utilities and store references for Chrome, Firefox, and Edge
- Update UI copy, URLs, and logic to reflect broader browser support
- Replace old Chrome-only references/logic with multi-browser dynamic logic everywhere in code and UI
- Update privacy policy and docs to reflect browser-agnostic support
Replace direct chrome.runtime.sendMessage calls with a window.postMessage
bridge pattern that works across Chrome, Firefox, and Edge. Remove
hard-coded extension IDs and the browser-dependent getExtensionId() function.
Add checkExtensionInstalled action to general.js store that calls the
bridge once and caches the result (null → not checked, false → absent,
string → version). Subsequent calls return immediately from state.

Guard sync_player in players.js with rootState check so it throws early
rather than waiting on the bridge when the extension is not present.

Update all four callers (CharacterSync, RunCampaign, Players, ContentSideRight)
to dispatch checkExtensionInstalled instead of calling the utility directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both target="_blank" links pointing to the browser extension stores used
rel="noopener" but were missing "noreferrer", which prevents the Referer
header from leaking to the destination. The :href="storeUrl" binding is
safe — storeUrl always returns one of three hardcoded HTTPS URLs from the
frozen character_sync_stores constant and has no user-controlled input.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@HarmlessHarm HarmlessHarm changed the base branch from main to develop February 28, 2026 10:13
Replace string comparison with proper semantic version parsing to correctly
compare version numbers (e.g., "0.2.10" > "0.2.1"). Add compareVersions()
helper function that splits and compares major, minor, and patch versions.
@sonarqubecloud
Copy link

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