User:SilentStorm/monobook.js

var gwwtWatchlist = true; var gwwtPortletPos = 'p-search';

/**** 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';

/////////////////////////

/**** function clearRecentChanges.js * (c) 2009 by Patrick Westerhoff [poke] * * Customize rNames and rWords to filter out entries from Special:RecentChanges. */ function ClearRecentChanges { if ( wgPageName !== 'Special:RecentChanges' ) return false; var rNames, rWords, xpath, snaps, snap; rNames = [ 'Mtew', 'Shard', 'Idontexist' ]; rWords = [ 'Ursan', 'ursan', 'nerf', 'buff', 'imba', 'balanc', 'skill', 'delete', 'GWWT', 'Isaiah Cartwright', 'Izzy', 'Shadow Form', 'Wounding Strike', 'Palm Strike', 'Idontexist' ]; xpath = '//div[@id="bodyContent"]//li/.. | //div[@id="bodyContent"]//li['; xpath += rNames.length > 0 ? './a[contains(@class,"mw-userlink")][contains(@title,"' + rNames.join( '") or contains(@title,"' ) + '")] or ' : ''; xpath += rWords.length > 0 ? 'contains(a[1]/@title,"' + rWords.join( '") or contains(a[1]/@title,"' ) + '") or ' : ''; xpath += rWords.length > 0 ? 'contains(span[@class="comment"],"' + rWords.join( '") or contains(span[@class="comment"],"' ) + '") or ' : ''; xpath += ' 0 ]'; snaps = document.evaluate( xpath, document, null, 6, null ); parent = snaps.snapshotItem( 0 ); for ( var i = 1; i < snaps.snapshotLength; i++ ) parent.removeChild( snaps.snapshotItem( i ) ); }

/** Some Additional Stuff * (c) 2008-2009 by SilentStorm */ function ImageNaming {   if ( wgNamespaceNumber == 3 && wgAction == 'edit' ) {      var pageRootName = wgTitle.substring( 0, ( ( wgTitle.indexOf( '/' ) > 0 ) ? wgTitle.indexOf( '/' ) : wgTitle.length ) ); var EdtBox = document.getElementById('wpTextbox1'); var Code = ' ' + pageRootName + ' --~ ';

EdtBox.value = Code.substr(8,Code.length -17) + EdtBox.value; } }

// My Wiki Links function AddXTLinks {   var XT_Personal = new PortletArea('p-personal'); var XT_Tools = new PortletArea('p-tb'); var XT_Links = new PortletArea('p-xtlinks', 'Important Links', document.getElementById( 'p-search' )); var pageRootName = wgTitle.substring( 0, ( ( wgTitle.indexOf( '/' ) > 0 ) ? wgTitle.indexOf( '/' ) : wgTitle.length ) ); XT_Links.addItem ( 'xt_del', 'GWW:DEL', '/wiki/GWW:DEL', 'Show Candidates for Deletion'); XT_Links.addItem ( 'xt_inacguilds', 'Inactive Guilds', '/wiki/Guild_Wars_Wiki:List_of_inactive_guilds', 'Show Inactive Guilds'); XT_Links.addItem ( 'xt_maintenance', 'GWW Maintenance', '/wiki/User:SilentStorm/sandbox/Maintenance', 'View Maintenance Page'); XT_Links.addItem ( 'xt_unusedimg', 'Orphaned Images', '/wiki/Special:UnusedImages', 'View Unused Images'); if ( wgNamespaceNumber == 3 && wgAction == 'edit' ) {      XT_Links.addItem ( 'xt_kakImgTpl', 'Bad Image', 'javascript:ImageNaming', 'Add Bad Image Notice'); }   else {      XT_Links.addItem ( 'xt_kakImgTpl', 'Bad Image', '/wiki/User:Kakarot/Templates/Image_Name', 'Bad Image Naming Notice Template'); }   XT_Links.addItem ( 'xt_login', 'Login Screen', '/wiki/ArenaNet:Login_screen_announcements', 'Login Screen Announcements'); XT_Links.addItem ( 'xt_feedback', 'Feedback Home', '/wiki/Feedback:User', 'Recently Created Suggestions'); if (navigator.appName !== 'Microsoft Internet Explorer') {      XT_Links.addText ( '---'); XT_Links.addItem ( 'xt_contrib', 'Contrib Counter', "javascript:addScript('User:Poke/GuildWarsWikiTools/ContributionCount.js');", 'Add Contribution Counter'); }

XT_Personal.addItem ( 'xt_mycss', 'CSS', '/wiki/User:SilentStorm/monobook.css', 'My StyleSheet', null, document.getElementById('pt-preferences') ); XT_Personal.addItem ( 'xt_myjs', 'JS', '/wiki/User:SilentStorm/monobook.js', 'My Javscript', null, document.getElementById('pt-preferences') ); XT_Personal.addItem ( 'xt_feedb', 'FB', '/wiki/Feedback:User/SilentStorm', 'My Feedback', null, document.getElementById('pt-preferences') );

if (wgNamespaceNumber !== 2 && wgNamespaceNumber !== 3 && wgNamespaceNumber !== 100 && wgNamespaceNumber !== 101 && wgNamespaceNumber !== -1) {      var dTalkNamespaceNumber = wgNamespaceNumber +1; XT_Tools.addItem ( 'xt_subpages', 'List Subpages', '/index.php?title=Special:Prefixindex&namespace=' + wgNamespaceNumber + '&from=' + pageRootName, 'Show All Subpages'); XT_Tools.addItem ( 'xt_subpages', 'List all Talkpages', '/index.php?title=Special:Prefixindex&namespace=' + dTalkNamespaceNumber + '&from=' + pageRootName, 'Show All Talkpages'); } }

/** Favicon changer **/ function changeFavicon( url ) {  var head  = document.getElementsByTagName( 'head' )[0]; var link = document.createElement( 'link' ); link.rel = 'shortcut icon'; link.type = "image/x-icon"; link.href = url; var links = head.getElementsByTagName( 'link' ); for ( var i = 0; i < links.length; i++ ) {    if ( links[i].rel == 'shortcut icon' ) {       head.removeChild( links[i] ); break; }  }   head.appendChild( link ); }

/**** RC Highlight. * Based on Stalker by Poke. * (C) 2009 by SilentStorm */ function HighlightRC(names, styles) {  if ( wgPageName != 'Special:RecentChanges' ) return; var links = document.getElementById( 'bodyContent' ).getElementsByTagName( 'a' ); for ( var x = 0; x < names.length; x++ ) {    for ( var i = 0; i < links.length; i++ ) {       if ( links[i].title.indexOf( names[x] ) > -1 ) links[i].style.background = styles[x]; }  } }

/**** function highlightRecentChanges.js * (c) 2009 by Patrick Westerhoff [poke] * Highlighs the given users or titles that contain the given text with the specified background color */ function highlightRecentChanges ( users, pages ) {  if ( wgPageName != 'Special:RecentChanges' ) return; for ( var user in users ) {    var snaps = document.evaluate( '//div[@id="bodyContent"]//li[./a[contains(@class,"mw-userlink")][contains(@title,"' + user + '")]]', document, null, 6, null ); for ( var i = 0; i < snaps.snapshotLength; i++ ) snaps.snapshotItem( i ).style.background = users[user]; }  for ( var page in pages ) {    var snaps = document.evaluate( '//div[@id="bodyContent"]//li[contains(a[1]/@title,"' + page + '")]', document, null, 6, null ); for ( var i = 0; i < snaps.snapshotLength; i++ ) snaps.snapshotItem( i ).style.background = pages[page]; } }

var gwwtLoadAfter = function {  if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3 ) {     var pageRootName = wgTitle.substring( 0, ( ( wgTitle.indexOf( '/' ) > 0 ) ? wgTitle.indexOf( '/' ) : wgTitle.length ) ); var XT_PortTop  = new PortletArea( 'p-cactions' ); XT_PortTop.addItem( 'xt_viewcss', 'Users CSS', '/wiki/User:' + pageRootName + '/monobook.css', 'Show ' + pageRootName + '\'s Stylesheet' ); XT_PortTop.addItem( 'xt_viewjs', 'User JS', '/wiki/User:' + pageRootName + '/monobook.js', 'Show ' + pageRootName + '\'s JavaScript' ); }  AddXTLinks; changeFavicon('http://borntolaugh.de/files/GuildWarsWiki.ico');

var rc_name = [ '.js', '.css', 'Elric', 'Poke' ]; var rc_style = [ '#FF0000', '#FF0000', '#FCC', '#80FF40' ]; HighlightRC(rc_name, rc_style); //var rc_users = { 'Poke':'#CEEFFF', 'Elric':'#FCC' }; //var rc_texts = { '.js':'#F00', '.css':'#F00' }; //highlightRecentChanges(rc_users, rc_texts);

//No Watching on Images or Guildpages by Default if ( wgCanonicalNamespace != "File" && wgCanonicalNamespace != "Guild" && wgAction == "edit") {     var Watch = document.getElementById('wpWatchthis'); Watch.checked = true; Watch.value = 1; }

if ( wgAction == "edit" && wgCurRevisionId == false ) {     var Sum = document.getElementById('wpSummary'); Sum.value = 'creation.'; }

//Add CleanRC Option on RC  if ( wgNamespaceNumber == -1 && wgPageName == 'Special:RecentChanges' && navigator.appName !== 'Microsoft Internet Explorer') {     var XT_RCTab = new PortletArea( 'p-cactions' ); XT_RCTab.addItem( 'xt-clearrc', 'Cleanup RC', 'javascript:ClearRecentChanges', 'Hide nasty Edits'); } }

/**** WantedPages Cleanup * (c) 2007 by Patrick Westerhoff [poke] * (c) 2009 by Belar based on Work by poke */

hookEvent( 'load', function {  if ( wgPageName !== 'Special:WantedPages' )     return false;   var removeNames = [ 'Guild' ];   var removeWords = [ 'Guild' ];   var i, li, lis, xpath, remove = new Array;   xpath  = '//div[@id="bodyContent"]//li[ ';   xpath += 'contains( a[4]/@title, "' + removeNames.join( '" ) or contains( a[4]/@title, "' ) + '" ) or ';   xpath += 'contains( a[1]/@title, "' + removeWords.join( '" ) or contains( a[1]/@title, "' ) + '" ) or ';   xpath += 'contains( span[@class="comment"], "' + removeWords.join( '" ) or contains( span[@class="comment"], "' ) + '" ) ]';   lis    = document.evaluate( xpath, document, null, 4, null );   while( ( li = lis.iterateNext ) )   {     remove.push( li );   }   while( ( li = remove.pop ) )   {     li.parentNode.removeChild( li );   } } );