User:User 100425457/hydra.js

// Credit to User:Chieftainalex for this code. // I've made a few changes which I have labeled with comments.

/* */ // DEFER LOADING SCRIPT UNTIL JQUERY IS READY. WAIT 25MS BETWEEN ATTEMPTS. function defer(method) { if (window.jQuery) { method; } else { setTimeout(function { defer(method) }, 25); } }

// INITIALISATION defer(function {    addMiniskillbarToPvxdecode; });

/** Job queue - Query wiki API with ajax for the job queue statistic, copied from User:Dr ishmael/monobook.js **/ function addMiniskillbarToPvxdecode { // Check if page title = Special:PvXDecode if (mw.config.get('wgCanonicalSpecialPageName') === 'PvXDecode') {

// Locate the original textarea node var target = $('#mw-content-text textarea'); target.attr('id','pvxbig');

// Create another with similar attributes var newtextnode = $(' '); target.after(newtextnode);

// Get original content var wikitext = target.val; // User 100425457 custom change: // Create the profession icons (should use regex here...) var pos1 = wikitext.indexOf('prof=') var pos2 = wikitext.indexOf(' ', pos1) var prof = wikitext.substring(pos1 + 5, pos2) var pos = prof.indexOf('/') var p1 = prof.substring(0, pos) var p2 = prof.substring(pos + 1) // /Any prof = '/ \n'

// Apply the find and replace patterns var patterns = [ ['\r\n', '\n'], ['\\[build(.*?)\\]', ']'], ['\\[\\/build\\]', '['], ['\\]\\[', '|'],           ['\\', ''], ['\n', ''], ['\\|\\}\\}', '}}']       ];        $.map(patterns, function(p,i) {            var originalText = p[0];            var newText = p[1];            var originalTextRegex = new RegExp(originalText, 'mg');            wikitext = wikitext.replace(originalTextRegex, newText);        });

// Write back to the page // User 100425457 custom change: (add prof to wikitext) $('#pvxsmall').val(prof + wikitext); } } /* */