YouTube Subscriptions Only

Removes Home and Shorts buttons, and redirects to Subscriptions feed

目前為 2025-03-04 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube Subscriptions Only
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Removes Home and Shorts buttons, and redirects to Subscriptions feed
// @author       Sanokei
// @match        https://www.youtube.com/*
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    
    // Function to remove Home and Shorts buttons
    function removeButtons() {
        // Target both mini-guide and regular guide entries
        const selectors = [
            'ytd-mini-guide-entry-renderer', 
            'ytd-guide-entry-renderer'
        ];
        
        selectors.forEach(selector => {
            const entries = document.querySelectorAll(selector);
            entries.forEach(entry => {
                // Check if the entry is Home or Shorts by examining its title
                const title = entry.querySelector('.title');
                if (title && (title.textContent === 'Home' || title.textContent === 'Shorts')) {
                    entry.style.display = 'none';
                }
            });
        });
    }
    
    // Function to redirect to subscriptions if on homepage
    function redirectToSubscriptions() {
        // Only redirect if we're on the homepage (not already on a video or other page)
        if (window.location.pathname === '/' || window.location.pathname === '/watch') {
            window.location.href = '/feed/subscriptions';
        }
    }
    
    // Run the button removal function periodically to catch dynamic content
    setInterval(removeButtons, 1000);
    
    // Run once on initial page load
    removeButtons();
    
    // Redirect if on homepage
    if (window.location.pathname === '/') {
        redirectToSubscriptions();
    }
    
    // Monitor for navigation events within YouTube (for SPA behavior)
    const pushState = history.pushState;
    history.pushState = function() {
        pushState.apply(history, arguments);
        
        // Check if we've navigated to the homepage
        if (window.location.pathname === '/') {
            setTimeout(redirectToSubscriptions, 100);
        }
        
        // Remove buttons after navigation
        setTimeout(removeButtons, 500);
    };
})();