facebook tracker kicker

removing all the ugly onclick redirection stuff

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        facebook tracker kicker
// @namespace   facebook url onclick redirection tracker
// @description removing all the ugly onclick redirection stuff
// @include     https://www.facebook.com/
// @version     4
// @grant       GM_xmlhttpRequest
// ==/UserScript==

(function (window) {
    var document = window.document;
    var OneTimeTrigger = function (func, delay) {
        var timerCountdown = 0;
        return function() {
            setTimeout(function() {
                timerCountdown -= 1;
                if (timerCountdown == 0) {
                    func();
                }
            }, delay);
            timerCountdown += 1;
        };
    };
    var cleanAllLink = function () {
        var cleanedUrl;
        Array.prototype.forEach.call(document.querySelectorAll("a:not(.url-checked)"),
            function (node) {
                if (node.getAttribute("onclick") !== null && (node.getAttribute("onclick").substring(0,8) === "Linkshim")) {
                    node.setAttribute("onclick", null);
                    // node.setAttribute("onmouseover", null);
                    console.log("1 CLEANED")
                    }
                node.className += " url-checked";
            });
    };
    var trigger = OneTimeTrigger(cleanAllLink, 100);
    var MutationObserver = window.MutationObserver ? window.MutationObserver : window.WebKitMutationObserver;
    if (typeof MutationObserver !== "undefined") {
        var observer = new MutationObserver(trigger);
        observer.observe(document, { childList: true, subtree: true });
    }
    else {
        document.addEventListener("DOMNodeInserted", trigger, false);
        document.addEventListener("DOMSubtreeModified", trigger, false);
    }

})(window);