-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube_AIO.js
46 lines (39 loc) · 1.62 KB
/
youtube_AIO.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
// ==UserScript==
// @name youtube_AIO
// @description Removes youtube tv ad card and auto redirect youtube homepage to subscriptions.
// @version 0.0
// @match http://*.youtube.com/*
// @match https://*.youtube.com/*
// @grant none
// @license MIT
// ==/UserScript==
// fix link auto-redirect. source: https://greasyfork.org/en/scripts/4298-youtube-url-cleaner/code
if (window.location.href !== "https://www.youtube.com/feed/subscriptions") {
var newurl = "https://www.youtube.com/watch?"+document.URL.match(/v\=[^&]*/g)
if (newurl != document.URL) location.replace(newurl);
}
// auto redirect youtube homepage to subscriptions
function redirect_to_subs() {
if (window.location.href !== "https://www.youtube.com/feed/subscriptions") {
if (window.location.href === "https://www.youtube.com/" || window.location.href === "http://www.youtube.com/" ) {
window.location.href = "https://www.youtube.com/feed/subscriptions"
}
}
}
window.addEventListener("yt-navigate-finish", redirect_to_subs)
redirect_to_subs()
const observer = new MutationObserver(function() {
try {
let dialog = document.getElementsByTagName("ytd-mealbar-promo-renderer")
console.log(dialog[0])
dialog[0].style.display = 'none'
}catch(e){console.log("err", e)}
let home_links = document.getElementsByTagName('a')
home_links.forEach(_link => {
if (_link.href === "/") {
console.log(_link)
_link.href = "https://www.youtube.com/feed/subscriptions"
}
})
})
observer.observe(document, {childList: true, characterData: true, subtree: true});