User:Lem/automaticPatrol.js

/* */ /**** gwwtAutomaticPatrol v1.3 * (c) 2008 by Patrick Westerhoff [poke] */ function gwwtAutomaticPatrol ( patrolArticles ) { var expr, link, xmlHTTP; if ( window.location.href.indexOf( '&diff=' ) > -1 ) expr = '//span[ @class="patrollink" ]/a[ contains(@href, "action=markpatrolled") ]'; else if ( window.location.href.indexOf( 'rcid=' ) > -1 ) expr = '//div[ @class="patrollink" ]/a[ contains(@href, "action=markpatrolled") ]'; else {   if ( !patrolArticles || wgPageName != 'Special:RecentChanges' && wgPageName != 'Special:Watchlist' ) return; var listItem, links, rcid, i = 0; var listItems = document.evaluate( '//div[@id="bodyContent"]//li[ a[ contains(@href, "rcid=") ] ]',     document, null, 6, null ); while ( ( listItem = listItems.snapshotItem( i++ ) ) ) {     links = listItem.getElementsByTagName( 'a' ); if ( ( rcid = links[0].href.match( /rcid=(\d+)/ ) ) ) links[2].href += '?rcid=' + rcid[1]; }   return; } link = document.evaluate( expr, document, null, 9, null ).singleNodeValue; if ( !link ) return; xmlHttp = new XMLHttpRequest; xmlHttp.onreadystatechange = function {   if ( xmlHttp.readyState == 4 ) {     link.parentNode.insertBefore( document.createElement( 'img' ), link ); link.previousSibling.src = 'http://wiki.guildwars.com/images/thumb/1/16/Tango-check-icon.png/16px-Tango-check-icon.png'; link.parentNode.insertBefore( document.createTextNode( ' patrolled' ), link ); link.parentNode.removeChild( link ); } }  xmlHttp.open( 'GET', link.href, true ); xmlHttp.send( null ); } /* */