User:Aiiane/monobook.js

/**** Guild Wars Wiki Tools * (c) 2007 by Patrick Westerhoff [poke] */ var head = document.getElementsByTagName( 'head' )[0]; head.appendChild( document.createElement( 'script' ) ); head.lastChild.src = '/index.php?title=User:Poke/GuildWarsWikiTools.js&action=raw&ctype=text/javascript'; head.lastChild.type = 'text/javascript';

// Makes the Watchlist actually usable. Groups each day's updated entries by their respective namespaces.

addOnloadHook(function { if (location.href.indexOf('Special:Watchlist') == -1) return;   //days = document.getElementById('bodyContent').getElementsByTagName('ul');  days = document.evaluate( "//ul[@class='special']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (d = 0; d < days.snapshotLength; d++) {     day = days.snapshotItem(d);    newday = document.createElement('ul');     while ((diffs = day.getElementsByTagName('li')).length > 0) {       //Try to extract the namespace      As = diffs[0].getElementsByTagName('a');      if (As[0].innerHTML == 'diff')        pagename = As[2].innerHTML;      else        pagename = As[1].innerHTML;      if (pagename.indexOf(':') == -1)        namespace = 'Main';      else        namespace = pagename.split(':')[0];       hdrs = newday.getElementsByTagName('h5');       hdr = null;      for (j=0; j<hdrs.length; j++)         if (hdrs[j].innerHTML==namespace) {          hdr = hdrs[j]; break;        }      if (hdr==null) {         hdr = document.createElement('h5');        hdr.innerHTML = namespace;        newday.appendChild(hdr);        namespacesub = document.createElement('ul');        newday.appendChild(namespacesub); }     hdr.nextSibling.appendChild(diffs[0]); }   newday.appendChild(document.createElement('hr')); day.parentNode.replaceChild(newday,day); } });

// Lupin's popups,

document.write(' '); function siteArticlePath{ return 'wiki'; } function siteBotInterfacePath{ return ''; } // disabling features that depend on query.php until that is installed popupUseQueryInterface=false; popupDelay=0.5; popupSubpopups=false; popupAdminLinks=true;

// // CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES AND IF SURE DO IT AUTOMATIC: // *** aut. signing / (automatische Unterschrift) *** User:Olliminatore/signing.js // created 23.04.2006 by User:Olliminatore // updated 23.04.2006 by en:User:Ilmari Karonen // current version 1.56 13.03.2007 // Interwiki // GWW tweaks by User:MisterPepe String.prototype.trim = function{return this.replace(/^\s*|\s*$/g,"")}; if (typeof usersignature == 'undefined') usersignature = ' \~\~\~\~\n'; if (typeof regpages == 'undefined') { // list of all non talk pages var regpages = [ '.*noticeboard.*', ]; }    // regarded pages type encoded if (wgCanonicalNamespace.match(/talk$/i)) var regpages = ""; for (p in regpages) if (wgPageName.indexOf(regpages[p]) != -1){regpages=false; break} if (!regpages) addOnloadHook(function{   if (!(window.editform = document.forms['editform'])) return;    // Add a new checkbox to the Wiki editOptions.    sigBox = document.createElement("input");    sigBox.setAttribute('type','checkbox');    sigBox.setAttribute('name','wpSigning');    sigBox.setAttribute('id','wpSigning');    sigBox.setAttribute('checked','checked');    sigBox.defaultChecked=true;    neuB = document.createElement("label");    neuB.appendChild(sigBox);    neuB.appendChild(document.createTextNode("Sign"));    neuB.setAttribute('for','wpSigning');    neuB.setAttribute('title','Sign this edit automatic.');    function setSigBox { // switch enable box        if (editform.wpMinoredit.checked) sigBox.setAttribute('disabled','disabled');        else sigBox.removeAttribute('disabled');    };    var txtarea=editform.elements['wpTextbox1'];    var txtOld=txtarea.value.trim;    // txtOld_l=txtOld.length var txtOldEnd=txtOld.slice(-24); var sig = /~{3}/g; if (!tNode){ //editform.insertBefore(neuB, editform.elements['wpWatchthis']); // maybe FIXME: raised an NS_DOM_ERR! var tNode = editform.elements['wpMinoredit'].parentNode; // DOM workaround!? tNode.divs = tNode.getElementsByTagName("DIV"); tNode.divs = tNode.divs.item(tNode.divs.length-1); // last div tNode.insertBefore(neuB, tNode.divs); setSigBox; }   function doSign(event){ if(editform.onsubmit==''){ // only once! removeEvent(editform.wpSave,"click",doSign); removeEvent(editform.wpPreview,"click",doSign); }       if(editform.onsubmit=='') removeEvent(editform.wpSave,"click",doSign); // only once! if(editform.wpMinoredit.checked || !sigBox.checked) return; txtarea.focus; var cOld = txtOld.match(/ .*?~{3}.*?<\/nowiki>/g); // exception for nowiki if (cOld) cOld = cOld.length; cNew = txtarea.value.match(sig); if (cNew) cNew = cNew.length; if (cNew > cOld){ // if there are a sign, check for true var cNew2 = txtarea.value.match(/\{\{subst\:unsig.*?~{3}\}\}/); // exception for Template:unsigned cNew -= (cNew2)?cNew2.length:0; }       if(cNew <= cOld){ // if nothing then search a set position txt=txtarea.value.trim; txtEnd=txt.slice(-24); if(txtOldEnd!=txtEnd) return txtarea.value = txt + usersignature; // aut. underwrite else { // post between pos = getCaretPos(txtarea); pos = txt.indexOf('\n', pos); // go to the post-end txtEnds = txt.substr(pos,24).replace(/(^\s*)/,""); // after txtpEnds = txt.slice(pos-18,pos); // before oldp = txtOld.indexOf(txtEnds); if(oldp!=-1 && oldp < pos - 3 && txtOld.indexOf(txtpEnds+RegExp.$1+txtEnds)==-1) // if some added return txtarea.value = txt.slice(0,pos).trim + usersignature + txt.slice(pos+1); }        // FIXME: then the edit-end is not found!? }       else if(!sig.test(txtOld) || cOld < cNew) return; if (event) event=(window.Event)? event.target: event.srcElement; if (event.name == 'wpPreview') return; // not for preview return editform.onsubmit=new Function("editform.onsubmit='';"         +"return confirm('No signing was found. Continue anyway?')"); //warn if saving without signature };   addEvent(editform.wpSave,"click", doSign); addEvent(editform.wpPreview,"click", doSign); addEvent(editform.wpMinoredit,"click", setSigBox); }); function getCaretPos(txtObj){   if (txtObj.setSelectionRange) return txtObj.selectionStart; // NS like    else if(!document.selection) return 0;  // not IE like    var c="\001", pos=0;    var range=document.selection.createRange;    var txt=range.text, dul=range.duplicate;    dul.moveToElementText(txtObj);    range.text=txt+c;    pos=(dul.text.indexOf(c));    range.moveStart('character',-1);    range.text="";    return pos; }; /* add/removeEvent Original idea by John Resig Tweaked by Scott Andrew LePera, Dean Edwards and Peter-Paul Koch Fixed for IE by Tino Zijdel (crisp) @date 2005-10 */ function addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false)}else if(obj.attachEvent){var eProp=type+fn;obj["e"+eProp]=fn;obj[eProp]=function{obj["e"+eProp](window.event)};obj.attachEvent("on"+type,obj[eProp])}else{obj['on'+type]=fn}}; function removeEvent(obj,type,fn){if(obj.removeEventListener){obj.removeEventListener(type,fn,false)}else if(obj.detachEvent){var eProp=type+fn;obj.detachEvent("on"+type,obj[eProp]);obj['e'+eProp]=null;obj[eProp]=null}else{obj['on'+type]=null}}; // *** end ***

var PNGFIXarVersion = navigator.appVersion.split("MSIE") var PNGFIXversion = parseFloat(PNGFIXarVersion[1])

if ((PNGFIXversion >= 5.5) && (document.body.filters)) {  for(var i=0; i<document.images.length; i++) {     var img = document.images[i] var imgName = img.src.toUpperCase if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {        var imgID = (img.id) ? "id='" + img.id + "' " : "" var imgClass = (img.className) ? "class='" + img.className + "' " : "" var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " var imgStyle = "display:inline-block;" + img.style.cssText if (img.align == "left") imgStyle = "float:left;" + imgStyle if (img.align == "right") imgStyle = "float:right;" + imgStyle if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle var strNewHTML = " " img.outerHTML = strNewHTML i = i-1 }  } }