Fixed bypass to twitter bug #71

This commit is contained in:
ManeraKai 2022-03-01 22:42:48 +03:00
parent 082016dcde
commit feb20fe96c
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
4 changed files with 36 additions and 37 deletions

View File

@ -214,7 +214,7 @@ function redirect(url, type, initiator) {
].includes(initiator.origin) ||
targets.includes(initiator.host)
)
) return 'BYBASSTAB';
) return 'BYPASSTAB';
if ((!targets.includes(url.host))) return null;

View File

@ -94,24 +94,24 @@ function setProtocol(val) {
console.log("twitterProtocol: ", val)
}
function isTwitter(url, initiator) {
if (disable) return false;
function redirect(url, initiator) {
if (disable) return null;
if (!targets.some((rx) => rx.test(url.href))) return null;
if (url.pathname.split("/").includes("home")) return null;
if (
commonHelper.isFirefox() &&
initiator && (
[
...redirects.nitter.normal,
[...redirects.nitter.normal,
...redirects.nitter.tor,
...nitterTorCustomRedirects,
...nitterNormalCustomRedirects
].includes(initiator.origin) || targets.includes(initiator.host))
) return false;
].includes(initiator.origin)
)
) return 'BYPASSTAB';
return targets.some((rx) => rx.test(url.href));
}
function redirect(url) {
let instancesList;
if (protocol == 'normal')
instancesList = [...nitterNormalRedirectsChecks, ...nitterNormalCustomRedirects];
@ -216,7 +216,6 @@ export default {
setProtocol,
redirect,
isTwitter,
init,
changeInstance,
};

View File

@ -328,8 +328,7 @@ function redirect(url, details, initiator) {
if (
bypassWatchOnYoutube &&
initiator && (
[
...redirects.invidious.normal,
[...redirects.invidious.normal,
...invidiousNormalCustomRedirects,
...redirects.invidious.tor,
...invidiousTorCustomRedirects,
@ -338,10 +337,9 @@ function redirect(url, details, initiator) {
...redirects.piped.tor,
...pipedNormalCustomRedirects,
...pipedTorCustomRedirects
].includes(initiator.origin) ||
targets.includes(initiator.host)
].includes(initiator.origin)
)
) return 'BYBASSTAB';
) return 'BYPASSTAB';
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return null; // Don't redirect YouTube Player API.

View File

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