Redirect a YouTube channel home page straight to the videos tab.
< 腳本Redirect YouTube channel to /videos的回應
Hi, thanks for reporting the bug. I avoid YouTube's homepage, so I missed it. I fixed the script by broadening the @match patterns. Try it out :) If you are on GitHub, I'd appreciate it if you could report issues there, so I could get to them faster and give credit :)
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址
It stopped working when clicking on a channel from the homepage, I made a small change and it works for me now
// ==UserScript==
// @name Redirect YouTube channel to /videos
// @namespace https://stojanow.com/
// @match https://*.youtube.com/@*
// @match http://*.youtube.com/@*
// @match https://youtube.com/@*
// @match http://youtube.com/@*
// @run-at document-start
// @grant none
// @version 0.2.0
// @author Piotr Stojanow (https://github.com/psto/)
// @license MIT
// @description Redirect a YouTube channel home page straight to the videos tab.
// @icon https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQoiMtJG_PC4lsb3-GZAiTZkUXAm3VlkJC1Ag&s
// @downloadURL https://update.gf.qytechs.cn/scripts/500460/Redirect%20YouTube%20channel%20to%20videos.user.js
// @updateURL https://update.gf.qytechs.cn/scripts/500460/Redirect%20YouTube%20channel%20to%20videos.meta.js
// ==/UserScript==
(function() {
const excludedPaths = ['/community', '/live', '/playlists', '/search', '/podcasts', '/shorts', '/streams'];
let isRedirecting = false;
function redirectIfNeeded() {
setTimeout(function() {
if (isRedirecting) return; // Prevent multiple redirections
const currentPath = window.location.pathname;
const channelMatch = currentPath.match(/^\/@([^/]+)/);
if (channelMatch) {
const channelName = channelMatch[1];
const shouldRedirect = !excludedPaths.some(path => currentPath.startsWith(`/@${channelName}${path}`));
if (shouldRedirect && (!currentPath.endsWith('/videos') || currentPath.endsWith('/featured'))) {
isRedirecting = true;
const newUrl = `https://www.youtube.com/@${channelName}/videos`;
window.location.href = newUrl;
}
}
}, 0);
}
// Observe changes in the DOM to trigger redirection if needed
const observer = new MutationObserver(redirectIfNeeded);
observer.observe(document, { subtree: true, childList: true });
// Initial check for redirection
redirectIfNeeded();
})();