Обновить LE: Delete NoPopular Video.js
This commit is contained in:
parent
717c0bc23d
commit
65bd885723
@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name LE: Delete NoPopular Video
|
// @name LE: Delete NoPopular Video
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 2025-01-04
|
// @version 2025-03-11
|
||||||
// @description try to take over the world!
|
// @description Удаляет непопулярные видео на YouTube.
|
||||||
// @author LE
|
// @author LE
|
||||||
// @match https://www.youtube.com/watch?v=*
|
// @match https://www.youtube.com/watch?v=*
|
||||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
|
||||||
@ -11,23 +11,40 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
let lastUrl = location.href;
|
||||||
|
|
||||||
setTimeout(() => {
|
function deleteNoPopularVideos() {
|
||||||
document.querySelectorAll(`span.inline-metadata-item.style-scope.ytd-video-meta-block`).forEach(span => {
|
document.querySelectorAll(`span.inline-metadata-item.style-scope.ytd-video-meta-block`).forEach(span => {
|
||||||
const text = span.textContent.trim();
|
const text = span.textContent.trim();
|
||||||
// Проверяем, соответствует ли текст нужному шаблону
|
if (/^\d+\sпросмот*/.test(text)) {
|
||||||
if (/^\d+\sпросмотр*/.test(text)) {
|
|
||||||
let parent = span;
|
let parent = span;
|
||||||
// Поднимаемся по дереву, пока не найдем <ytd-compact-video-renderer>
|
|
||||||
while (parent && parent.tagName !== 'YTD-COMPACT-VIDEO-RENDERER') {
|
while (parent && parent.tagName !== 'YTD-COMPACT-VIDEO-RENDERER') {
|
||||||
parent = parent.parentElement;
|
parent = parent.parentElement;
|
||||||
}
|
}
|
||||||
// Удаляем найденный элемент
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.remove();
|
parent.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 5000); // Задержка в миллисекундах (5000 = 5 секунд)
|
}
|
||||||
|
|
||||||
})();
|
function startScript(vTime) {
|
||||||
|
setTimeout(deleteNoPopularVideos, vTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Запускаем при загрузке страницы
|
||||||
|
startScript(5000);
|
||||||
|
startScript(10000);
|
||||||
|
startScript(20000);
|
||||||
|
|
||||||
|
// Следим за изменением URL (например, при переходе по видео без полной перезагрузки страницы)
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
if (location.href !== lastUrl) {
|
||||||
|
lastUrl = location.href;
|
||||||
|
startScript();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
observer.observe(document.body, { childList: true, subtree: true });
|
||||||
|
})();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user