iarp / Remove Reddit URL Click Tracking

// ==UserScript==
// @name Remove Reddit URL Click Tracking
// @description Probably removes Reddit spying on urls clicked
// @match *://*.reddit.com/*
// @run-at document-end
// @license MIT
// ==/UserScript==

(function() {
    "use strict";

    // Store the original href which no longer contains utm_* tracking code in another attribute.
    $.each($('a'), function() {
        var attr = $(this).attr('href');
        if (typeof attr !== typeof undefined && attr !== false) {
            $(this).attr("data-original-href-url", attr);
        }
    });

    // Finally, replace the href back to the original value when clicked on
    $(document).on('click', 'a', function(e) {
        var attr = $(this).attr('data-original-href-url');
        if (typeof attr !== typeof undefined && attr !== false) {
            $(this).attr("href", attr);
        }
    });
})();