From b677c308277f8d1bd51b4c28dd0b99c7dfd86e30 Mon Sep 17 00:00:00 2001 From: NotAProton Date: Wed, 20 Sep 2023 01:30:21 +0530 Subject: [PATCH] Fix dnr rulset updating before options are saved --- src/js/background.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index 178d6c8c9..58d62ab07 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -5,12 +5,12 @@ const isFirefox = /Firefox/i.test(navigator.userAgent); // Check if the browser is Firefox if (isFirefox) { browser.runtime.onInstalled.addListener((details) => { - if (details.reason === "install") { + if (details.reason === 'install') { browser.storage.local.get('consentStatus').then(function (data) { const consentStatus = data.consentStatus; if (consentStatus !== 'granted') { browser.tabs.create({ - url: "html/consent.html" + url: 'html/consent.html', }); } else { // If consent has been already granted, execute background script @@ -71,7 +71,8 @@ function executeBackgroundScript() { url.pathname = '/html' + url.pathname; if (url.searchParams.get('crowd') === 'true') { url.pathname = - url.pathname.split('/').slice(0, -1).join('/') + '/crowd-bypassed.html'; + url.pathname.split('/').slice(0, -1).join('/') + + '/crowd-bypassed.html'; } else { url.pathname = url.pathname.split('/').slice(0, -1).join('/') + @@ -173,6 +174,9 @@ function executeBackgroundScript() { brws.storage.onChanged.addListener(() => { getOptions().then((options) => { + if (typeof options === 'undefined') { + return; + } if (options.optionBlockIpLoggers === false) { brws.declarativeNetRequest.updateEnabledRulesets({ disableRulesetIds: ['ipLoggerRuleset'],