vBulletin - Show full links

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

当前为 2014-11-21 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         vBulletin - Show full links
// @namespace    http://openuserjs.org/users/ardiman
// @description  Reveals truncated (...) links in vBulletin-forums.
// @description:de-DE  Zeigt gekürzte Links in vBulletin-Foren komplett an.
// @grant        none
// @homepage     https://github.com/ardiman/userscripts/tree/master/vbulletinshowfulllinks
// @icon         https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif
// @include      */showthread.php*
// @include      */viewtopic.php?*
// @license      CC BY-NC-SA 3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/
// @supportURL   https://github.com/ardiman/userscripts/issues
// @version      1.9.2
// @date         2014-11-21
// ==/UserScript==


(function () {
matchtext = new RegExp("/\.{3,3}[0-z]");
var rrdirect = 1;  //if = 1, then try to remove prefixes like "http://anonym.to/?" etc.

function changelinktext(link)
{
  var d = link.firstChild.nodeValue;
  var u = link.href;
  match = matchtext.exec(d);
  if (match) {
    var linkparts = d.split("...");
    var a = u.indexOf(fcttrim(linkparts[0]));
    var z = 0;
    if (linkparts[1]){
      z = u.indexOf(fcttrim(linkparts[1]));
    }
    if (a != -1 && z != -1) {
      if (rrdirect == 1) {
        link.firstChild.nodeValue = u.slice(a);
        } else {
        link.firstChild.nodeValue = u;
      }
    }
  }
}


function fcttrim(a_str) {
  return a_str.replace(/ +/g, ' ').replace(/^\s+/g, '').replace(/\s+$/g, '');
}


urlarray = document.evaluate(
  '//a[@href]',
  document,
  null,
  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  null);

for(var i = 0; i < urlarray.snapshotLength; i++) {
  link = urlarray.snapshotItem(i);
  if (link.firstChild) {
    changelinktext(link);
  }
}
})();