Removes YesWare email trackers from links in GMail

This script removes the YesWare email trackers from links received in GMail. This means the sender will not know that you have clicked on their links if they use this tracking system.

09.05.2021 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Removes YesWare email trackers from links in GMail
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  This script removes the YesWare email trackers from links received in GMail. This means the sender will not know that you have clicked on their links if they use this tracking system.
// @match        https://mail.google.com/*
// @icon         https://www.google.com/s2/favicons?domain=google.com
// @grant        none
// ==/UserScript==

/**
 * YesWare tracking links look like this:
 * http://t.yesware.com/tt/d9fbcc52aa217aeec95457ead96daaee0c23b5ca/df6ccb12940ec0d69ac63a5be14e018a/a22c14da6fbc87418a7a2303a74e0ca3/realdomain.tld/some/page
 *
 * This script replaces the above ^ with https://realdomain.tld/some/page, which is found at the end.
 */

(function() {
    'use strict';

    const debug = true; // change to true to log the links found and updated

    const hrefRegex = /http(?:s)?:\/\/[a-z]+\.yesware\.com\/tt\/(?:[0-9a-f]+\/){3}(.+)$/;
    function isYesWareLink(anchor) {
        return hrefRegex.exec(anchor.href.toString()) !== null;
    }

    setInterval(function() {
        // search for YesWare-tracked links using XPath
        var xpathResult = document.evaluate("//a[contains(@href,'.yesware.com')]", document, null, XPathResult.ANY_TYPE, null);
        if (xpathResult) {
            var anchor = null;
            while ((anchor = xpathResult.iterateNext()) !== null) { // go over all the matching links
                if (isYesWareLink(anchor)) {
                    if (anchor.getAttribute('data-saferedirecturl')) { // remove GMail's own redirect
                        anchor.removeAttribute('data-saferedirecturl');
                    }
                    var match = hrefRegex.exec(anchor.href.toString()); // match the exact tracking link format, and extract the real target
                    anchor.href = 'https://' + match[1]; // rewrite the link target
                    anchor.onclick = function(){}; // disable any JavaScript interceptors that GMail may add
                    anchor.click = function(){};

                    debug && console.log('Removed YesWare tracker, now pointing to', anchor.href); // if enabled, log to the console to list all changes made
                }
            }
        }
    }, 200); // repeat as more content is loaded
})();