YouTube - Shorts Redirect

YouTube shorts redirect to regular watch page

  1. // ==UserScript==
  2. // @name YouTube - Shorts Redirect
  3. // @namespace q1k
  4. // @version 0.1
  5. // @description YouTube shorts redirect to regular watch page
  6. // @author q1k
  7. // @match *://*.youtube.com/*
  8. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. if (window.location.href.indexOf('youtube.com/shorts/') > -1) {
  13. window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
  14. }
  15.  
  16. var redirecting = false;
  17. var mo = new MutationObserver(function(mutations) {
  18. if (window.location.href.indexOf('youtube.com/shorts/') > -1) {
  19. if(redirecting){ return; }
  20. window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
  21. redirecting = true;
  22. }
  23. });
  24. function watchUrlForChange(e) {
  25. mo.observe(document.body, {
  26. childList: true,
  27. subtree: true,
  28. });
  29. }
  30.  
  31. window.addEventListener('load', watchUrlForChange, true);
  32.