Skip to content

Commit 7d87622

Browse files
authored
Merge pull request freelawproject#404 from ttys0dev/fix-firefox-world
fix(background): use chrome.scripting.ExecutionWorld.MAIN for firefox compatibility
2 parents 95084d5 + 0618658 commit 7d87622

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.github/workflows/test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
node-version: [14.x, 16.x, 18.x]
1718
steps:

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Fixes:
1616
- Improves the reliability of PACER case ID retrieval on attachment pages ([369](https://github.com/freelawproject/recap/issues/369), [400](https://github.com/freelawproject/recap-chrome/pull/400)).
1717
- Fix setDefaultOptions in updateToolbarButton([403](https://github.com/freelawproject/recap-chrome/pull/403))
1818
- Ensure we call sendResponse even when notifications are disabled([405](https://github.com/freelawproject/recap-chrome/pull/405))
19+
- Use chrome.scripting.ExecutionWorld.MAIN for firefox compatibility ([404](https://github.com/freelawproject/recap-chrome/pull/404))
1920

2021

2122
For developers:

src/utils/background.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { getCourtFromUrl } from './url_and_cookie_helpers.js';
22

3+
let isSafari =
4+
/Safari/.test(navigator.userAgent) &&
5+
!/Chrome|Chromium/.test(navigator.userAgent);
6+
let executionWorld = isSafari ? 'MAIN' : chrome.scripting.ExecutionWorld.MAIN;
7+
38
export function chooseVariant(details) {
49
const options = ['A-A', 'A-C', 'B-B', 'B-D'];
510
const randomIndex = Math.floor(Math.random() * options.length);
@@ -123,13 +128,12 @@ export function getAndStoreVueData(req, sender, sendResponse) {
123128
.executeScript({
124129
target: { tabId: sender.tab.id },
125130
func: getVueDiv,
126-
world: 'MAIN',
131+
world: executionWorld,
127132
})
128133
.then((injectionResults) => sendResponse(injectionResults));
129134
}
130135

131-
132-
export function overwriteSubmitMethod(req, sender, sendResponse){
136+
export function overwriteSubmitMethod(req, sender, sendResponse) {
133137
const _overwriteScript = () => {
134138
document.createElement('form').__proto__.submit = function () {
135139
this.id = 'form' + new Date().getTime();
@@ -154,7 +158,7 @@ export function overwriteSubmitMethod(req, sender, sendResponse){
154158
.executeScript({
155159
target: { tabId: sender.tab.id },
156160
func: _overwriteScript,
157-
world: 'MAIN',
161+
world: executionWorld,
158162
})
159163
.then((injectionResults) => sendResponse(injectionResults));
160164
}

0 commit comments

Comments
 (0)