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