YouTube Shorts Blocker Ultra + Blocking Youtube Shorts GUI On Homepage And Videos

Blocks YouTube Shorts

目前為 2024-12-30 提交的版本,檢視 最新版本

// ==UserScript==
// @name         YouTube Shorts Blocker Ultra + Blocking Youtube Shorts GUI On Homepage And Videos
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Blocks YouTube Shorts
// @author       You
// @match        https://www.youtube.com/*
// @grant        none
// @license      All Rights Reserved.
// ==/UserScript==

(function() {
    'use strict';

    let lastValidUrl = window.location.href;
    let isRedirecting = false;


    setInterval(function() {
        const currentUrl = window.location.href;


        if (!currentUrl.includes('/shorts/')) {
            lastValidUrl = currentUrl;
        } else if (!isRedirecting) {

            isRedirecting = true;


            let userResponse = confirm("This video is a YouTube Shorts. To view it as a regular video, click OK. If you click Cancel, you will be redirected to the previous URL.");


            if (userResponse) {
                window.location.href = currentUrl.replace('/shorts/', '/watch?v=');
            } else {

                if (lastValidUrl.includes('youtube.com/shorts')) {
                    window.location.href = 'https://www.youtube.com';
                } else {
                    window.location.href = lastValidUrl;
                }
            }


            setTimeout(function() {
                isRedirecting = false;
            }, 5000);
        }
    }, 1);
})();

(function () {
    'use strict';

    setInterval(function () {
        const elementsToRemove = document.querySelectorAll(
            '.yt-core-image.shortsLockupViewModelHostThumbnail.yt-core-image--fill-parent-height.yt-core-image--fill-parent-width.yt-core-image--content-mode-scale-aspect-fill.yt-core-image--loaded,' +
            '.shortsLockupViewModelHostThumbnailContainer.shortsLockupViewModelHostThumbnailContainerRounded.shortsLockupViewModelHostThumbnailContainerCustomDimensions,' +
            '.shortsLockupViewModelHostThumbnailContainer.shortsLockupViewModelHostThumbnailContainerAspectRatioTwoByThree.shortsLockupViewModelHostThumbnailContainerRounded.shortsLockupViewModelHostThumbnailContainerCustomDimensions,' +
            '.shortsLockupViewModelHostOutsideMetadata.shortLockupViewModelHostMetadataRounded.image-overlay-text,' +
            'ytd-rich-section-renderer.style-scope.ytd-rich-grid-renderer,' +
            'a.shortsLockupViewModelHostEndpoint.shortsLockupViewModelHostOutsideMetadataEndpoint,' +
            'ytm-shorts-lockup-view-model-v2.shortsLockupViewModelHost.yt-horizontal-list-renderer,' +
            'ytm-shorts-lockup-view-model.shortsLockupViewModelHost.yt-horizontal-list-renderer,' +
            '#title-container.style-scope.ytd-reel-shelf-renderer'
        );

        
        elementsToRemove.forEach(function (element) {
            element.remove();
        });
    }, 1);
})();

QingJ © 2025

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