// ==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 2.1 // @include https://e.mail.ru/* // @grant none // @downloadURL none // ==/UserScript== let clb = /^https?:\/\/r\.mail\.ru\/cl[a-z][0-9]+\/(.*)/i, cgi = /&(amp;)?url=([^&]*)/i, clearLink = function() { for (let x in this) if (x.indexOf('__originUrl') > -1) { let res = null; do { res = cgi.exec(this[x]); if (res) this[x] = decodeURIComponent(res[2]); } while (res); res = clb.exec(this[x]); if (res) this[x] = 'http://' + res[1]; this.href = this[x]; console.log("Dereferenced link:", this[x]); } }, task = function () { let links = document.querySelectorAll('#b-letter A:not(.fixed)'); if (links.length > 0) for (let l of links) { l.classList.add("fixed"); l.onclick = clearLink; } }; (function link_monitor() { task(); setTimeout(link_monitor, 100); })();