mail.ru: clean links

Dereferences mail.ru links in emails when clicked.

24.08.2014 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        mail.ru: clean links
// @namespace   lainscripts_mailru_clean_links
// @description Dereferences mail.ru links in emails when clicked.
// @author      lainverse
// @license     CC BY-SA
// @version     1.1
// @include     https://e.mail.ru/message/*
// @grant       none
// ==/UserScript==

let clb = /^http:\/\/r\.mail\.ru\/clb[0-9]+\/(.*)/i,
    cgi = /^http:\/\/e\.mail\.ru\/cgi-bin\/link\?.*&(amp;)?url=([^&]*)/i; //http:\/\/r\.mail\.ru\/clb[0-9]+\/(.*)/i,
    clearLink = function() {
      for (let x in this)
        if (x.indexOf('__originUrl') > -1) {
          let res = cgi.exec(this[x]);
          if (res) this[x] = decodeURIComponent(res[2]);
          res = clb.exec(this[x]);
          if (res) this[x] = 'http://' + res[1];
          this.href = this[x];
        }
    },
    task = function () {
      let links = document.querySelectorAll('A[href^="http://r.mail.ru/clb"]:not(.fixed),A[href^="http://e.mail.ru/cgi-bin/link?"]:not(.fixed)');
      if (links.length > 0)
        for (let l of links) {
          l.classList.add("fixed");
          l.onclick = clearLink;
          console.log(l);
        }
    };

(function link_monitor() { task(); setTimeout(link_monitor, 100); })();