Mail.Ru Links

Восстанавливает обрезанные ссылки

  1. // ==UserScript==
  2. // @name Mail.Ru Links
  3. // @namespace mailru
  4. // @description Восстанавливает обрезанные ссылки
  5. // @include *//*.mail.ru/*
  6. // @version 0.0.2
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. if (!String.prototype.endsWith) {
  11. String.prototype.endsWith = function (string, position) {
  12. var lastIndex;
  13. position = position || this.length;
  14. position = position - string.length;
  15. lastIndex = this.lastIndexOf(string);
  16. return -1 != lastIndex && lastIndex == position;
  17. };
  18. }
  19.  
  20. new function fix() {
  21. Array.forEach(document.querySelectorAll('a[target="_blank"]:not([fixed])'), function (link) {
  22. var linkText = link.textContent;
  23. if (linkText.endsWith('...') || linkText.endsWith('…')) {
  24. link.textContent = link.href;
  25. }
  26. link.setAttribute('fixed', 'true');
  27. });
  28. window.setTimeout(fix, 1000);
  29. };