Greasy Fork is available in English.

mail.ru: clean links

Dereferences mail.ru links in emails when clicked.

Verze ze dne 24. 08. 2014. Zobrazit nejnovější verzi.

// ==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); })();