Skip to content

Commit

Permalink
Removed ?si= from youtube frontends #922
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed May 20, 2024
1 parent 33fc116 commit abcd566
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ function rewrite(url, frontend, randomInstance) {
case "librey":
return `${randomInstance}/search.php${url.search}`
case "yattee":
url.searchParams.delete("si")
return url.href.replace(/^https?:\/{2}/, "yattee://")
case "freetube":
url.searchParams.delete("si")
return 'freetube://' + url.href
case "freetubePwa":
url.searchParams.delete("si")
return 'freetube://' + url.href
case "poketube": {
url.searchParams.delete("si")
if (url.pathname.startsWith('/channel')) {
const reg = /\/channel\/(.*)\/?$/.exec(url.pathname)
if (reg) {
Expand Down Expand Up @@ -383,6 +387,7 @@ function rewrite(url, frontend, randomInstance) {
return `${randomInstance}${url.pathname}${url.search}`
}
case "invidious": {
url.searchParams.delete("si")
if (url.hostname == "youtu.be" || url.hostname.endsWith("youtube.com") && url.pathname.startsWith("/live")) {
const watch = url.pathname.substring(url.pathname.lastIndexOf('/') + 1)
return `${randomInstance}/watch?v=${watch}${url.search.replace("?", "&")}`
Expand All @@ -407,6 +412,7 @@ function rewrite(url, frontend, randomInstance) {
return `${randomInstance}${url.pathname}${url.search}`
}
case "tuboYoutube":
url.searchParams.delete("si")
if (url.pathname.startsWith("/channel")) return `${randomInstance}/channel?url=${encodeURIComponent(url.href)}`
if (url.pathname.startsWith("/watch")) return `${randomInstance}/stream?url=${encodeURIComponent(url.href)}`
return randomInstance
Expand Down Expand Up @@ -442,6 +448,11 @@ function rewrite(url, frontend, randomInstance) {
}
return `${randomInstance}${url.pathname}${url.search}`;
}
case "piped":
case "pipedMaterial":
case "cloudtube":
case "viewtube":
url.searchParams.delete("si")
default:
return `${randomInstance}${url.pathname}${url.search}`
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let tabIdRedirects = {}
browser.webRequest.onBeforeRequest.addListener(
details => {
const url = new URL(details.url)
const old_href = url.href
if (new RegExp(/^chrome-extension:\/{2}.*\/instances\/.*.json$/).test(url.href) && details.type == "xmlhttprequest") return
let initiator
try {
Expand Down Expand Up @@ -71,7 +72,7 @@ browser.webRequest.onBeforeRequest.addListener(
if (tabIdRedirects[details.tabId] != false) tabIdRedirects[details.tabId] = false
return null
}
console.log("Redirecting", url.href, "=>", newUrl)
console.log("Redirecting", old_href, "=>", newUrl)
return { redirectUrl: newUrl }
}
return null
Expand Down

0 comments on commit abcd566

Please sign in to comment.