-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
95 lines (81 loc) · 3.2 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// ==UserScript==
// @name Limpieza de Lista "Ver Más Tarde" de YouTube con Botones Animados
// @namespace http://tampermonkey.net/
// @version 1.4
// @description Elimina automáticamente los videos de la lista "Ver Más Tarde" de YouTube. Añade botones con animaciones para una mejor interacción.
// @author Sebastián Riquelme - GitHub: SebastianRiquelmeM
// @match https://www.youtube.com/playlist?list=WL*
// @grant none
// @license MIT
// @supportURL https://github.com/SebastianRiquelmeM/TamperMonkeyEliminarVerMasTardeYoutube/issues
// ==/UserScript==
(function () {
"use strict";
var intervalId;
function removeVideo() {
var video = document.querySelector("ytd-playlist-video-renderer");
if (!video) return;
var menuButton = video.querySelector("ytd-menu-renderer #button");
if (menuButton) {
menuButton.click();
}
setTimeout(function () {
var removeButton = Array.from(
document.querySelectorAll("ytd-menu-service-item-renderer")
).find((el) => el.innerText.includes("Eliminar de Ver más tarde"));
if (removeButton) {
removeButton.click();
}
}, 500);
}
function applyBootstrapStyle(button, color, hoverColor) {
button.style.padding = "10px 15px";
button.style.fontSize = "14px";
button.style.lineHeight = "1.5";
button.style.borderRadius = "0.25rem";
button.style.border = "1px solid transparent";
button.style.color = "white";
button.style.backgroundColor = color;
button.style.transition =
"color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out, transform .2s";
button.onmouseover = function () {
this.style.backgroundColor = hoverColor;
this.style.transform = "scale(1.05)";
};
button.onmouseout = function () {
this.style.backgroundColor = color;
this.style.transform = "scale(1)";
};
}
function createButtons() {
var sortButton = document.querySelector(
"yt-sort-filter-sub-menu-renderer"
);
if (!sortButton) return;
var buttonContainer = document.createElement("div");
buttonContainer.style.display = "flex";
buttonContainer.style.marginRight = "10px";
var startButton = document.createElement("button");
startButton.textContent = "🗑️ Comenzar a eliminar todos los videos";
startButton.style.cursor = "pointer";
startButton.style.marginRight = "10px";
applyBootstrapStyle(startButton, "#28a745", "#218838"); // Verde con hover más oscuro
startButton.addEventListener("click", function () {
intervalId = setInterval(removeVideo, 1000);
startButton.disabled = true;
});
var stopButton = document.createElement("button");
stopButton.textContent = "🛑 Detener Eliminación";
stopButton.style.cursor = "pointer";
applyBootstrapStyle(stopButton, "#dc3545", "#c82333"); // Rojo con hover más oscuro
stopButton.addEventListener("click", function () {
clearInterval(intervalId);
startButton.disabled = false;
});
buttonContainer.appendChild(startButton);
buttonContainer.appendChild(stopButton);
sortButton.parentNode.insertBefore(buttonContainer, sortButton);
}
// Retrasa la creación de los botones para asegurarse de que el contenedor ha cargado
setTimeout(createButtons, 3000);
})();