Last active
May 17, 2023 08:38
-
-
Save lassekongo83/8c025d93da1061c69c13c2040b8ee9da to your computer and use it in GitHub Desktop.
Revisions
-
lassekongo83 revised this gist
May 17, 2023 . 1 changed file with 24 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,37 @@ // ==UserScript== // @name Youtube shorts redirect // @namespace ViolentMonkey Scripts // @version 0.3 // @match *://*.youtube.com/* // @grant none // @run-at document-start // ==/UserScript== (function() { 'use strict'; const replaceShortsLinks = () => { [...document.querySelectorAll('a[href*="/shorts/"]')] .forEach(a => { a.href = a.href.replace(/\/shorts\/(.*)/, '/watch?v=$1') }); }; window.addEventListener("yt-navigate-finish", replaceShortsLinks, true); let oldHref = document.location.href; if (window.location.href.indexOf('youtube.com/shorts') > -1) { window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); } function shortsRedirector() { if (oldHref != document.location.href) { oldHref = document.location.href; if (window.location.href.indexOf('youtube.com/shorts') > -1) { window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); } } } window.addEventListener("yt-navigate-finish", shortsRedirector, true); })(); -
lassekongo83 revised this gist
May 17, 2023 . 1 changed file with 13 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ // ==UserScript== // @name Youtube shorts redirect // @namespace ViolentMonkey Scripts // @version 0.2 // @match *://*.youtube.com/* // @grant none // @run-at document-start // ==/UserScript== let oldHref = document.location.href; if (window.location.href.indexOf('youtube.com/shorts') > -1) { window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); @@ -19,4 +20,14 @@ function shortsRedirector() { } } } window.addEventListener("yt-navigate-finish", shortsRedirector, true); // Replace links as well const replaceShortsLinks = () => { [...document.querySelectorAll('a[href*="/shorts/"]')] .forEach(a => { a.href = a.href.replace(/\/shorts\/(.*)/, '/watch?v=$1') }); }; window.addEventListener("yt-navigate-finish", replaceShortsLinks, true); -
lassekongo83 revised this gist
Jul 5, 2022 . No changes.There are no files selected for viewing
-
lassekongo83 created this gist
May 17, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ // ==UserScript== // @name Youtube shorts redirect // @namespace ViolentMonkey Scripts // @version 0.1 // @match *://*.youtube.com/* // @grant none // @run-at document-start // ==/UserScript== let oldHref = document.location.href; if (window.location.href.indexOf('youtube.com/shorts') > -1) { window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); } function shortsRedirector() { if (oldHref != document.location.href) { oldHref = document.location.href; if (window.location.href.indexOf('youtube.com/shorts') > -1) { window.location.replace(window.location.toString().replace('/shorts/', '/watch?v=')); } } } window.addEventListener("yt-navigate-finish", shortsRedirector, true);