Добавить LE: Delete NoPopular Video.js

This commit is contained in:
lukas91 2025-01-05 04:05:18 +05:00
parent 1299fba291
commit 22a95820d3

View File

@ -0,0 +1,31 @@
// ==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() {
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();
}
}
});
})();