YouTube Jump to Channel Videos

Redirect links in the subscription list to videos tab instead of the home tab (only works for open in new tab/window)

当前为 2020-08-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube Jump to Channel Videos
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Redirect links in the subscription list to videos tab instead of the home tab (only works for open in new tab/window)
// @author       Nathaniel Wu
// @include      *www.youtube.com/*
// @license      Apache-2.0
// @supportURL   https://gist.github.com/Nathaniel-Wu/b9cbdc29b2b33c7d49993ef70d7993d7
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function redirect_channel_links(subscriptions) {
        subscriptions.querySelectorAll('ytd-guide-entry-renderer').forEach(channel => {
            var link = channel.getElementsByTagName("a")[0];
            if (link.href.substring(link.href.length - 7) != "/videos")
                link.href += "/videos";
        });
    }
    function set_listeners() {
        var subscriptions = document.evaluate('//div[@id="content"]/app-drawer[@id="guide"]//div[@id="sections"]/ytd-guide-section-renderer[2]/div[@id="items"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;//subject to change
        if (subscriptions == null)
            return false;
        redirect_channel_links(subscriptions);
        var active_DOMNodeInsertion = 0;
        subscriptions.addEventListener("DOMNodeInserted", () => {
            active_DOMNodeInsertion++;
            setTimeout(() => {
                active_DOMNodeInsertion--;
                if (active_DOMNodeInsertion == 0)
                    redirect_channel_links(subscriptions);
            }, 20);
        });
        return true;
    }
    function repeat_until_successful(function_ptr, interval) {
        if (!function_ptr())
            setTimeout(() => {
                repeat_until_successful(function_ptr, interval);
            }, interval);
    }
    window.addEventListener("load", () => { repeat_until_successful(set_listeners, 100); });
})();