about summary refs log tree commit diff stats
path: root/src/pages/background/background.js
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-03-01 22:42:48 +0300
committerManeraKai <manerakai@protonmail.com>2022-03-01 22:42:48 +0300
commitfeb20fe96c41ab7cef4897cada60affe92085c7c (patch)
tree7784ed373935c61f18bc26bfa7e3411a8147d2a4 /src/pages/background/background.js
parentRemoved invidious cookies as it's not working (diff)
downloadlibredirect-feb20fe96c41ab7cef4897cada60affe92085c7c.zip
Fixed bypass to twitter bug #71
Diffstat (limited to 'src/pages/background/background.js')
-rw-r--r--src/pages/background/background.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 13bbb5d4..3211e1c7 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -36,7 +36,7 @@ wholeInit();
 
 browser.storage.onChanged.addListener(wholeInit);
 
-let bybassTabs = [];
+let BYPASSTABs = [];
 
 browser.webRequest.onBeforeRequest.addListener(
   (details) => {
@@ -53,7 +53,7 @@ browser.webRequest.onBeforeRequest.addListener(
     if (youtubeHelper.isPipedorInvidious(newUrl ?? url, details.type)) newUrl = youtubeHelper.addUrlParams(newUrl ?? url);
     if (youtubeMusicHelper.isYoutubeMusic(url, initiator)) newUrl = youtubeMusicHelper.redirect(url, details.type)
 
-    if (twitterHelper.isTwitter(url, initiator)) newUrl = twitterHelper.redirect(url);
+    if (!newUrl) newUrl = twitterHelper.redirect(url, initiator);
 
     if (instagramHelper.isInstagram(url, initiator)) newUrl = instagramHelper.redirect(url, details.type);
 
@@ -75,16 +75,16 @@ browser.webRequest.onBeforeRequest.addListener(
 
     if (exceptionsHelper.isException(url, initiator)) newUrl = null;
 
-    if (bybassTabs.includes(details.tabId)) newUrl = null;
+    if (BYPASSTABs.includes(details.tabId)) newUrl = null;
 
     if (newUrl) {
       if (newUrl == 'CANCEL') {
         console.log(`Canceled ${url}`);
         return { cancel: true };
       }
-      else if (newUrl == 'BYBASSTAB') {
-        console.log(`Bybassed ${details.tabId}`);
-        bybassTabs.push(details.tabId);
+      else if (newUrl == 'BYPASSTAB') {
+        console.log(`Bybassed ${details.tabId} ${url}`);
+        BYPASSTABs.push(details.tabId);
         return null;
       }
       else {
@@ -99,9 +99,11 @@ browser.webRequest.onBeforeRequest.addListener(
 );
 
 browser.tabs.onRemoved.addListener((tabId) => {
-  let index = bybassTabs.indexOf(tabId);
-  if (index > -1) bybassTabs.splice(index, 1);
-  console.log("Removed bybassTabs", tabId);
+  let index = BYPASSTABs.indexOf(tabId);
+  if (index > -1) {
+    BYPASSTABs.splice(index, 1);
+    console.log("Removed BYPASSTABs", tabId);
+  }
 });