User:Ryan/monobook.js
//////////STATUS CHANGER
// Creator: Misza13
// Credits: Voyagerfan5761 for some minor improvements
addOnloadHook(function (){
//Check if the config is defined
if (typeof(statusChangerConfig) == 'undefined') {
statusChangerConfig = {}
}
if (typeof(statusChangerConfig.statusList) == 'undefined') {
statusChangerConfig.statusList = [ 'online', 'editing', 'offline'];
}
if (typeof(statusChangerConfig.statusPage) == 'undefined') {
statusChangerConfig.statusPage = 'User:' + wgUserName + '/Status';
}
if (typeof(statusChangerConfig.statusTemplate) == 'undefined') {
statusChangerConfig.statusTemplate = 'User:' + wgUserName + '/StatusTemplate';
}
//Add the links
for (var i=0; i var stat = statusChangerConfig.statusList[i]; mw.util.addPortletLink( "p-personal", //target tab - personal links mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + statusChangerConfig.statusPage + "&action=edit&newstatus=" + stat, //link URL stat, //link text "pt-status-" + stat, //id of new button "" + stat + "!", //hover text "", //??? document.getElementById("pt-logout")); //add before logout button } if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status? //Get new status statusRegExp = /&action=edit&newstatus=(.*)/; status = statusRegExp.exec(location.href)[1]; //Modify the form document.getElementById('wpTextbox1').value = ""+status+""; document.getElementById('wpSummary').value = "Status update: " + status; document.getElementById('wpMinoredit').checked = true; //Submit it! document.getElementById('editform').submit(); }); ///////////////////////////////////////// // By Alek Storm // Please see talk page for instructions ///////////////////////////////////////// var body; // shortcut for body node var xmlhttp; // XMLHTTPRequest object var startNode; // div that includes section header and edit link var editSec; // edit link var editForm; // spliced edit form var preview; // spliced preview or diff content var oldContent; // original content of section var xmlhttpDone = false; // kludge to prevent multiple calls to callback importScript("User:Supadawg/util.js"); function inc(path) { var lt = String.fromCharCode(60); var gt = String.fromCharCode(62); document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+path+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt); } function initSecEdit() { body = document.getElementsByTagName("body")[0]; // apply to all divs of class "editsection" var editSecs = document.getElementsByTagName("span"); var secCount = 1; var pagetitleRe=/\/(wiki\/|w\/index\.php\?title=)([^&?]*)/; // from [Wikipedia:WikiProject User scripts/Techniques] for ( var i = 0; i < editSecs.length; i++ ) { if ( editSecs[i].getAttribute("class") == "editsection" ) { for ( var k = 0; k < editSecs[i].childNodes.length; k++ ) { if ( editSecs[i].childNodes[k].nodeName == "A" ) { // grab editing uri, escape it, then put it back in var editURI = "http://en.wikipedia.org/w/index.php?title="+encodeURIComponent2(pagetitleRe.exec(decodeURI(editSecs[i].childNodes[k].getAttribute("href")))[2]).replace(/\"/gi, "%22").replace(/\'/gi, "%27")+"&action=edit§ion="+secCount; // give it a unique id editSecs[i].childNodes[k].setAttribute( "id", "editSection"+secCount ); // swap the href with a function call, passing the original href as the second parameter editSecs[i].childNodes[k].setAttribute( "href", "javascript:editSection( document.getElementById('editSection" + secCount + "'), '"+editURI+"' );" ); secCount++; } } } } } // called on click of section edit link function editSection( elem, editURI ) { cancelEdit(); // get rid of any other sections being edited editSec = elem; startNode = elem.parentNode.parentNode; // initiate xmlhttprequest for section edit page xmlhttpDone = false; xmlhttp = null // kludge xmlhttp = createXMLHTTP( "GET", editURI, stateChange ); } // put raw input returned from XMLHTTPRequest into a div so we can grab specific elements function makeDiv( rawHTML ) { var div = createNode( body, "div", {style: "visibility: hidden; position: absolute;"} ); div.innerHTML = rawHTML.replace(/