Обновить LE: Delete NoPopular Video.js
This commit is contained in:
parent
65bd885723
commit
0ffb1f7c26
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name LE: Delete NoPopular Video
|
// @name LE: Delete NoPopular Video
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 2025-03-11
|
// @version 2025-01-04
|
||||||
// @description Удаляет непопулярные видео на YouTube.
|
// @description Удаляет непопулярные видео на YouTube.
|
||||||
// @author LE
|
// @author LE
|
||||||
// @match https://www.youtube.com/watch?v=*
|
// @match https://www.youtube.com/watch?v=*
|
||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
let lastUrl = location.href;
|
let lastUrl = location.href;
|
||||||
|
let tabActivatedOnce = false;
|
||||||
|
|
||||||
function deleteNoPopularVideos() {
|
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 => {
|
||||||
@ -32,7 +33,6 @@
|
|||||||
setTimeout(deleteNoPopularVideos, vTime);
|
setTimeout(deleteNoPopularVideos, vTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Запускаем при загрузке страницы
|
// Запускаем при загрузке страницы
|
||||||
startScript(5000);
|
startScript(5000);
|
||||||
startScript(10000);
|
startScript(10000);
|
||||||
@ -42,9 +42,20 @@
|
|||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (location.href !== lastUrl) {
|
if (location.href !== lastUrl) {
|
||||||
lastUrl = location.href;
|
lastUrl = location.href;
|
||||||
startScript();
|
startScript(5000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
observer.observe(document.body, { childList: true, subtree: true });
|
observer.observe(document.body, { childList: true, subtree: true });
|
||||||
|
|
||||||
|
// Запуск скрипта, если вкладка была открыта в фоне и на неё переключились
|
||||||
|
document.addEventListener(`visibilitychange`, () => {
|
||||||
|
if (!tabActivatedOnce && document.visibilityState === `visible`) {
|
||||||
|
tabActivatedOnce = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
startScript(3000);
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user