Skip to content

feat: add Safari web extension support - #1267

Open
RaphxelS wants to merge 3 commits into
SevenTV:masterfrom
RaphxelS:feat/safari-web-extension
Open

RaphxelS wants to merge 3 commits into
SevenTV:masterfrom
RaphxelS:feat/safari-web-extension

Conversation

@RaphxelS

Copy link
Copy Markdown

Proposed changes

Adds a Safari build target and works around the extension APIs Safari doesn't implement, so the extension can run as a Safari Web Extension.

  • Safari-specific manifest (drops action.default_area, options_ui.open_in_tab, and the unsupported management permission)
  • build:safari / convert:safari scripts + make safari, wrapping the build into an Xcode project via safari-web-extension-converter
  • guard runtime.onUpdateAvailable and the management API (absent in Safari) and make dynamic content-script registration tolerant
  • handle the safari-web-extension:// scheme in the hosted stylesheet check
  • README docs for building/running/signing/installing on Safari

Tested on Safari 27: extension loads on Twitch, emotes render, settings/options work. Chrome/Firefox manifests are unchanged (OUT_DIR=mv3 verified identical). Chrome (MV3) and Firefox (MV2) manifests are unchanged — verified against yarn build:prod for both.

Types of changes

What types of changes does your code introduce to 7TV?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged

Add a Safari build target and work around the extension APIs Safari does not
implement, so the existing extension can run as a Safari Web Extension.

- manifest.config.ts: omit Chrome-only keys (`action.default_area`,
  `options_ui.open_in_tab`) and the unsupported `management` permission when
  building for Safari
- package.json / Makefile: add `build:safari` and `convert:safari` scripts and a
  `make safari` target that wraps the build into an Xcode project via
  `safari-web-extension-converter` (script/convert-safari.sh, which also
  validates the referenced icons and supports a signing team)
- guard `runtime.onUpdateAvailable` and the `management` API, which are absent
  in Safari, and make dynamic content-script registration tolerant
- handle the `safari-web-extension://` scheme in the hosted stylesheet check
- README: document building, running, signing and installing in Safari
The settings-sync broadcast runs on every completed tab load and can target a
tab that has since closed or that does not run a content script, which Safari
surfaces as "Invalid call to tabs.sendMessage(). Tab not found.". Add an error
callback that consumes `runtime.lastError` so these expected failures are
silently ignored (same for the update-ready broadcast).
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