Invidious Preferences

Redirect Invidious Videos with URL Parameters

  1. // ==UserScript==
  2. // @name Invidious Preferences
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.2
  5. // @description Redirect Invidious Videos with URL Parameters
  6. // @author Doctor Derp
  7. // @match *://invidious.baczek.me/*
  8. // @match *://iteroni.com/*
  9. // @match *://invidious.namazso.eu/*
  10. // @match *://iv.ggtyler.dev/*
  11. // @match *://yewtu.be/*
  12. // @match *://vid.puffyan.us/*
  13. // @match *://y.com.sb/*
  14. // @match *://invidious.nerdvpn.de/*
  15. // @match *://invidious.tiekoetter.com/*
  16. // @match *://yt.artemislena.eu/*
  17. // @match *://invidious.flokinet.to/*
  18. // @match *://inv.bp.projectsegfau.lt/*
  19. // @match *://inv.vern.cc/*
  20. // @match *://invidious.projectsegfau.lt/*
  21. // @match *://yt.funami.tech/*
  22. // @match *://invidious.lunar.icu/*
  23. // @match *://invidious.privacydev.net/*
  24. // @match *://invidious.esmailelbob.xyz/*
  25. // @match *://invidious.snopyta.org/*
  26. // @match *://invidious.kavin.rocks/*
  27. // @match *://yt.oelrichsgarcia.de/*
  28. // @match *://invidious.privacydev.net/*
  29. // @match *://inv.zzls.xyz/*
  30. // @match *://vid.priv.au/*
  31. // @match *://invidious.fdn.fr/*
  32. // @match *://inv.tux.pizza/*
  33. // @match *://invidious.nogafa.org/*
  34. // @match *://inv.pistasjis.net/*
  35. // @match *://invidious.protokolla.fi/*
  36. // @match *://inv.in.projectsegfau.lt/*
  37. // @match *://inv.citw.lgbt/*
  38. // @match *://iv.nboeck.de/*
  39. // @match *://invidious.private.coffee/*
  40. // @match *://invidious.asir.dev/*
  41. // @match *://invidious.io.lol/*
  42. // @match *://anontube.lvkaszus.pl/*
  43. // @match *://iv.datura.network/*
  44. // @match *://invidious.no-logs.com/*
  45. // @match *://iv.melmac.space/*
  46. // @match *://yt.cdaut.de/*
  47. // @match *://yt.drgnz.club/*
  48. // @match *://invidious.slipfox.xyz/*
  49. // @match *://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion/*
  50. // @match *://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion/*
  51. // @match *://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion/*
  52. // @match *://grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad.onion/*
  53. // @match *://osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd.onion/*
  54. // @match *://u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad.onion/*
  55. // @match *://euxxcnhsynwmfidvhjf6uzptsmh4dipkmgdmcmxxuo7tunp3ad2jrwyd.onion/*
  56. // @match *://invidious.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion/*
  57. // @match *://inv.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/*
  58. // @match *://am74vkcrjp2d5v36lcdqgsj2m6x36tbrkhsruoegwfcizzabnfgf5zyd.onion/*
  59. // @match *://ng27owmagn5amdm7l5s3rsqxwscl5ynppnis5dqcasogkyxcfqn7psid.onion/*
  60. // @match *://iv.odysfvr23q5wgt7i456o5t3trw2cw5dgn56vbjfbq2m7xsc5vqbqpcyd.onion/*
  61. // @match *://invidious.g4c3eya4clenolymqbpgwz3q3tawoxw56yhzk4vugqrl6dtu3ejvhjid.onion/*
  62. // @match *://verni6dr4qxjgjumnvesxerh5rvhv6oy5ddeibaqy5d7tgbiiyfa.b32.i2p/*
  63. // @grant none
  64. // @license MIT
  65. // @homepage https://gitlab.com/userscripts3/Invidious-Preferences-Userscript
  66. // ==/UserScript==
  67. /** This userscript is based on https://greasyfork.org/en/scripts/450983-genius-back-to-the-original-page-layout but rewritten to enforce video playback preferences as video quality, visibility of comments, etc, through URL parameters and without using browser cookies.
  68. For more information about Invidious URL parameters and the various options, see https://docs.invidious.io/url-parameters/
  69. To edit the enforced URL parameters, change the setting strings below. Keep options in their appropriate catagories (URL Parameters affecting video playback should only be in videosettings, etc). You can keep a setting option blank if you would rather not append any URL parameters.
  70. */
  71. let appearencesettings = "dark_mode=auto&hl=en-US"
  72. let searchsettings = "region=JP"
  73. let videosettings = "related_videos=false&comments=false&quality=hd720&player_style=invidious&extend_desc=true"
  74. let trendingsettings = "type=Music"
  75. /**
  76. Anytime you load a video URL on your desired Invidious instance, this script will check the URL for the desired parameters, and apply them if not found.
  77. To edit the Invidious instances this script applies to, edit the domains above.
  78. You may also edit the Homepage by changing the variable below (options include "search", "popular", and "trending"). */
  79. let homepage = "search"
  80. /** You may also set it so videos in a single playlist play automatically by setting the toggle below. */
  81.  
  82. let PlaylistAutoplay = "true"
  83.  
  84.  
  85. /**
  86.  
  87. It is recommended that you use this script in combination with https://github.com/dybdeskarphet/privacy-redirector and https://codeberg.org/mthsk/userscripts/src/branch/master/simple-sponsor-skipper
  88.  
  89.  
  90. This script can also redirect Invidious Feeds to their YouTube equivelants so that URLs from RSS Feeds can be easily redirected to the most convenient instance. To disable this, set rssRedirect below to "false". */
  91. let rssRedirect = "true"
  92.  
  93. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  94.  
  95. function getCurrentURL () {
  96. return window.location.href;
  97. }
  98.  
  99. // Example
  100. const url = getCurrentURL();
  101.  
  102. (function() {
  103. 'use strict';
  104.  
  105. if (!url.includes("?") && !url.includes(appearencesettings)) {
  106. window.location.replace(url + ("?" + appearencesettings));
  107.  
  108. }
  109.  
  110. else if(!url.includes(appearencesettings)) {
  111. window.location.replace(url + ("&" + appearencesettings));
  112.  
  113. }
  114.  
  115. if (url.includes("q=") && !url.includes(searchsettings)) {
  116. window.location.replace(url + ("&" + appearencesettings + "&" + searchsettings));
  117. }
  118.  
  119. if(homepage.includes("search") && url.includes("feed/trending")){
  120. window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/trending')) + ("search"));
  121. }
  122. else if(homepage.includes("search") && url.includes("feed/popular")){
  123. window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/popular')) + ("search"));
  124. }
  125.  
  126. if(homepage.includes("popular") && url.includes("feed/trending")){
  127. window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/trending')) + ("feed/popular"));
  128. }
  129. else if(homepage.includes("popular") && url.includes("search") && !url.includes("q=")){
  130. window.location.replace (window.location.href.substring(0, window.location.href.indexOf('search')) + ("feed/popular"));
  131. }
  132.  
  133. if(homepage.includes("trending") && url.includes("feed/popular")){
  134. window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/popular')) + ("feed/trending"));
  135. }
  136. else if(homepage.includes("popular") && url.includes("search") && !url.includes("q=")){
  137. window.location.replace (window.location.href.substring(0, window.location.href.indexOf('search')) + ("feed/trending"));
  138. }
  139. if (url.includes("feed/trending") && !url.includes(trendingsettings)) {
  140. window.location.replace(url + ("?" + appearencesettings + "&" + trendingsettings));
  141. }
  142.  
  143. if (url.includes("v=") && url.includes("&list=") && !url.includes(videosettings) && PlaylistAutoplay.includes("true")) {
  144. window.location.replace(url + ("&" + appearencesettings + "&" + videosettings + "&autoplay=1"));
  145. }
  146. else if (url.includes("v=") && !url.includes(videosettings)) {
  147. window.location.replace(url + ("&" + appearencesettings + "&" + videosettings));
  148. }
  149.  
  150. })();
  151.  
  152. var InvidiousLinks = Array.from(document.links).filter(link => link.href.includes(window.location.hostname));
  153. for (var i = 0; i < InvidiousLinks.length; i++) {
  154.  
  155.  
  156. if(!InvidiousLinks[i].href.includes("watch") && !InvidiousLinks[i].href.includes("preferences") && !InvidiousLinks[i].href.includes("channel") && !InvidiousLinks[i].href.includes("search") && !InvidiousLinks[i].href.includes("feed") && !InvidiousLinks[i].href.includes("playlist") && homepage.includes("search") && !InvidiousLinks[i].href.includes("embed")){
  157. InvidiousLinks[i].href = InvidiousLinks[i].href + ("search")
  158. }
  159.  
  160. else if(!InvidiousLinks[i].href.includes("watch") && !InvidiousLinks[i].href.includes("preferences") && !InvidiousLinks[i].href.includes("channel") && !InvidiousLinks[i].href.includes("search") && !InvidiousLinks[i].href.includes("feed") && !InvidiousLinks[i].href.includes("playlist") && homepage.includes("trending") && !InvidiousLinks[i].href.includes("embed")){
  161. InvidiousLinks[i].href = InvidiousLinks[i].href + ("feed/trending")
  162. }
  163.  
  164. else if(!InvidiousLinks[i].href.includes("watch") && !InvidiousLinks[i].href.includes("preferences") && !InvidiousLinks[i].href.includes("channel") && !InvidiousLinks[i].href.includes("search") && !InvidiousLinks[i].href.includes("feed") && !InvidiousLinks[i].href.includes("playlist") && homepage.includes("popular") && !InvidiousLinks[i].href.includes("embed")){
  165. InvidiousLinks[i].href = InvidiousLinks[i].href + ("feed/popular")
  166. }
  167.  
  168. if(InvidiousLinks[i].href.includes("?") && !InvidiousLinks[i].href.includes("v=") && !InvidiousLinks[i].href.includes("embed")){
  169. InvidiousLinks[i].href = InvidiousLinks[i].href + ("&" + appearencesettings)
  170. }
  171. else if (!InvidiousLinks[i].href.includes("feed/channel") && !InvidiousLinks[i].href.includes("feed/playlist") && !InvidiousLinks[i].href.includes("v=") && !InvidiousLinks[i].href.includes("embed")){
  172. InvidiousLinks[i].href = InvidiousLinks[i].href + ("?" + appearencesettings)
  173. }
  174.  
  175. if(InvidiousLinks[i].href.includes("v=") && InvidiousLinks[i].href.includes("&t=")){
  176. InvidiousLinks[i].href = InvidiousLinks[i].href.replace("t=", appearencesettings + "&" + videosettings + "&t=")
  177. }
  178.  
  179. else if (InvidiousLinks[i].href.includes("v=") && InvidiousLinks[i].href.includes("&list=") && !InvidiousLinks[i].href.includes(videosettings) && !InvidiousLinks[i].href.includes("embed") && PlaylistAutoplay.includes("true")){
  180. InvidiousLinks[i].href = InvidiousLinks[i].href + ("&"+ appearencesettings + "&" + videosettings + "&autoplay=1")
  181. }
  182.  
  183.  
  184. else if (InvidiousLinks[i].href.includes("v=") && !InvidiousLinks[i].href.includes(videosettings) && !InvidiousLinks[i].href.includes("embed")){
  185. InvidiousLinks[i].href = InvidiousLinks[i].href + ("&"+ appearencesettings + "&" + videosettings)
  186. }
  187. if(InvidiousLinks[i].href.includes("feed/channel") && rssRedirect.includes("true")){
  188. InvidiousLinks[i].href = ("https://www.youtube.com/feeds/videos.xml?channel_id=" + InvidiousLinks[i].pathname.replace("/feed/channel/", ""))
  189. }
  190. if(InvidiousLinks[i].href.includes("feed/playlist") && rssRedirect.includes("true")){
  191. InvidiousLinks[i].href = ("https://www.youtube.com/feeds/videos.xml?playlist_id=" + InvidiousLinks[i].pathname.replace("/feed/playlist/", ""))
  192. }
  193. }