您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
By default, clicking on a channel while browsing Youtube loads the "Home" tab. This loads the "Videos" tab instead.
// ==UserScript== // @name Youtube channels open to "Videos" tab // @description By default, clicking on a channel while browsing Youtube loads the "Home" tab. This loads the "Videos" tab instead. // @version 0.7 // @namespace BawdyInkSlinger // @author BawdyInkSlinger // @match https://www.youtube.com/* // @exclude https://www.youtube.com/embed* // @run-at document-start // @license MIT License // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_setValue // @grant GM_getValue // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // ==/UserScript== // original version: https://gf.qytechs.cn/en/discussions/requests/56798-request-make-videoes-the-default-tab-on-youtube-channels#comment-455176 (async () => { let storage = undefined; initializeStorage(); createDebugMenu(); const channelHomeRegex = /^(https?:\/\/www\.youtube\.com)((\/(user|channel|c)\/[^/]+)|(\/@(?!.*\/)[^/]+))(\/?$|\/featured[^/])/; const startedOnChannel = channelHomeRegex.test(location.href); debug(`startedOnChannel=${startedOnChannel}`); if (startedOnChannel) { // this will get invoked when a youtube channel link is reached from a non-youtube origin page, // redirecting the link to /videos location.href = RegExp.$2 + "/videos"; // BIS: I think there's a bug here but I've yet to prove it: If you navigate to another part of youtube, will // the script work due to this early return? return; } addEventListener('mousedown', event => { const anchorTag = event.target.closest('a'); const anchorGoesToChannel = anchorTag && channelHomeRegex.test(anchorTag.href); debug(`anchorGoesToChannel`, anchorGoesToChannel, `anchorTag.href`, anchorTag?.href, ); debug(`anchorTag before modification:`, anchorTag, `anchorTag.data before modification:`, anchorTag?.data); if (anchorGoesToChannel) { event.stopPropagation(); const channelName = RegExp.$2; debug(`channelName`, channelName); location.href = channelName + "/videos"; } }); function initializeStorage() { storage = { get debugMode() { return GM_getValue("debugMode", false); }, set debugMode(value) { GM_setValue("debugMode", value); log(`debugMode ${value ? "Enabled" : "Disabled"}`); } } log(`debugMode ${storage.debugMode ? "Enabled" : "Disabled"}`); } function createDebugMenu() { let debugMenuId = undefined; (function toggleMenu() { debugMenuId = GM_registerMenuCommand(`${storage.debugMode ? "Disable" : "Enable"} Debug Mode`, function(event) { storage.debugMode = !storage.debugMode; toggleMenu(); }, { id: debugMenuId, title: `Debug Mode is ${storage.debugMode ? "Enabled" : "Disabled"}`, }); })(); } function debug(...args) { if (storage.debugMode) { console.log(`Youtube channels open to "Videos" tab:`, ...args); } } function log(...args) { console.log(`Youtube channels open to "Videos" tab:`, ...args); } function error(...args) { console.error(`Youtube channels open to "Videos" tab:`, ...args); } })().catch((err) => { console.error(`Youtube channels open to "Videos" tab`, err); });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址