js-tampermonkey-public-scripts/LE: Delete NoPopular Video.js

33 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==UserScript==
// @name LE: Delete NoPopular Video
// @namespace http://tampermonkey.net/
// @version 2025-01-04
// @description try to take over the world!
// @author LE
// @match https://www.youtube.com/watch?v=*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
setTimeout(() => {
document.querySelectorAll(`span.inline-metadata-item.style-scope.ytd-video-meta-block`).forEach(span => {
const text = span.textContent.trim();
// Проверяем, соответствует ли текст нужному шаблону
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 секунд)
})();