Reddit Remove Spy Linking

Remove Spy Linking on Reddit.com

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        Reddit Remove Spy Linking
// @namespace   http://reddit.co.uk
// @description Remove Spy Linking on Reddit.com
// @include     https://*.reddit.com/*
// @include     https://reddit.com/*
// @include     http://reddit.com/*
// @include     http://*.reddit.com/*
// @version     1.0.1
// @grant       none
// ==/UserScript==

var a = document.getElementsByTagName("a");
for (var x=1; x<a.length; x++) {
  a[x].removeAttribute("data-outbound-url");
  a[x].removeAttribute("data-href-url");
  a[x].removeAttribute("data-outbound-expiration");
  a[x].removeAttribute("data-event-action");
  a[x].removeAttribute("rel");
  if (a[x].className.indexOf("comments")!=-1) {
    var nid = a[x].parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("data-fullname").split("_")[1];
    var sbr = a[x].parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("data-subreddit");
    var tid = a[x].parentNode.parentNode.parentNode.getElementsByTagName("p")[0].getElementsByTagName("a")[0].textContent.toLowerCase();
    tid = tid.replace(/\s+/g, "_");
    tid = tid.replace(/[^a-zA-z0-9]/g, "");
    tid = tid.replace(/__/g, "_");
    if (tid.length > 50) {
      tid=tid.substr(0,50);
      while (tid.length>=1 && tid.charAt(tid.length-1)!="_") {
        tid = tid.substr(0, tid.length-1)
      }
     tid = tid.substr(0, tid.length-1)
    }
    newstr = "https://www.reddit.com/" + "r/"+ sbr + "/comments/" + nid + "/" + tid;
    a[x].setAttribute("href", newstr);
  }
  a[x].removeAttribute("data-inbound-url");
}