Skip to content

Instantly share code, notes, and snippets.

@belst
Last active September 24, 2023 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belst/f365e09bdc8242ed073f1b3eb7939c59 to your computer and use it in GitHub Desktop.
Save belst/f365e09bdc8242ed073f1b3eb7939c59 to your computer and use it in GitHub Desktop.
// ==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