mirror of
https://codeberg.org/LibRedirect/libredirect.git
synced 2025-02-02 20:36:51 +01:00
Added hard cancel requests, will be more improved
This commit is contained in:
parent
f69ff24201
commit
23be155b20
@ -5,9 +5,11 @@ import commonHelper from '../common.js'
|
||||
window.browser = window.browser || window.chrome;
|
||||
|
||||
const targets = [
|
||||
"studio.youtube.com",
|
||||
"m.youtube.com",
|
||||
"youtube.com",
|
||||
"img.youtube.com",
|
||||
"i.ytimg.com",
|
||||
"www.youtube.com",
|
||||
"youtube-nocookie.com",
|
||||
"www.youtube-nocookie.com",
|
||||
@ -243,7 +245,7 @@ function redirect(url, initiator, type) {
|
||||
return null;
|
||||
|
||||
if (url.host.split(".")[0] === "studio") return null;// Avoid `studio.youtube.com`
|
||||
|
||||
|
||||
if (url.pathname.match(/iframe_api/) || url.pathname.match(/www-widgetapi/)) return null; // Don't redirect YouTube Player API.
|
||||
|
||||
if (frontend == 'freeTube' && type === "main_frame")
|
||||
@ -271,8 +273,6 @@ function redirect(url, initiator, type) {
|
||||
|
||||
let randomInstance = commonHelper.getRandomInstance(redirects.piped.normal);
|
||||
|
||||
console.log(" redirects.invidious.normal.includes(url.hostname)", redirects.invidious.normal.includes(url.hostname))
|
||||
|
||||
if (
|
||||
url.hostname.endsWith("youtube.com") ||
|
||||
url.hostname.endsWith("youtube-nocookie.com") ||
|
||||
@ -284,6 +284,7 @@ function redirect(url, initiator, type) {
|
||||
return `${randomInstance}/watch?v=${url.pathname.substring(1)}`;
|
||||
|
||||
}
|
||||
return 'CANCEL';
|
||||
}
|
||||
|
||||
export default {
|
||||
|
@ -58,8 +58,14 @@ browser.webRequest.onBeforeRequest.addListener(
|
||||
else if (wikipediaHelper.isWikipedia(url)) newUrl = wikipediaHelper.redirect(url, initiator);
|
||||
|
||||
if (newUrl) {
|
||||
console.info("Redirecting", url.href, "=>", newUrl);
|
||||
return { redirectUrl: newUrl };
|
||||
if (newUrl == 'CANCEL') {
|
||||
console.log(`Canceled ${url}`);
|
||||
return { cancel: true };
|
||||
}
|
||||
else {
|
||||
console.info("Redirecting", url.href, "=>", newUrl);
|
||||
return { redirectUrl: newUrl };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user