User:Dr ishmael/monobook.js

function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); }	return null; }

function addBar { document.getElementById('p-navigation').innerHTML += ' '+ ' '+ ' Command Center '+ ' '+ 'Deletion'+ 'Copyvio'+ 'Master Log'+ 'New Pages</li>'+ '<a href=\"/wiki/Special:Newimages">New Images</a></li>'+ '<a href=\"/wiki/Special:Unusedimages">Unused Images</a></li>'+ '<a href=\"/wiki/MediaWiki:Sitenotice">Site Notice</a></li>'+ '<a href=\"/wiki/Special:Allmessages">System messages</a></li>'+ '<a href=\"/wiki/Special:WikiaStats">WikiaStats</a></li>'+ '</ul> '; } addOnloadHook(addBar);

function defaultFormValues { if(wgAction == 'delete') { document.getElementById('wpDeleteReasonList').value = readCookie('jsDeleteReasonList'); document.getElementById('wpReason').value = readCookie('jsReason'); } if(wgPageName == 'Special:Upload') { document.getElementById('wpUploadDescription').value = readCookie('jsUploadDescription'); document.getElementById('wpLicense').value = readCookie('jsLicense');

if(readCookie('jsWatchthis') == 1) { document.getElementById('wpWatchthis').checked = true; } else { document.getElementById('wpWatchthis').checked = false; }

if(readCookie('jsIgnoreWarning') == 1) { document.getElementById('wpIgnoreWarning').checked = true; } else { document.getElementById('wpIgnoreWarning').checked = false; }

} } addOnloadHook(defaultFormValues);

function addGWWSwitch {   var hist; var url; if (!(hist = document.getElementById('ca-history') )) return; if (!(url = hist.getElementsByTagName('a')[0] )) return; if (!(url = url.href )) return; addPortletLink('p-cactions', 'http://wiki.guildwars.com/wiki/' + wgCanonicalNamespace + ':' + encodeURIComponent( wgTitle ),                  'GWW', 'ca-gww', 'See this page on Guild Wars Wiki', 'g'); } addOnloadHook(addGWWSwitch);

/***** Custom edit buttons ****/ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/2/23/Button_code.png", "speedTip": "Code", "tagOpen": " ", "sampleText": "foo"}

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/7/73/Button_code_nowiki.png", "speedTip": "Code+Nowiki", "tagOpen": " ", "sampleText": "foo"}

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/central/images/f/f6/Button_html_comment.png", "speedTip": "HTML comment", "tagOpen": "", "sampleText": "I am a comment"}

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/d/d5/Button_noinclude.png", "speedTip": "Noinclude", "tagOpen": " ", "tagClose": " ", "sampleText": "bar"}

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/gw/images/b/bf/Button_pagename.png", "speedTip": "Pagename", "tagOpen": "", "sampleText": ""}

mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/4/4a/Btn_toolbar_strike.png", "speedTip": "Strikethrough", "tagOpen": " ", "tagClose": " ", "sampleText": "baz"}

}

/*** hideUser for RC ***/ /* function hideUserWrapper {   if (document.title.substring(0,14) == 'Recent changes') { var tables = document.getElementsByTagName('table'); var RCinput; for (var i = 0; i < tables.length; i++) { if (tables[i].className == 'mw-recentchanges-table') { RCinput = tables[i]; break; }       }        var uls = document.getElementsByTagName('ul'); var RCuls = new Array; for (var i = 0; i < uls.length; i++) { if (uls[i].className == 'special') { RCuls.push(uls[i]); }       }
 * Adds an input box and button under the "Namespace:" selector on Special:RecentChanges.
 * Enter a username in the box and click "Hide" to hide all edits by that user on your current RC list.
 * Clearing the box and clicking "Hide" will restore that user's edits to your current RC list.
 * Entering a different username and clicking "Hide" will do both of the above at once.
 * Does not "remember" the user if you refresh RC.
 * Works on Monobook and Monaco with non-grouped RC. Grouped RC uses some messy nested divs/tables that I don't feel like dealing with.
 * Because of how I'm placing it in the RC options, pressing "Enter" in the hideUser field will submit the Namespace form. I guess I should just make a new form instead of inserting this into the existing one, but this was the first thing I thought of.  I might try that later.

var myInput = document.createElement('input'); myInput.type = 'text'; myInput.id = 'hideUsername'; myInput.name = 'hideUsername';

var myLabel = document.createElement('label'); myLabel.for = 'hideUsername'; myLabel.innerHTML = "Hide user:";

var mySubmit = document.createElement('input'); mySubmit.type = 'button'; mySubmit.value = 'Hide'; var newRow = RCinput.insertRow(1); var newLabelCell = newRow.insertCell(0); var newInputCell = newRow.insertCell(1);

newLabelCell.appendChild(myLabel);

newInputCell.appendChild(myInput); newInputCell.appendChild(mySubmit);

try { //IE mySubmit.attachEvent("onclick", function{ hideUser(RCuls) } ); }       catch(e) { //Mozilla mySubmit.addEventListener("click", function { hideUser(RCuls) }, false); }   } } addOnloadHook(hideUserWrapper);

function hideUser(RCuls) {   var myUser = document.getElementById('hideUsername').value; for (var j = 0; j < RCuls.length; j++) { var lis = RCuls[j].getElementsByTagName('li'); for (var i = 0; i < lis.length; i++) { var userLink; if (lis[i].innerHTML.substring(0,6) == '(diff)') userLink = lis[i].getElementsByTagName('a')[2]; else userLink = lis[i].getElementsByTagName('a')[3]; if (userLink.innerHTML == myUser) lis[i].style.display = 'none'; else lis[i].style.display = ''; }   } } /*** end hideUser ***/