Youtube Shorts Garbage Remover

Hides elements based on like count conditions. Removes the trash tier garbage youtube shorts shovelled down your throat.

目前為 2023-04-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Youtube Shorts Garbage Remover
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Hides elements based on like count conditions. Removes the trash tier garbage youtube shorts shovelled down your throat.
// @author       psyda#0001 (but actually ChatGPT4)
// @match        https://wWW.youtube.com/shorts/*
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const hideElements = () => {
        const elements = document.querySelectorAll('.reel-video-in-sequence.style-scope.ytd-shorts');

        elements.forEach(element => {
            const likeButton = element.querySelector('#like-button');

            if (likeButton) {
                const likeCountSpan = likeButton.querySelector('span.yt-core-attributed-string.yt-core-attributed-string--white-space-pre-wrap.yt-core-attributed-string--text-alignment-center.yt-core-attributed-string--word-wrapping[role="text"]');

                if (likeCountSpan) {
                    const likeCountText = likeCountSpan.textContent.toLowerCase();

                    if (/\d/.test(likeCountText) && !likeCountText.includes('k')) {
                        element.style.display = 'none';
                    }
                }
            }
        });
    };

    const observeContainer = () => {
        const targetNode = document.querySelector('#shorts-inner-container');

        if (targetNode) {
            const observerConfig = { childList: true, subtree: true };
            const observerCallback = (mutationsList, observer) => {
                hideElements();
            };
            const observer = new MutationObserver(observerCallback);
            observer.observe(targetNode, observerConfig);
        } else {
            setTimeout(observeContainer, 500);
        }
    };

    observeContainer();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址