Fixed bugs
This commit is contained in:
parent
16d8069191
commit
587b16e107
|
@ -1,4 +1,6 @@
|
|||
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
function getCookie() {
|
||||
for (const c of document.cookie.split(";")) {
|
||||
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
||||
|
|
|
@ -435,12 +435,12 @@ function changeInstance(url) {
|
|||
return randomInstance;
|
||||
}
|
||||
|
||||
function isPipedorInvidious(url, details) {
|
||||
function isPipedorInvidious(url, type) {
|
||||
let protocolHost = `${url.protocol}//${url.host}`;
|
||||
return (details.type === "main_frame" || details.type === "sub_frame") && [
|
||||
return (type === "main_frame" || type === "sub_frame") && [
|
||||
...redirects.invidious.normal,
|
||||
...invidiousNormalCustomRedirects,
|
||||
...redirects.invidious.tor,
|
||||
...invidiousNormalCustomRedirects,
|
||||
...invidiousTorCustomRedirects,
|
||||
|
||||
...redirects.piped.normal,
|
||||
|
@ -450,9 +450,26 @@ function isPipedorInvidious(url, details) {
|
|||
].includes(protocolHost);
|
||||
}
|
||||
|
||||
function isUrlPipedorInvidious(url) {
|
||||
function isUrlPipedorInvidious(url, frontend) {
|
||||
url = new URL(url);
|
||||
let protocolHost = `${url.protocol}//${url.host}`;
|
||||
|
||||
if (frontend == 'invidious')
|
||||
return [
|
||||
...redirects.invidious.normal,
|
||||
...redirects.invidious.tor,
|
||||
...invidiousNormalCustomRedirects,
|
||||
...invidiousTorCustomRedirects,
|
||||
].includes(protocolHost);
|
||||
|
||||
if (frontend == 'piped')
|
||||
return [
|
||||
...redirects.piped.normal,
|
||||
...redirects.piped.tor,
|
||||
...pipedNormalCustomRedirects,
|
||||
...pipedTorCustomRedirects,
|
||||
].includes(protocolHost);
|
||||
|
||||
return [
|
||||
...redirects.invidious.normal,
|
||||
...redirects.invidious.tor,
|
||||
|
@ -463,15 +480,14 @@ function isUrlPipedorInvidious(url) {
|
|||
...redirects.piped.tor,
|
||||
...pipedNormalCustomRedirects,
|
||||
...pipedTorCustomRedirects,
|
||||
|
||||
].includes(protocolHost);
|
||||
}
|
||||
|
||||
function addUrlParams(url) {
|
||||
|
||||
console.log("addUrlParams");
|
||||
let protocolHost = `${url.protocol}//${url.host}`;
|
||||
let isChanged = false;
|
||||
console.log("protocolHost", protocolHost);
|
||||
console.log("AddingprotocolHost", protocolHost);
|
||||
console.log([
|
||||
...redirects.invidious.normal,
|
||||
...redirects.invidious.tor,
|
||||
|
|
|
@ -38,11 +38,5 @@
|
|||
},
|
||||
"web_accessible_resources": [
|
||||
"assets/javascripts/helpers/youtube/invidious-cookies.js"
|
||||
],
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "7esoorv3@alefvanoon.anonaddy.me",
|
||||
"strict_min_version": "67.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -75,6 +75,7 @@ browser.webRequest.onBeforeRequest.addListener(
|
|||
if (wikipediaHelper.isWikipedia(url, initiator)) newUrl = wikipediaHelper.redirect(url);
|
||||
|
||||
if (youtubeHelper.isPipedorInvidious(newUrl ?? url, details.type)) newUrl = youtubeHelper.addUrlParams(newUrl ?? url);
|
||||
else console.log("isPipedorInvidiousisFalse");
|
||||
|
||||
if (bybassTabs.includes(details.tabId)) newUrl = null;
|
||||
|
||||
|
@ -108,6 +109,6 @@ browser.tabs.onRemoved.addListener((tabId) => {
|
|||
|
||||
browser.tabs.onUpdated.addListener(
|
||||
(tabId, changeInfo) => {
|
||||
if (changeInfo.url && youtubeHelper.isUrlPipedorInvidious(changeInfo.url))
|
||||
if (changeInfo.url && youtubeHelper.isUrlPipedorInvidious(changeInfo.url, 'invidious'))
|
||||
youtubeHelper.invidiousInitCookies(tabId);
|
||||
});
|
|
@ -49,6 +49,7 @@ input[type="text"],
|
|||
select {
|
||||
padding: 5px 10px;
|
||||
width: 350px;
|
||||
font-weight: bold;
|
||||
border-radius: 3px;
|
||||
box-sizing: border-box;
|
||||
background-color: var(--bg-main);
|
||||
|
|
Loading…
Reference in New Issue