Last active
June 9, 2024 20:41
-
-
Save belst/f365e09bdc8242ed073f1b3eb7939c59 to your computer and use it in GitHub Desktop.
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 shorts redirect | |
// @namespace Violentmonkey Scripts | |
// @match *://*.youtube.com/* | |
// @grant none | |
// @version 1.0 | |
// @author belst | |
// @description 9/22/2022, 1:26:47 PM | |
// ==/UserScript== | |
let href = window.location.href; | |
const redirect = () => { | |
if (href.includes('/shorts')) { | |
window.location.replace(href.replace('/shorts/', '/watch?v=')); | |
} | |
} | |
redirect(); | |
window.onload = () => { | |
const observer = new MutationObserver((mutations) => { | |
for (const m of mutations) { | |
if (href !== window.location.href) { | |
href = window.location.href; | |
redirect(); | |
} | |
} | |
}); | |
observer.observe(document.body, {childList: true, subtree: true}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment