Enquirer Home Page | Twitter | Back to Improbable Island
 

ii-rainbow

Please note: Because it is not disabled by using the 'Disable Player Colors' link, and some players may find walls of rainbow text highly distracting, please be considerate in the use of this tool, particularly in public places like Banter or Outposts.

ii-rainbow.user.js
// ==UserScript==
// @name        ii-rainbow
// @description `rtext to rainbow`r
// @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     0.1
// @grant       none
// ==/UserScript==
 
var bracketsr = /`r(.*?)`r/;
//matches brackets and captures what's between them,
 
rain=["*","Q","y","g","L","&","V"];
 
var rainindex=0;
function nextrain(){
  if (rainindex>=rain.length){
    rainindex = 0;
  }
  return rain[rainindex++];
}
 
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
    str="";
    for (c of target){
      if (c != " "){
        str += "`"+nextrain()+c;
      } else {
        str += c;
      }
    }
    rainindex=0;
    str = "`b`i"+str+"`b`i";
    console.log(str);
    this.value =(this.value.replace(bracketsr, str));
  });
};
 
Logged in as: Guest (Guest)
greasemonkey/ii-rainbow.txt · Last modified: 2018/03/17 02:42 by csodalatos