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)); }