YouTube link redirect remover

replaces the url from youtube.com/redirect links to the actual target

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name           YouTube link redirect remover
// @name:de        YouTube Link redirect Entferner
// @description    replaces the url from youtube.com/redirect links to the actual target
// @description:de Ersetzt die URL von youtube.com/redirect links zur wirklichen Zieladresse
// @version        0.2
// @match          https://www.youtube.com/*
// @grant          none
// @namespace      https://greatest.deepsurf.us/users/94906
// @license        WTFPL
// ==/UserScript==

(function() {
  'use strict';
  console.log("YT LINK REDIRECT REMOVER LOADED");
  //console.log("Language:" + document.getElementsByTagName("html")[0].getAttribute("lang"));
  function editAnchorTag() {
    for (var i = 0; i < document.links.length; i++) {
      if (document.links[i].href.indexOf('youtube.com/redirect') < 0)
        continue;
      var urlParams = new URLSearchParams(document.links[i].href);

      if(urlParams.get('q') != null){
        document.links[i].href = urlParams.get('q');
      }
      console.log(document.links[i].href);
    }
  }
  editAnchorTag();
  //document.addEventListener('click', editAnchorTag);
  //document.addEventListener('yt-page-data-updated', editAnchorTag);
  document.addEventListener('yt-navigate-finish', editAnchorTag);
  setInterval(editAnchorTag, 500);
})();