vBulletin - Show full links

Reveals truncated (...) links in vBulletin-forums.

当前为 2017-11-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name vBulletin - Show full links
  3. // @namespace http://openuserjs.org/users/ardiman
  4. // @description Reveals truncated (...) links in vBulletin-forums.
  5. // @description:de-DE Zeigt gekürzte Links in vBulletin-Foren komplett an.
  6. // @grant none
  7. // @homepage https://github.com/ardiman/userscripts/tree/master/vbulletinshowfulllinks
  8. // @icon https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif
  9. // @include */showthread.php*
  10. // @include */viewtopic.php?*
  11. // @license CC-BY-NC-SA-3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
  12. // @license MIT; https://opensource.org/licenses/MIT
  13. // @supportURL https://github.com/ardiman/userscripts/issues
  14. // @version 1.9.3
  15. // @date 2017-11-19
  16. // ==/UserScript==
  17.  
  18.  
  19. (function () {
  20. matchtext = new RegExp("/\.{3,3}[0-z]");
  21. var rrdirect = 1; //if = 1, then try to remove prefixes like "http://anonym.to/?" etc.
  22.  
  23. function changelinktext(link)
  24. {
  25. var d = link.firstChild.nodeValue;
  26. var u = link.href;
  27. match = matchtext.exec(d);
  28. if (match) {
  29. var linkparts = d.split("...");
  30. var a = u.indexOf(fcttrim(linkparts[0]));
  31. var z = 0;
  32. if (linkparts[1]){
  33. z = u.indexOf(fcttrim(linkparts[1]));
  34. }
  35. if (a != -1 && z != -1) {
  36. if (rrdirect == 1) {
  37. link.firstChild.nodeValue = u.slice(a);
  38. } else {
  39. link.firstChild.nodeValue = u;
  40. }
  41. }
  42. }
  43. }
  44.  
  45.  
  46. function fcttrim(a_str) {
  47. return a_str.replace(/ +/g, ' ').replace(/^\s+/g, '').replace(/\s+$/g, '');
  48. }
  49.  
  50.  
  51. urlarray = document.evaluate(
  52. '//a[@href]',
  53. document,
  54. null,
  55. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  56. null);
  57.  
  58. for(var i = 0; i < urlarray.snapshotLength; i++) {
  59. link = urlarray.snapshotItem(i);
  60. if (link.firstChild) {
  61. changelinktext(link);
  62. }
  63. }
  64. })();