Youtube Shorts Garbage Remover

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

当前为 2023-05-01 提交的版本,查看 最新版本

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

(function() {
    'use strict';

    if (!window.location.pathname.startsWith('/shorts/')) {
        return;
    }

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

        elements.forEach(element => {
            // Skip the element if it has already been hidden
            if (element.hasAttribute('data-hidden')) {
                return;
            }

            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') && !likeCountText.includes('m')) {
                        // Find the video title
                        const videoTitleElement = element.querySelector('h2.title.style-scope.ytd-reel-player-header-renderer yt-formatted-string.style-scope.ytd-reel-player-header-renderer');
                        const videoTitle = videoTitleElement ? videoTitleElement.textContent : 'Unknown';

                        // Hide the element and log the information
                        element.style.display = 'none';

                        // Mark the element as hidden
                        element.setAttribute('data-hidden', 'true');

                        // Increment and log the total count of videos skipped
                        const totalSkipped = GM_getValue('totalSkipped', 0) + 1;
                        GM_setValue('totalSkipped', totalSkipped);
                        console.log(`GarbageShort_remover Deleted: "${videoTitle}" with "${likeCountText}" Likes. Saving you time. (Total skipped: ${totalSkipped})`);
                    }
                }
            }
        });
    };

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

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

    observeContainer();
})();

QingJ © 2025

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