All jobs

Make a Chrome Extension Work in Firefox

Yes. An agent adds a Firefox build of your Manifest V3 extension: a gecko id, a background script entry, the cross-browser API, web-ext lint and tests, in a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent clones the repository into its own cloud sandbox and reads how the extension is built before it changes anything, because the differences between the two browsers are in the manifest and the background page, not the React code. In an extension shaped like chibat/chrome-extension-typescript-starter, public/manifest.json is Manifest V3 with an action popup at popup.html, options_ui at options.html, a content_scripts entry on <all_urls> loading js/vendor.js and js/content_script.js, background.service_worker at js/background.js, the storage permission and <all_urls> under host_permissions. webpack/webpack.common.js bundles src/popup.tsx, src/options.tsx, src/background.ts and src/content_script.tsx into dist/js, splits shared code into vendor.js for every chunk except background, and copies public/ to dist/. package.json has watch, build, clean, test and style scripts, React 18, @types/chrome 0.0.158, webpack 5, Jest 29 with ts-jest, and .github/workflows/build.yml runs npm ci, npm run build and npm test on Node 20 and 22.

The code calls the chrome namespace with callbacks throughout: src/popup.tsx uses chrome.action.setBadgeText, chrome.tabs.query and chrome.tabs.sendMessage, src/options.tsx reads and writes chrome.storage.sync, src/content_script.tsx listens on chrome.runtime.onMessage, and src/background.ts is a setTimeout loop every 30 seconds. Firefox runs Manifest V3 backgrounds as event pages declared with background.scripts and does not start a service_worker; it requires an add-on id under browser_specific_settings.gecko for V3; and it treats host_permissions as optional, granted by the user from the add-on's page or on request, so the content script does not inject on install the way it does in Chrome.

The agent moves the manifest into the build: webpack/manifest.ts produces the Chrome manifest unchanged and a Firefox variant with background.scripts, a browser_specific_settings.gecko.id and strict_min_version, written by a small plugin into dist/ or dist-firefox/ depending on a BROWSER environment variable, with build:firefox added to package.json. It adds webextension-polyfill and @types/webextension-polyfill, replaces each chrome.* callback with the promise form of browser.*, and rewrites the badge, tab query, message and storage calls accordingly. In the popup it adds a check with browser.permissions.contains for the host permission and a button that calls browser.permissions.request from the click handler, so Firefox users can grant access without visiting about:addons. The 30-second loop in background.ts would be killed with the event page; the agent replaces it with the alarms API and the permission that needs, which works in both browsers.

Tooling follows: web-ext as a dev dependency, lint:firefox running web-ext lint --source-dir dist-firefox, and a second job in build.yml that builds the Firefox variant and lints it. Jest tests mock browser.storage and browser.permissions through a module mock and cover the manifest generator for both outputs and the permission prompt in the popup. In the sandbox the agent runs both builds, loads dist/ into Chrome with --load-extension to confirm the popup still counts and sets the badge, and runs web-ext lint on the Firefox build, which rejects manifest keys Firefox does not accept.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Make this Chrome extension work in Firefox as well and open a pull request. Read public/manifest.json, webpack/webpack.common.js, webpack/webpack.prod.js, package.json, tsconfig.json, jest.config.js, src/popup.tsx, src/options.tsx, src/background.ts, src/content_script.tsx and .github/workflows/build.yml first. Generate the manifest in the build with a Firefox variant that uses background.scripts, a browser_specific_settings gecko id and a minimum version, output to a separate directory under a build:firefox script. Replace chrome callback calls with webextension-polyfill promises. Add a host permission check and request button to the popup because Firefox grants Manifest V3 host permissions on request. Replace the setTimeout loop in the background with the alarms API. Add web-ext as a dev dependency with a lint script and a CI job for the Firefox build. Add Jest tests for the manifest generator and the permission prompt. Run both builds, the tests and web-ext lint, and put the output in the pull request description.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request on its own branch. The diff adds webpack/manifest.ts and its test, removes public/manifest.json in favour of the generated one, edits the four source files to use browser.*, adds the permission check to src/popup.tsx, changes package.json with the polyfill, web-ext, build:firefox and lint:firefox, and adds the Firefox job to .github/workflows/build.yml. The description shows the two generated manifests side by side.

The run's record keeps the npm run build, npm run build:firefox, npm test and web-ext lint output, and the screenshot of the popup loaded in Chrome, so a reviewer sees both builds succeed and the linter accept the Firefox manifest before the workflow runs on GitHub.

Before merging, a reviewer checks that the gecko id is the one the team will publish under, that strict_min_version is not lower than the first Firefox release with the V3 features used, that the alarm period keeps whatever the 30-second loop was for, and that the content script still works in Chrome where host permissions are granted at install.

Run it on every extension repository with one browser target

A team shipping several extensions starts one run per repository with POST /o/{org}/sessions, this prompt and the repository in resources. Each run reads its own manifest and bundler config, so an extension that already uses the polyfill gets only the manifest and tooling work, and each opens its own pull request with its own lint output.

Everyone in the org can open the run while it works and read the generated manifests as they appear, and its starter or an org admin can send a follow-up through POST /o/{org}/sessions/{id}/messages when the gecko id or the minimum version should differ.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

Cross-browser support is a list of small differences that only show up when the other browser loads the build: a service worker Firefox never starts, an id Firefox insists on, a host permission that is not granted. In a Rush sandbox the agent produces both builds, runs Mozilla's own linter on the Firefox one and loads the Chrome one, and keeps every result with the pull request.

The change crosses the manifest, the bundler, every API call site, the background lifecycle, the tests and CI. One run returns all of it with its log, and the same prompt runs across every extension repository at once, each in its own sandbox with its own manifest.

Frequently asked questions

Why generate two manifests instead of one with both background keys?

Chrome and Firefox read different background keys for Manifest V3, and the gecko id is meaningless to Chrome. Generating both from one TypeScript source keeps the shared keys identical and lets a Jest test check each output. The build directory for each browser is what the store upload takes.

Will the content script still run on every site in Firefox?

Not until the user grants it. Firefox treats V3 host_permissions as optional, so the popup now shows a button that calls browser.permissions.request for the hosts in the manifest. In Chrome the permission is granted at install and the button is hidden.

Does the polyfill change behaviour in Chrome?

No. webextension-polyfill wraps the chrome namespace in promises where Chrome does not already return them and passes through where it does. The badge, tab query and messaging calls do the same work; the code just awaits them instead of nesting callbacks.

Is the Firefox build published by this run?

No. The run produces dist-firefox/ and the web-ext lint result. Signing and listing on addons.mozilla.org need the team's AMO credentials, and the pull request names web-ext sign as the step a person runs with them.

More Chrome Extension jobs

More jobs like this: Hand off a long task

Keep reading