rctdude2 / YouTube Subscription Redirect

// ==UserScript==
// @name		YouTube Subscription Redirect
// @description	Automatically load the videos you actually care about
// @namespace	B492B7DC-4C33-4E72-8316-49A425788F86
// @version		2.0.8
// @match		*://www.youtube.com/*
// @grant		none
// ==/UserScript==

(function () {
	"use strict";

	var loc = window.location,
		rePathname = /^\/(?:artist|channel|show|user)\/[A-Za-z0-9_-]*\/?$/,
		reSearch = /^\?(?:annotation_id|app|feature|noredirect|tab)(?:=.*)?$/;

	function main() {
		if (loc.search || loc.hash) {
			if (reSearch.test(loc.search)) loc.search = "";
			if (loc.search === "") main();
		}
		else {
			if (loc.pathname === "/") loc.replace("feed/subscriptions");
			if (rePathname.test(loc.pathname)) loc.replace(loc + "/videos");
		}
		var homelink = document.querySelector("#guide-container .guide-user-links a[title='Home']");
		if (homelink === null) {
			homelink = document.querySelector("#sections #endpoint");
		}
		homelink.href += "?bypass-ytsr=true";
	}

	// Listen for spfdone events and re-run the script when it fires
	window.addEventListener("spfdone", main);
	// We also have to run the script at least once
	main();
}());