NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Redirect YouTube Shorts
// @description Automatically redirect YouTube "shorts" to a normal video page
// @match *://*.youtube.com/*
// @version 0.4.0
// @author cliff_barr: https://openuserjs.org/users/cliff_barr
// @namespace https://openuserjs.org/users/cliff_barr
// @run-at document-start
// @license MIT
// @updateURL https://openuserjs.org/meta/cliff_barr/Redirect_YouTube_Shorts.meta.js
// @downloadURL https://openuserjs.org/install/cliff_barr/Redirect_YouTube_Shorts.user.js
// ==/UserScript==
function redirectYoutubeShorts() {
const videoId = window.location.pathname.match(/^\/shorts\/(.+)/)[1];
if (videoId) {
// quit if a redirect already happened (and the user pressed "back" or something)
const flag = `shortsRedirected ${videoId}`;
if (sessionStorage.getItem(flag) !== null) {
return;
}
// remember redirection in session storage
sessionStorage.setItem(flag, '1');
console.info('Redirected YouTube shorts');
const upgradeUrl = `https://www.youtube.com/watch?v=${videoId}`;
history.pushState({}, upgradeUrl, upgradeUrl);
window.location.assign(upgradeUrl);
}
}
// run script on in-page navigation
document.addEventListener("yt-navigate-start", () => {
redirectYoutubeShorts();
});
redirectYoutubeShorts();