From 8dc807a67bb338c36232489930cc024c522a869e Mon Sep 17 00:00:00 2001 From: ttys0dev <126845556+ttys0dev@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:33:08 -0600 Subject: [PATCH 1/2] fix(background): use chrome.scripting.ExecutionWorld.MAIN for firefox compatibility --- .github/workflows/test.yml | 1 + CHANGES.md | 1 + src/utils/background.js | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ac78cd0..6761876c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: [14.x, 16.x, 18.x] steps: diff --git a/CHANGES.md b/CHANGES.md index b4427e96..a14772a4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ Fixes: - Refines the generateFileName method to accurately compute zip file names ([366](https://github.com/freelawproject/recap/issues/366), [399](https://github.com/freelawproject/recap-chrome/pull/399)). - 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)). - Fix setDefaultOptions in updateToolbarButton([403](https://github.com/freelawproject/recap-chrome/pull/403)) + - Use chrome.scripting.ExecutionWorld.MAIN for firefox compatibility ([404](https://github.com/freelawproject/recap-chrome/pull/404)) For developers: diff --git a/src/utils/background.js b/src/utils/background.js index f66718b8..b9cd7455 100644 --- a/src/utils/background.js +++ b/src/utils/background.js @@ -123,7 +123,7 @@ export function getAndStoreVueData(req, sender, sendResponse) { .executeScript({ target: { tabId: sender.tab.id }, func: getVueDiv, - world: 'MAIN', + world: chrome.scripting.ExecutionWorld.MAIN, }) .then((injectionResults) => sendResponse(injectionResults)); } @@ -154,7 +154,7 @@ export function overwriteSubmitMethod(req, sender, sendResponse){ .executeScript({ target: { tabId: sender.tab.id }, func: _overwriteScript, - world: 'MAIN', + world: chrome.scripting.ExecutionWorld.MAIN, }) .then((injectionResults) => sendResponse(injectionResults)); } From 06186588325a108e95df2bb0bece27775cc53445 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Thu, 31 Oct 2024 11:02:58 -0400 Subject: [PATCH 2/2] feat(background): Improve compatibility for Safari - Detect Safari browser explicitly - Adjust execution world to 'MAIN' for Safari, 'chrome.scripting.ExecutionWorld.MAIN' for other browsers --- src/utils/background.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/background.js b/src/utils/background.js index b9cd7455..646abe80 100644 --- a/src/utils/background.js +++ b/src/utils/background.js @@ -1,5 +1,10 @@ import { getCourtFromUrl } from './url_and_cookie_helpers.js'; +let isSafari = + /Safari/.test(navigator.userAgent) && + !/Chrome|Chromium/.test(navigator.userAgent); +let executionWorld = isSafari ? 'MAIN' : chrome.scripting.ExecutionWorld.MAIN; + export function chooseVariant(details) { const options = ['A-A', 'A-C', 'B-B', 'B-D']; const randomIndex = Math.floor(Math.random() * options.length); @@ -123,13 +128,12 @@ export function getAndStoreVueData(req, sender, sendResponse) { .executeScript({ target: { tabId: sender.tab.id }, func: getVueDiv, - world: chrome.scripting.ExecutionWorld.MAIN, + world: executionWorld, }) .then((injectionResults) => sendResponse(injectionResults)); } - -export function overwriteSubmitMethod(req, sender, sendResponse){ +export function overwriteSubmitMethod(req, sender, sendResponse) { const _overwriteScript = () => { document.createElement('form').__proto__.submit = function () { this.id = 'form' + new Date().getTime(); @@ -154,7 +158,7 @@ export function overwriteSubmitMethod(req, sender, sendResponse){ .executeScript({ target: { tabId: sender.tab.id }, func: _overwriteScript, - world: chrome.scripting.ExecutionWorld.MAIN, + world: executionWorld, }) .then((injectionResults) => sendResponse(injectionResults)); }