User:Splarka/electrocute.js

addOnloadHook(function { mw.util.addPortletLink('p-tb','/wiki/Special:Electrocute','Electrocutions'); });

if(wgPageName == 'Special:Electrocute') { document.title = 'User electrocution'; appendCSS('#content {visibility:hidden;}'); addOnloadHook(electrocuteForm); }

function electrocuteForm { var con = (document.getElementById('content')) ? document.getElementById('content') : document.getElementById('mw_content') var bcon = (document.getElementById('bodyContent')) ? document.getElementById('bodyContent') : document.getElementById('mw_contentholder') var fh = getElementsByClassName(con,'h1','firstHeading')[0]; while(fh.firstChild) fh.removeChild(fh.firstChild) fh.appendChild(document.createTextNode('User electrocution')); for(var i=0;i ' + 'User " + queryString('user') + " has had an electric shock per the following parameters:' + ' voltage = ' + queryString('voltage') + ' amperage = ' + queryString('amperage') + ' type = ' + queryString('acdc') + ' duration = ' + queryString('duration') + '' }

//Note: I was writing this as nice dom, but since it is for a gag anyways, it is too much work' bcon.innerHTML += '' + ' Electrocute a deserving user ' + ' User:  ' + ' Amps: ' + '0.001 0.01 0.1 ' + ' 1 10  100  '    + ' Voltage: ' + ' 6 12  24 '    + ' 36  48 120 ' + ' 240 480  2000  60,000  '    + '<label for="acdc_ac">AC ' + '<input id="acdc_dc" value="dc" name="acdc" type="radio" /><label for="acdc_dc">DC ' + ' (<a href="http://en.wikipedia.org/wiki/Electric_shock#Lethality_of_a_shock">help</a>) ' + ' Duration: <input id="duration" type="text" name="duration" value="100 milliseconds"/> ' + '<input type="submit" value="Apply" name="submit" />' + ' '  appendCSS('#content {visibility:visible;}');

if(queryString('user')) document.getElementById('user').value = queryString('user'); if(queryString('duration')) document.getElementById('duration').value = queryString('duration'); }

function appendCSS(text) { var s = document.createElement('style'); s.type = 'text/css'; s.rel = 'stylesheet'; if (s.styleSheet) s.styleSheet.cssText = text //IE else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null document.getElementsByTagName('head')[0].appendChild(s); return s; }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; }