mail.ru: clean links

Dereferences mail.ru links in emails when clicked.

目前為 2014-08-24 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name mail.ru: clean links
  3. // @namespace lainscripts_mailru_clean_links
  4. // @description Dereferences mail.ru links in emails when clicked.
  5. // @author lainverse
  6. // @license CC BY-SA
  7. // @version 3.0
  8. // @include https://e.mail.ru/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. let clb = /^https?:\/\/r\.mail\.ru\/cl[a-z][0-9]+\/(.*)/i,
  13. cgi = /&(amp;)?url=([^&]*)/i,
  14. lastLink = null,
  15. clearLink = function() {
  16. for (let x in this)
  17. if (x.indexOf('__originUrl') > -1) {
  18. let res = null;
  19. do {
  20. res = cgi.exec(this[x]);
  21. if (res) this[x] = decodeURIComponent(res[2]);
  22. } while (res);
  23. res = clb.exec(this[x]);
  24. if (res) this[x] = 'http://' + res[1];
  25. this.href = this[x];
  26. lastLink = this[x];
  27. console.log("Dereferenced link:", this[x]);
  28. }
  29. },
  30. task = function () {
  31. let links = document.querySelectorAll('#b-letter A:not(.fixed)');
  32. if (links.length > 0)
  33. for (let l of links) {
  34. l.classList.add("fixed");
  35. l.onclick = clearLink;
  36. }
  37. },
  38. confirmerObserver = new MutationObserver(function(mt) {
  39. for (let m of mt) {
  40. if (m.target.style.display !== 'none') {
  41. console.log('pop');
  42. m.target.querySelector('.confirm-cancel').click();
  43. window.open(lastLink, '_blank').focus();
  44. break;
  45. }
  46. }
  47. });
  48.  
  49. function link_monitor() { task(); setTimeout(link_monitor, 100); };
  50. setTimeout(link_monitor, 0);
  51.  
  52. (function locate_confirmer() {
  53. let confirmer = document.querySelector('#MailRuConfirm');
  54. if (confirmer) confirmerObserver.observe(confirmer, {attributes:true});
  55. else setTimeout(locate_confirmer, 100);
  56. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址