您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically redirects from a YouTube channel's home page to its videos section
// ==UserScript== // @name YouTube Channel Auto-Redirect to Videos Section // @namespace http://tampermonkey.net/ // @version 1.2 // @description Automatically redirects from a YouTube channel's home page to its videos section // @author Claude // @match https://www.youtube.com/* // @grant none // @license MIT // @run-at document-start // ==/UserScript== (function() { 'use strict'; // Function to redirect to the videos section function redirectToVideos(url) { // Check if URL matches a channel's home page pattern const isChannelUrl = /youtube\.com\/((@[^\/]+)|channel\/|c\/)[^\/]*$/.test(url); // If we're on a channel's home page, redirect to videos section if (isChannelUrl) { const newUrl = url + (url.endsWith('/') ? 'videos' : '/videos'); window.location.replace(newUrl); return true; } return false; } // Check initial URL redirectToVideos(window.location.href); // Monitor URL changes using History API const originalPushState = history.pushState; const originalReplaceState = history.replaceState; // Override pushState method history.pushState = function() { const result = originalPushState.apply(this, arguments); redirectToVideos(window.location.href); return result; }; // Override replaceState method history.replaceState = function() { const result = originalReplaceState.apply(this, arguments); redirectToVideos(window.location.href); return result; }; // Additional listener for popstate events (back/forward navigation) window.addEventListener('popstate', function() { redirectToVideos(window.location.href); }); // Additional function to check URL periodically function checkUrlPeriodically() { redirectToVideos(window.location.href); setTimeout(checkUrlPeriodically, 1000); // Check every 1 second } // Start periodic checking setTimeout(checkUrlPeriodically, 1000); })();