User:DimeCadmium/monobook.js

/* COPYRIGHT/LICENSE */ /* //By DimeCadmium. Copyright 2010 John Runyon. //GFDL licensed. //Yeah, its crappy, so what.

/* SETTINGS */ var dcSet = { 'showHelp': true, // boolean, enable/disable the "help" pane under toolbox 'showWL': true, // boolean, enable/disable watchlist under options 'maxWatch': 5, // int, maximum # of watches to show 'wlReset': 60, // int, (seconds) duration between watchlist reloads 'modNav': { 'activate': true, // boolean, enable/disable the following navpane modification 'leaveSupport': false, 'items': [ // array of strings, link (INCLUDING ) to be put in nav 'Recent changes', 'Main Page', 'Community portal', 'Admin noticeboard', 'Help center', ], }, };

/* CODE */ var intid; addOnloadHook(doOnLoad);

function doTimer { var xmlhttp = new XMLHttpRequest; xmlhttp.open("GET", "http://wiki.guildwars.com/api.php?action=query&list=watchlist&format=json&wllimit="+dcSet['maxWatch']+"&wlprop=title|timestamp", false); xmlhttp.send; var json = xmlhttp.responseText; var wlOut = eval('(' + json + ')');

var str = ""; for (var k in wlOut['query']['watchlist']) { var title = wlOut['query']['watchlist'][k]['title']; var time = wlOut['query']['watchlist'][k]['timestamp']; str += ' '+title+' '+time+' '; } (document.getElementById('watchdiv')).innerHTML = ""+str+""; } function doOnLoad { if (dcSet['modNav']['activate']) { var navLine = ' navigation '; for (var item in dcSet['modNav']['items']) navLine += ''+dcSet['modNav']['items'][item]+'</li>';

(document.getElementById('p-navigation')).innerHTML = navLine+'</ul> ';

if (!dcSet['modNav']['leaveSupport']) (document.getElementById('p-support')).innerHTML = ""; } if (dcSet['showHelp']) { (document.getElementById('column-one')).innerHTML += ' help <a href="javascript:tagDeleteSpeedy;void(0);">Speedy deletion tags</a></li><a href="/wiki/Guild_Wars_Wiki:Policies">Policies</a></li><a href="/wiki/Guild_Wars_Wiki:Formatting">Formatting</a></li><a href="/wiki/Guild_Wars_Wiki:Requests_for_comment">RFC\'s</a></li></ul> '; (document.getElementsByTagName('body')[0]).innerHTML += '<div id="opt-popup" style="display:none; background-color:#fafad2; color:#777; font-size:large; font-family:monospace; max-width:70%; padding:2px 5px; position:fixed; right:2.5%; top:2.5%; z-index:100;"> '; }

if (dcSet['showWL']) { intid = setInterval(doTimer, (dcSet['wlReset']*1000)); (document.getElementById('column-one')).innerHTML += ' watchlist </ul> '; doTimer; } }

function tagDeleteSpeedy { var div = document.getElementById('opt-popup'); if (div.style.display == "none") { div.innerHTML = '<p style="float:right;"><a href="javascript:tagDeleteSpeedy;void(0);">[X]</a> '; div.innerHTML += " All : G1=Vandal • G2=test • G3=editor request • G4=housekeeping • G5=NPA • G6=re-creation • G7=ArbComm "; div.innerHTML += " Article : A1=no appropriate info • A2=no good source • A3=unrelated to GWW "; div.innerHTML += " Redirect : R1=from main -> [User|Guild] • R2=unnecessary • R3=misleading • R4=broken • R5=redirect-at-move "; div.innerHTML += " Image : I1=redundant • I2=corrupt "; div.innerHTML += " Category : C1=empty "; div.innerHTML += " User : U1=user request • U2=no such user "; div.innerHTML += " <a href='/wiki/GWW:DP'>See also</a> "; div.style.display = "block"; } else { div.style.display = "none"; div.innerHTML = ""; } }

function doEdit(newCont) { var xhr = new XMLHttpRequest; xhr.open("GET", '/api.php?format=json&action=query&prop=info|revisions&intoken=edit&titles='+wgPageName, false); xhr.send; var respS = eval('('+xhr.responseText+')'); var pgs = respS['query']['pages']; var tok; for (var key in pgs) { tok = pgs[key]['edittoken']; }	tok = tok.substring(0, tok.length-2); tok += "%2B%5C";

xhr = new XMLHttpRequest; xhr.open("GET", "/api.php?action=query&titles="+wgPageName+"&prop=revisions&rvprop=user|comment|content&rvlimit=1&format=xml", false); xhr.send; var currX = xhr.responseXML; var curr = (currX.getElementsByTagName('rev')[0]).textContent;

xhr = new XMLHttpRequest; xhr.open("POST", "/api.php", false); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("action=edit&title="+wgPageName+"&section=0&text="+newCont+"\n\n"+curr+"&token="+tok+"&summary=test&minor=1&nocreate=1&watchlist=nochange"); }