-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
76 lines (65 loc) · 2.02 KB
/
script.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
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
function main(){
'use strict';
console.log("test");
let test = document.querySelector('.style-scope ytd-mini-guide-renderer');
let button = test.querySelector('[aria-label="Shorts"]');
console.log("got everything");
button.remove();
console.log("done");
// Get the current time
let now = new Date();
// Set the start and end times
let start = new Date();
start.setHours(18, 0, 0); // 12pm
// Check if the current time is between the start and end times
if (now >= start) {
// Launch the function here
close();
}
}
function close(){
'use strict';
console.log("Try to close window");
window.location.href = 'about:blank';
}
function shorts(){
if (window.location.href.includes('shorts')){
setTimeout(close, 100);}
console.log(window.location.href)
}
function remove_shorts_video(){
let liste = document.querySelectorAll("#thumbnail");
for (var i = 0; i<liste.length; i++){
if (liste[i].tagName == 'A'){
if (liste[i].href.includes("shorts")){
console.log(liste[i].href);
liste[i].parentNode.parentNode.parentNode.remove();
}}
}
}
(function() {
'use strict';
console.log("test");
window.addEventListener('load', function(){setTimeout(main, 1000);});
setTimeout(close, 10*60*1000);
setTimeout(shorts,1000);
const observer = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
remove_shorts_video(); // run your function here
}
}
});
observer.observe(document.body, { childList: true, subtree: true });
//setInterval(remove_shorts_video, 1000)
})();