Last active
March 13, 2024 07:37
-
-
Save lbmaian/c53f48e04a3303d059c042f779a82604 to your computer and use it in GitHub Desktop.
YouTube - Redirect Shorts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube - Redirect Shorts | |
// @namespace https://gist.github.com/lbmaian/c53f48e04a3303d059c042f779a82604 | |
// @downloadURL https://gist.github.com/lbmaian/c53f48e04a3303d059c042f779a82604/raw/youtube-redirect-shorts.user.js | |
// @updateURL https://gist.github.com/lbmaian/c53f48e04a3303d059c042f779a82604/raw/youtube-redirect-shorts.user.js | |
// @version 0.2.2 | |
// @description Redirects YouTube shorts URL to watch URL | |
// @author lbmaian | |
// @match https://*.youtube.com/* | |
// @grant window.onurlchange | |
// @icon https://www.youtube.com/favicon.ico | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function onurlchange() { | |
if (window.location.pathname.startsWith('/shorts/')) { | |
const href = window.location.href; | |
const newHref = href.replace('/shorts/', '/watch?v='); | |
console.log("Redirecting %s to %s", href, newHref); | |
window.location.replace(newHref); | |
} | |
} | |
if (window.onurlchange === null) { // if onurlchange supported | |
window.addEventListener('urlchange', onurlchange); | |
} else { | |
window.setInterval(onurlchange, 500); | |
} | |
onurlchange(); | |
})(); |
0.2: Updated to work on m.youtube.com as well
0.2.2: Add update URL and rename to "Redirect shorts" - this may require a uninstall+reinstall
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If using the Enhancer for YouTube extension, this is userscript is no longer useful with that extension's new "Convert Shorts" option