Enquirer Home Page | Twitter | Back to Improbable Island


// ==UserScript==
// @name        ii-wikilink
// @description expands dokuwiki-style links typed into text fields into urls that point to the Wiki of Lies
// @author      Full Metal Lion
// @namespace   http://enquirer.improbableisland.com/dokuwiki/doku.php?id=greasemonkey
// @match       *://*.improbableisland.com/*
// @exclude     *://enquirer.improbableisland.com/dokuwiki/*
// @icon        http://improbableisland.com/favicon.ico
// @version     1.2
// @grant       none
// ==/UserScript==
//This script does not support interwiki links, but I guess a future version could.
var bracketsr = /\[\[(.*?)\]\]/;
//matches brackets and captures what's between them,
var underscoresr = /[^a-zA-Z0-9-.:#?;\/@&=+$,]+/g;
//matches characters to replace them with underscores.
//this regex matches all but the characters that might mean something to dokuwiki
//the purpose of this process is to avoid breaking II's url detection
var url = "enquirer.improbableisland.com/dokuwiki/doku.php?id=";
var boxes = document.querySelectorAll('input, textarea');
for(var i=0; i<boxes.length; i++){
  boxes[i].addEventListener("input", function(event){
    target = this.value;
    target = bracketsr.exec(target)[1]; //get the capture group
    target = target.replace(/\?/,"&"); //support url parameters
    target = target.replace(underscoresr, "_");
    this.value =(this.value.replace(bracketsr, url+target));
Logged in as: Guest (Guest)
greasemonkey/ii-wikilink.txt · Last modified: 2018/02/22 01:15 by Full Metal Lion