YouTube Shorts zu normaler URL Konverter

Konvertiert YouTube Shorts URLs automatisch zu regulären YouTube URLs

  1. // ==UserScript==
  2. // @name YouTube Shorts zu normaler URL Konverter
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Konvertiert YouTube Shorts URLs automatisch zu regulären YouTube URLs
  6. // @author You
  7. // @match *://*.youtube.com/*
  8. // @match https://youtube.com/*
  9. // @match https://www.youtube.com/*
  10. // @grant none
  11. // @run-at document-start
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. function convertUrl() {
  19. const currentUrl = window.location.href;
  20. if (currentUrl.includes('/shorts/')) {
  21. const videoId = currentUrl.split('/shorts/')[1].split('?')[0];
  22. const newUrl = `https://www.youtube.com/watch?v=${videoId}`;
  23. window.location.replace(newUrl);
  24. }
  25. }
  26.  
  27. convertUrl();
  28.  
  29. let lastUrl = location.href;
  30. new MutationObserver(() => {
  31. const url = location.href;
  32. if (url !== lastUrl) {
  33. lastUrl = url;
  34. convertUrl();
  35. }
  36. }).observe(document, {subtree: true, childList: true});
  37. })();