// ==UserScript== // @name Automatic channel tab switch // @namespace http://tampermonkey.net/ // @version 0.5 // @description Switches automatically to the videos tab if a channel or user page is requested // @author Jason Schilling // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js // @downloadURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js // @match https://www.youtube.com/* // @run-at document-end // @grant none // ==/UserScript== (function() { 'use strict'; function notEmptyFilter(item){ return item.length; } console.info("Automatic tab switch loaded!"); document.addEventListener('yt-navigate-start', function(event){ execute(event.detail.url); return false; }); function execute(url){ const parts = url.split('/').filter(notEmptyFilter); if(parts.length === 2 && (parts[0] === 'user' || parts[0] === 'channel')){ const target = location.href + '/videos'; location.href = target location.replace(target); } } execute(location.pathname); })();