Advertisement
bejiitas_wrath

Youtube #shorts redirect.

Sep 25th, 2022
1,393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.29 KB | Cybersecurity | 0 0
  1. // ==UserScript==
  2. // @name         Youtube shorts redirect
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.3
  5. // @description  Youtuebe shorts > watch redirect
  6. // @author       Fuim
  7. // @match        *://*.youtube.com/*
  8. // @icon         https://www.google.com/s2/favicons?domain=youtube.com
  9. // @grant        none
  10. // @run-at       document-start
  11. // @license      GNU GPLv2
  12. // ==/UserScript==
  13. var oldHref = document.location.href;
  14. if (window.location.href.indexOf('youtube.com/shorts') > -1) {
  15.     window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
  16. }
  17. window.onload = function() {
  18.     var bodyList = document.querySelector("body")
  19.     var observer = new MutationObserver(function(mutations) {
  20.         mutations.forEach(function(mutation) {
  21.             if (oldHref != document.location.href) {
  22.                 oldHref = document.location.href;
  23.                 console.log('location changed!');
  24.                 if (window.location.href.indexOf('youtube.com/shorts') > -1) {
  25.                     window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
  26.                 }
  27.             }
  28.         });
  29.     });
  30.     var config = {
  31.         childList: true,
  32.         subtree: true
  33.     };
  34.     observer.observe(bodyList, config);
  35. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement