Skip to content

Commit

Permalink
Disabled autoplay for embedded invidious #319
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Jan 20, 2025
1 parent ae18594 commit 03b2108
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/assets/javascripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ function regexArray(service, url, config, options, frontend) {
* @param {URL} url
* @param {string} frontend
* @param {string} randomInstance
* @param {string} type
* @returns {undefined|string}
*/
function rewrite(url, originUrl, frontend, randomInstance) {
function rewrite(url, originUrl, frontend, randomInstance, type) {
switch (frontend) {
case "hyperpipe":
for (const key of [...url.searchParams.keys()]) if (key !== "q") url.searchParams.delete(key)
Expand Down Expand Up @@ -384,10 +385,14 @@ function rewrite(url, originUrl, frontend, randomInstance) {
return `${randomInstance}${url.pathname}${url.search}`
}
case "invidious": {
// tracker
url.searchParams.delete("si")

if (type == "sub_frame") url.searchParams.append("autoplay", "0")

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("?", "&")}`
return `${randomInstance}/watch?v=${watch}&${url.search.substring(1)}`
}
if (url.hostname.endsWith("youtube.com") && url.pathname.startsWith("/redirect?")) return url.href
return `${randomInstance}${url.pathname}${url.search}`
Expand Down Expand Up @@ -557,7 +562,7 @@ function rewrite(url, originUrl, frontend, randomInstance) {

case "duckDuckGoAiChat":
return "https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=1"

case "soundcloak":
if (url.pathname.startsWith("/feed") || url.pathname.startsWith("/stream")) { // this feature requires authentication and is unsupported, so just redirect to main page
return randomInstance
Expand Down Expand Up @@ -668,7 +673,7 @@ function redirect(url, type, originUrl, documentUrl, incognito, forceRedirection
}
if (!frontend) return

return rewrite(url, originUrl, frontend, randomInstance)
return rewrite(url, originUrl, frontend, randomInstance, type)
}

/**
Expand Down

0 comments on commit 03b2108

Please sign in to comment.