Skip to content

Instantly share code, notes, and snippets.

@digiwombat
Last active March 24, 2023 22:25
Show Gist options
  • Save digiwombat/1d3a7b2b38ab6cd198b8714458550215 to your computer and use it in GitHub Desktop.
Save digiwombat/1d3a7b2b38ab6cd198b8714458550215 to your computer and use it in GitHub Desktop.
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.5
// @match *://www.youtube.com/*
// @run-at document-end
// @grant none
// @license MIT
// @updateURL https://gist.github.com/digiwombat/1d3a7b2b38ab6cd198b8714458550215/raw/YouTubeSubscriptionRedirect.user.js
// ==/UserScript==
// Adapted from: https://openuserjs.org/meta/rctdude2/YouTube_Subscription_Redirect.meta.js
(function () {
"use strict";
const location = window.location,
rePathname = /^\/(?:artist|channel|show|user|c)\/[A-Za-z0-9_-]*\/?$/,
reAtname = /^\/(?:@[^\/]+)$/,
reSearch = /^\?(?:annotation_id|app|feature|noredirect|reload|tab)(?:=.*)?$/;
function main() {
if (location.search || location.hash) {
if (reSearch.test(location.search)) location.search = "";
if (location.search === "") main();
}
else {
if (location.pathname === "/") location.replace("feed/subscriptions");
if (rePathname.test(location.pathname)) location.replace(location + "/videos");
if (reAtname.test(location.pathname)) location.replace(location + "/videos");
}
}
// Listen for yt-navigate-start events and re-run the script when it fires
window.addEventListener("yt-navigate-start", main);
// We also have to run the script at least once
main();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment