From 2bd336f546c925a13574630a6a1aff89129715d5 Mon Sep 17 00:00:00 2001 From: marsn3 Date: Sun, 24 Dec 2023 17:07:59 +0000 Subject: [PATCH] Add src/ytshorts.user.js --- src/ytshorts.user.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/ytshorts.user.js diff --git a/src/ytshorts.user.js b/src/ytshorts.user.js new file mode 100644 index 0000000..68dc494 --- /dev/null +++ b/src/ytshorts.user.js @@ -0,0 +1,35 @@ +// ==UserScript== +// @name Youtube shorts redirect +// @namespace http://tampermonkey.net/ +// @version 0.3 +// @description Youtuebe shorts > watch redirect +// @author Fuim +// @match *://*.youtube.com/* +// @icon https://www.google.com/s2/favicons?domain=youtube.com +// @grant none +// @run-at document-start +// @license GNU GPLv2 +// ==/UserScript== +var oldHref = document.location.href; +if (window.location.href.indexOf('youtube.com/shorts') > -1) { + window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); +} +window.onload = function() { + var bodyList = document.querySelector("body") + var observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (oldHref != document.location.href) { + oldHref = document.location.href; + console.log('location changed!'); + if (window.location.href.indexOf('youtube.com/shorts') > -1) { + window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); + } + } + }); + }); + var config = { + childList: true, + subtree: true + }; + observer.observe(bodyList, config); +}; \ No newline at end of file