// ==UserScript== // @name YT redirect to Invidious on login request // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description Redirects youtube links to invidious instances if youtube requires you to login for geo-blocking or age restriction // @author Xynoth // @match https://www.youtube.com/watch?* // @grant none // @downloadURL none // ==/UserScript== (function() { // Edit your invidious instance here var invidiousInstance = "https://invidio.us"; // Other variables var currentLocation = window.location.href; var newLocation = currentLocation.replace("https://www.youtube.com/watch?", invidiousInstance + "/watch?"); var loginWarning; var timedLoop = 0; // "Must login" warning container var checkExist = setInterval(function() { loginWarning = document.querySelector(".ytp-error[role='alert']"); if (loginWarning) { window.location.href = newLocation; clearInterval(checkExist); } else if (timedLoop >= 5) { clearInterval(checkExist); } timedLoop += 1; }, 1000); })();