From 0e889c2d4285b3cf1767cb9b8a3957ec5392324d Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sun, 3 Apr 2022 13:55:54 +0300 Subject: Restructured exceptions to behave in another way #164 #161 --- src/pages/background/background.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/pages/background') diff --git a/src/pages/background/background.js b/src/pages/background/background.js index e54627c4..650a48a8 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -92,7 +92,12 @@ browser.webRequest.onBeforeRequest.addListener( if (!newUrl) newUrl = wikipediaHelper.redirect(url); - if (generalHelper.isException(url, initiator)) newUrl = null; + if ( + details.frameAncestors && details.frameAncestors.length > 0 && + generalHelper.isException(new URL(details.frameAncestors[0].url)) + ) newUrl = null; + + if (generalHelper.isException(url)) newUrl = null; if (BYPASSTABs.includes(details.tabId)) newUrl = null; @@ -103,15 +108,11 @@ browser.webRequest.onBeforeRequest.addListener( } else if (newUrl == 'BYPASSTAB') { console.log(`Bybassed ${details.tabId} ${url}`); - BYPASSTABs.push(details.tabId); + if (!BYPASSTABs.includes(details.tabId)) BYPASSTABs.push(details.tabId); return null; } else { console.info("Redirecting", url.href, "=>", newUrl); - // let wewe = new URL(newUrl); - // console.log("wewe", wewe.search); - // console.log("path", wewe.pathname); - // console.log("searchParams", wewe.searchParams); return { redirectUrl: newUrl }; } } @@ -206,7 +207,8 @@ browser.tabs.onUpdated.addListener( if (instagramHelper.isBibliogram(url)) instagramHelper.initBibliogramCookies(url); // if (changeInfo.url && youtubeHelper.isPipedorInvidious(url, 'main_frame', 'pipedMaterial')) youtubeHelper.initPipedMaterialLocalStorage(tabId); - }); + } +); function changeWholeInstance(url) { let newUrl = youtubeHelper.switchInstance(url); -- cgit 1.4.1