This repository was archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInvidious-Preferences.js
186 lines (156 loc) · 11 KB
/
Invidious-Preferences.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// ==UserScript==
// @name Invidious Preferences
// @namespace http://tampermonkey.net/
// @version 3
// @description Redirect Invidious Videos with URL Parameters
// @author MintMain21
// @match *://invidious.baczek.me/*
// @match *://iteroni.com/*
// @match *://invidious.namazso.eu/*
// @match *://iv.ggtyler.dev/*
// @match *://yewtu.be/*
// @match *://vid.puffyan.us/*
// @match *://y.com.sb/*
// @match *://invidious.nerdvpn.de/*
// @match *://invidious.tiekoetter.com/*
// @match *://yt.artemislena.eu/*
// @match *://invidious.flokinet.to/*
// @match *://inv.bp.projectsegfau.lt/*
// @match *://inv.vern.cc/*
// @match *://invidious.projectsegfau.lt/*
// @match *://yt.funami.tech/*
// @match *://invidious.lunar.icu/*
// @match *://invidious.privacydev.net/*
// @match *://invidious.esmailelbob.xyz/*
// @match *://invidious.snopyta.org/*
// @match *://invidious.kavin.rocks/*
// @match *://yt.oelrichsgarcia.de/*
// @match *://invidious.privacydev.net/*
// @match *://inv.zzls.xyz/*
// @match *://vid.priv.au/*
// @match *://invidious.fdn.fr/*
// @match *://inv.tux.pizza/*
// @match *://invidious.nogafa.org/*
// @match *://inv.pistasjis.net/*
// @match *://invidious.protokolla.fi/*
// @match *://inv.in.projectsegfau.lt/*
// @match *://inv.citw.lgbt/*
// @match *://iv.nboeck.de/*
// @match *://invidious.private.coffee/*
// @match *://invidious.asir.dev/*
// @match *://invidious.io.lol/*
// @match *://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion/*
// @match *://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion/*
// @match *://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion/*
// @match *://grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad.onion/*
// @match *://osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd.onion/*
// @match *://u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad.onion/*
// @match *://euxxcnhsynwmfidvhjf6uzptsmh4dipkmgdmcmxxuo7tunp3ad2jrwyd.onion/*
// @match *://invidious.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion/*
// @match *://inv.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/*
// @match *://am74vkcrjp2d5v36lcdqgsj2m6x36tbrkhsruoegwfcizzabnfgf5zyd.onion/*
// @match *://ng27owmagn5amdm7l5s3rsqxwscl5ynppnis5dqcasogkyxcfqn7psid.onion/*
// @match *://iv.odysfvr23q5wgt7i456o5t3trw2cw5dgn56vbjfbq2m7xsc5vqbqpcyd.onion/*
// @match *://invidious.g4c3eya4clenolymqbpgwz3q3tawoxw56yhzk4vugqrl6dtu3ejvhjid.onion/*
// @match *://verni6dr4qxjgjumnvesxerh5rvhv6oy5ddeibaqy5d7tgbiiyfa.b32.i2p/*
// @grant none
// @license MIT
// @homepage https://github.com/MintMain21/Invidious-URL-Parameters-Userscript
// ==/UserScript==
/** 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.
For more information about Invidious URL parameters and the various options, see https://docs.invidious.io/url-parameters/
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.
*/
let appearencesettings = "dark_mode=auto&hl=en-US"
let searchsettings = "region=JP"
let videosettings = "related_videos=false&comments=false&quality=hd720&player_style=invidious&extend_desc=true"
let trendingsettings = "type=Music"
/**
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.
To edit the Invidious instances this script applies to, edit the domains above.
You may also edit the Homepage by changing the variable below (options include "search", "popular", and "trending"). */
let homepage = "search"
/** You may also set it so videos in a single playlist play automatically by setting the toggle below. */
let PlaylistAutoplay = "true"
/**
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
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". */
let rssRedirect = "true"
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getCurrentURL () {
return window.location.href;
}
// Example
const url = getCurrentURL();
(function() {
'use strict';
if (!url.includes("?") && !url.includes(appearencesettings)) {
window.location.replace(url + ("?" + appearencesettings));
}
else if(!url.includes(appearencesettings)) {
window.location.replace(url + ("&" + appearencesettings));
}
if (url.includes("q=") && !url.includes(searchsettings)) {
window.location.replace(url + ("&" + appearencesettings + "&" + searchsettings));
}
if(homepage.includes("search") && url.includes("feed/trending")){
window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/trending')) + ("search"));
}
else if(homepage.includes("search") && url.includes("feed/popular")){
window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/popular')) + ("search"));
}
if(homepage.includes("popular") && url.includes("feed/trending")){
window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/trending')) + ("feed/popular"));
}
else if(homepage.includes("popular") && url.includes("search") && !url.includes("q=")){
window.location.replace (window.location.href.substring(0, window.location.href.indexOf('search')) + ("feed/popular"));
}
if(homepage.includes("trending") && url.includes("feed/popular")){
window.location.replace (window.location.href.substring(0, window.location.href.indexOf('feed/popular')) + ("feed/trending"));
}
else if(homepage.includes("popular") && url.includes("search") && !url.includes("q=")){
window.location.replace (window.location.href.substring(0, window.location.href.indexOf('search')) + ("feed/trending"));
}
if (url.includes("feed/trending") && !url.includes(trendingsettings)) {
window.location.replace(url + ("?" + appearencesettings + "&" + trendingsettings));
}
if (url.includes("v=") && url.includes("&list=") && !url.includes(videosettings) && PlaylistAutoplay.includes("true")) {
window.location.replace(url + ("&" + appearencesettings + "&" + videosettings + "&autoplay=1"));
}
else if (url.includes("v=") && !url.includes(videosettings)) {
window.location.replace(url + ("&" + appearencesettings + "&" + videosettings));
}
})();
var InvidiousLinks = Array.from(document.links).filter(link => link.href.includes(window.location.hostname));
for (var i = 0; i < InvidiousLinks.length; i++) {
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")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("search")
}
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")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("feed/trending")
}
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")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("feed/popular")
}
if(InvidiousLinks[i].href.includes("?") && !InvidiousLinks[i].href.includes("v=") && !InvidiousLinks[i].href.includes("embed")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("&" + appearencesettings)
}
else if (!InvidiousLinks[i].href.includes("feed/channel") && !InvidiousLinks[i].href.includes("feed/playlist") && !InvidiousLinks[i].href.includes("v=") && !InvidiousLinks[i].href.includes("embed")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("?" + appearencesettings)
}
if(InvidiousLinks[i].href.includes("v=") && InvidiousLinks[i].href.includes("&t=")){
InvidiousLinks[i].href = InvidiousLinks[i].href.replace("t=", appearencesettings + "&" + videosettings + "&t=")
}
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")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("&"+ appearencesettings + "&" + videosettings + "&autoplay=1")
}
else if (InvidiousLinks[i].href.includes("v=") && !InvidiousLinks[i].href.includes(videosettings) && !InvidiousLinks[i].href.includes("embed")){
InvidiousLinks[i].href = InvidiousLinks[i].href + ("&"+ appearencesettings + "&" + videosettings)
}
if(InvidiousLinks[i].href.includes("feed/channel") && rssRedirect.includes("true")){
InvidiousLinks[i].href = ("https://www.youtube.com/feeds/videos.xml?channel_id=" + InvidiousLinks[i].pathname.replace("/feed/channel/", ""))
}
if(InvidiousLinks[i].href.includes("feed/playlist") && rssRedirect.includes("true")){
InvidiousLinks[i].href = ("https://www.youtube.com/feeds/videos.xml?playlist_id=" + InvidiousLinks[i].pathname.replace("/feed/playlist/", ""))
}
}