Skip to content

Instantly share code, notes, and snippets.

@Airbus-A330
Created August 12, 2022 20:01
Show Gist options
  • Save Airbus-A330/b6849fd9fe842d008bd9bc32b3f4a63d to your computer and use it in GitHub Desktop.
Save Airbus-A330/b6849fd9fe842d008bd9bc32b3f4a63d to your computer and use it in GitHub Desktop.
Tired of YouTube shorts? This will transform any YouTube short into a normal video. Paste this in Tampermonkey/Greasemonkey.
// ==UserScript==
// @name Anti-Shorts
// @namespace http://tampermonkey.net/
// @version 0.0.1
// @description Tired of YouTube shorts? We are too! Transform any YouTube short into a normal video.
// @author Airbus-A330
// @match *.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// CREDIT: https://phpcoder.tech/detect-url-change-in-javascript-without-refresh/
let lastURL = location.href;
new MutationObserver(() => {
const url = location.href;
if (url !== lastURL) {
lastURL = url;
disableShorts();
}
}).observe(document, {
subtree: true,
childList: true
});
function disableShorts() {
if (location.href.includes("shorts")) {
window.location.href = location.href.replace("/shorts/", "/watch?v=");
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment