YT - Other UI Tweaks + both Shorts and AI removal included

This is the script that tweaks other UI elements (that also includes removal of 'Shorts' and 'AI nonsense', along with reverting the 'Subscriptions' tab that used to appear from the top)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         YT - Other UI Tweaks + both Shorts and AI removal included
// @version      2025.11.27
// @description  This is the script that tweaks other UI elements (that also includes removal of 'Shorts' and 'AI nonsense', along with reverting the 'Subscriptions' tab that used to appear from the top)
// @author       Joey_JTS
// @license MIT
// @match        *://www.youtube.com/*
// @match        *://m.youtube.com/*
// @match        *://www.youtube-nocookie.com/*
// @exclude      *://www.youtube.com/live_chat*
// @namespace    https://greasyfork.org/en/users/761382
// @icon         https://www.youtube.com/favicon.ico
// @unwrap
// @run-at       document-idle
// @unwrap
// @grant        none
// ==/UserScript==


// Apply (most) of the CSS tweaks
(function() {
let css = `
/* Hide all shorts, irrelevant search results and AI crap */
.ytGridShelfViewModelHost, .ytd-search ytd-shelf-renderer, [page-subtype='home'] ytd-reel-shelf-renderer, [page-subtype='home'] ytd-rich-section-renderer, [page-subtype='subscriptions'] ytd-reel-shelf-renderer, [page-subtype='subscriptions'] ytd-rich-section-renderer, ytd-watch-flexy ytd-reel-shelf-renderer, ytd-watch-flexy ytd-rich-section-renderer, #related ytd-compact-video-renderer:has(a[href^="/shorts"]), ytm-rich-shelf-renderer, ytm-search ytm-shelf-renderer, ytm-reel-shelf-renderer, ytm-rich-section-renderer, ytm-pivot-bar-item-renderer:has(> .pivot-shorts) { display: none !important }
.style-scope[page-subtype='channels'] ytd-shelf-renderer, .style-scope[page-subtype='channels'] ytm-shelf-renderer { display: block !important }
[is-search] ytd-shelf-renderer.ytd-item-section-renderer:not(ytd-channel-renderer + ytd-shelf-renderer), [is-search] ytd-horizontal-card-list-renderer.ytd-item-section-renderer:not(:first-child), [is-search] ytd-exploratory-results-renderer.ytd-item-section-renderer { display: none !important }
#expandable-metadata.ytd-video-renderer, #expandable-metadata.ytd-watch-flexy { display: none !important }
ytd-expandable-metadata-renderer[has-video-summary] { display: none !important }
/* #flexible-item-buttons button[aria-label^="Ask" i], ytd-menu-renderer button[aria-label^="Ask" i] { display: none !important } */

/* Disable giant thumbnails on search results */
ytd-two-column-search-results-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] #primary.ytd-two-column-search-results-renderer, ytd-search[has-search-header][has-bigger-thumbs] #header.ytd-search { max-width: 1096px !important }
ytd-channel-renderer[use-bigger-thumbs][bigger-thumb-style=BIG] #avatar-section.ytd-channel-renderer, ytd-channel-renderer[use-bigger-thumbs] #avatar-section.ytd-channel-renderer, ytd-video-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] ytd-thumbnail.ytd-video-renderer, ytd-video-renderer[use-search-ui] ytd-thumbnail.ytd-video-renderer, ytd-playlist-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] ytd-playlist-thumbnail.ytd-playlist-renderer, ytd-playlist-renderer[use-bigger-thumbs] ytd-playlist-thumbnail.ytd-playlist-renderer, ytd-radio-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] ytd-thumbnail.ytd-radio-renderer, ytd-radio-renderer[use-bigger-thumbs] ytd-thumbnail.ytd-radio-renderer, ytd-radio-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] ytd-thumbnail.ytd-radio-renderer, ytd-radio-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] ytd-playlist-thumbnail.ytd-radio-renderer, ytd-movie-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] .thumbnail-container.ytd-movie-renderer, ytd-movie-renderer[use-bigger-thumbs] .thumbnail-container.ytd-movie-renderer, ytd-promoted-video-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] ytd-thumbnail.ytd-promoted-video-renderer, ytd-promoted-sparkles-web-renderer[web-search-layout][use-bigger-thumbs][bigger-thumbs-style=BIG] #thumbnail-container.ytd-promoted-sparkles-web-renderer, ytd-text-image-no-button-layout-renderer[use-bigger-thumbs][bigger-thumbs-style=BIG] #text-image-container.ytd-text-image-no-button-layout-renderer, .yt-lockup-view-model-wiz--horizontal .yt-lockup-view-model-wiz__content-image, .yt-lockup-view-model--horizontal .yt-lockup-view-model__content-image { max-width: 360px !important }

/* Disable big player mode controls in theater mode (pre-delhi player changes only) */
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chrome-bottom { height: 48px !important; padding-top: 3px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chrome-controls { height: 48px !important; line-height: 48px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chrome-controls .ytp-button { width: 48px !important; height: 48px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chrome-controls .ytp-play-button { width: 46px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-volume-slider-active .ytp-volume-panel { width: 52px !important; margin-right: 3px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-volume-slider { min-height: 36px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-volume-slider-handle { width: 12px !important; height: 12px !important; border-radius: 6px !important; margin-top: -6px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-time-display { font-size: 1.3rem !important; line-height: 47px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chapter-title.ytp-button { width: auto !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chapter-title-content { font-size: 1.3rem !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-autonav-toggle-button { height: 14.4px !important; width: 36px !important; border-radius: 14.4px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-autonav-toggle-button::after { height: 20.4px !important; width: 20.4px !important; border-radius: 20.4px !important; margin-top: -3px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-autonav-toggle-button[aria-checked=true]::after { -ms-transform: translateX(15.6px) !important; transform: translateX(15.6px) !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chrome-controls .ytp-button[aria-pressed=true]::after { width: 24px !important; left: 12px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-chrome-controls .ytp-button[aria-pressed]::after { height: 3px !important; border-radius: 3px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-progress-bar-container { bottom: 47px !important; height: 5px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-progress-bar-container:hover { bottom: 45.5px !important; height: 8px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-scrubber-container { top: -4px !important; left: -6.5px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-progress-bar-container:hover .ytp-scrubber-container { top: -2.5px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-scrubber-button { height: 13px !important; width: 13px !important; border-radius: 6.5px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-progress-bar-padding { height: 16px !important; }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-touch-mode):not(.ytp-delhi-modern) .ytp-chapter-hover-container:hover:not([aria-disabled=true]) .ytp-progress-bar-padding { height: 22px !important; bottom: -6px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-progress-list { transform: scaleY(.6) !important; transition: transform .1s cubic-bezier(.4,0,1,1),-webkit-transform .1s cubic-bezier(.4,0,1,1) !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-progress-bar-container:hover .ytp-timed-markers-container { -ms-transform: scaleY(1.8) !important; transform: scaleY(1.8) !important; transition: transform .1s cubic-bezier(0,0,.2,1),-webkit-transform .1s cubic-bezier(0,0,.2,1) !important; top: -2px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-clip-start, ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-clip-end { width: 14px !important; height: 14px !important; bottom: -4.5px !important; margin-left: -7px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-settings-menu { bottom: 61px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem:not(.ytp-menuitem-with-footer), ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-panel-header { height: 40px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-settings-menu .ytp-menuitem-icon { padding: 0 10px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-settings-menu .ytp-menuitem-content { padding-right: 15px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem-label { font-size: 13px !important; font-weight: 500 !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-settings-menu .ytp-menuitem>*:last-child { font-size: 12px !important; padding-right: 36px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem-icon svg { display: block !important; width: 24px !important; height: 24px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem-toggle-checkbox { height: 14px !important; width: 36px !important; border-radius: 14px !important; margin-right: -14px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem-toggle-checkbox::after { left: 0 !important; height: 20px !important; width: 20px !important; border-radius: 20px !important; margin-top: -3px !important; margin-left: 0px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem[aria-checked=true] .ytp-menuitem-toggle-checkbox::after { margin-left: -6px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem[aria-haspopup=true] .ytp-menuitem-content { background-repeat: no-repeat !important; background-position: right 9px center !important; background-size: 32px 32px !important; padding-right: 38px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-menuitem[role=menuitemradio][aria-checked=true] .ytp-menuitem-label { background-repeat: no-repeat !important; background-position: left 10px center !important; background-size: 18px 18px !important; }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-panel-title { font-size: 13px !important; padding: 0 !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-panel-footer {font-size: 13px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-panel-options {font-size: 12px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-videowall-still-info-title {font-size: 1.3rem !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-videowall-still-info-author, ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-videowall-still-info-live, ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-videowall-still-info-duration { font-size: 1.1rem !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-cards-button-icon { width: 36px !important; height: 36px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-cards-button-title { font-size: 14px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-cards-teaser .ytp-cards-teaser-box, ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-cards-teaser .ytp-cards-teaser-text { height: 31px !important }
ytd-watch-flexy:not([fullscreen]) .ytp-big-mode:not(.ytp-delhi-modern) .ytp-cards-teaser .ytp-cards-teaser-text { font-size: 1.2rem !important; padding: 0 36px 0 10px !important; line-height: 31px !important }

/* Remove most guide-entry-renderer elements (including small tweaks) */
ytd-guide-entry-renderer[title="Shorts"], .ytd-mini-guide-entry-renderer[href="/shorts/"], ytd-guide-entry-renderer > a[href*="/feed/podcasts"], ytd-guide-section-renderer.ytd-guide-renderer.style-scope:nth-of-type(1) ytd-guide-entry-renderer.ytd-guide-section-renderer.style-scope:nth-of-type(3) {
display: none !important
}`;
if (typeof GM_addStyle !== "undefined") {
  GM_addStyle(css);
} else {
  let styleNode = document.createElement("style");
  styleNode.appendChild(document.createTextNode(css));
  (document.querySelector("head") || document.documentElement).appendChild(styleNode);
}
})();

// Re-add 'Subscriptions' tab from normal sidebar on top
function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }
 
        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                resolve(document.querySelector(selector));
                observer.disconnect();
            }
        });
 
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}
 
    function restoreTrending() {
 
        var trendingData = {
            "navigationEndpoint": {
                "clickTrackingParams": "CBwQtSwYASITCNqYh-qO_fACFcoRrQYdP44D9Q==",
                "commandMetadata": {
                    "webCommandMetadata": {
                        "url": "/feed/subscriptions",
                        "webPageType": "WEB_PAGE_TYPE_BROWSE",
                        "rootVe": 6827,
                        "apiUrl": "/youtubei/v1/browse"
                    }
                },
                "browseEndpoint": {
                    "browseId": "FEtrending"
                }
            },
            "icon": {
                "iconType": "SUBSCRIPTIONS"
            },
            "trackingParams": "CBwQtSwYASITCNqYh-qO_fACFcoRrQYdP44D9Q==",
            "formattedTitle": {
                "simpleText": "Subscriptions"
            },
            "accessibility": {
                "accessibilityData": {
                    "label": "Subscriptions"
                }
            },
            "isPrimary": true
        };
 
        var guidetemplate = `<ytd-guide-entry-renderer class="style-scope ytd-guide-section-renderer" is-primary="" line-end-style="none"><!--css-build:shady--><a id="endpoint" class="yt-simple-endpoint style-scope ytd-guide-entry-renderer" tabindex="-1" role="tablist"><tp-yt-paper-item role="tab" class="style-scope ytd-guide-entry-renderer" tabindex="0" aria-disabled="false"><!--css-build:shady--><yt-icon class="guide-icon style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><yt-img-shadow height="24" width="24" class="style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-img-shadow><yt-formatted-string class="title style-scope ytd-guide-entry-renderer"><!--css-build:shady--></yt-formatted-string><span class="guide-entry-count style-scope ytd-guide-entry-renderer"></span><yt-icon class="guide-entry-badge style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><div id="newness-dot" class="style-scope ytd-guide-entry-renderer"></div></tp-yt-paper-item></a><yt-interaction class="style-scope ytd-guide-entry-renderer"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></ytd-guide-entry-renderer>`;
        document.querySelector(`#items > ytd-guide-entry-renderer:nth-child(2)`).data = trendingData;
 
    }
 
 
waitForElm("#items.ytd-guide-section-renderer").then((elm) => {
    restoreTrending();
});

// Preventing the 'automatic dubbing' feature on videos
/*jshint esversion: 11 */
 
(function () {
    'use strict';
 
    function main(event) {
        try {
            const playingLanguage = event.detail.video.playingLanguage;
            const originalLanguage = event.detail.video.originalLanguage;
            const isAutoDubbed = playingLanguage !== originalLanguage && `${playingLanguage}` !== 'Default';
            if (!isAutoDubbed) return;
            if (!originalLanguage) throw new Error('Unable to determine the original audio track.');
            console.log('Auto-dub detected, trying to undo...');
            window.youtubeHelperApi.player.playerObject.setAudioTrack(originalLanguage);
            console.log(`Auto-dub undo successful. Audio track reverted from ${playingLanguage} to ${originalLanguage}.`);
        } catch (error) {
            console.warn('Failed to prevent YouTube auto-dubbing.', error);
        }
    }
 
    window.youtubeHelperApi.eventTarget.addEventListener('yt-helper-api-ready', main);
})();