NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Oolite Forum aegidian.org Wiki-links
// @copyright 2019, private_lock (https://openuserjs.org/users/private_lock)
// @license GPL-3.0-or-later
// @version 2019-04-19
// @grant none
// @icon http://www.aegidian.org/bb/images/elitewikismall.png
// @include http://www.aegidian.org/*
// @include https://www.aegidian.org/*
// @include http://aegidian.org/*
// @include https://aegidian.org/*
// ==/UserScript==
// http://de.selfhtml.org/xml/darstellung/xpathsyntax.htm
function viaXpath(path, node, ordered) {
return document.evaluate(path, node ? node : document, null,
ordered ? XPathResult.ORDERED_NODE_SNAPSHOT_TYPE : XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
}
const nodeList = viaXpath('//div[@class="postbody"]//div[@class="content"]');
const reg_wiki_search = /\[wiki/i,
reg_wiki_replace = /\[wiki\]([^\[]*)\[\/wiki\]/gi,
prefix = 'http://wiki.alioth.net/index.php/',
icon = '/bb/images/elitewikismall.png',
link = '<a class="postlink" href="' + prefix + '$1"><img src="' + icon + '" alt="[EliteWiki]" width="13" height="13"> $1</a>';
for (var i = 0; i < nodeList.snapshotLength; i++) {
const node = nodeList.snapshotItem(i);
if (node.innerHTML.search(reg_wiki_search) >= 0) {
// node.style = 'border:1px solid red;';
node.innerHTML = node.innerHTML.replace(reg_wiki_replace, link);
}
}