User:Wizardboy777/PvXtools/automaticPatrol.js

/* */ /**** gwwtAutomaticPatrol v1.2 * (c) 2008 by Patrick Westerhoff [poke] * Modified for PvXwiki by Wizardboy777 */ function pvxAutomaticPatrol ( patrolArticles ) { var expr, link, xmlHTTP; if ( window.location.href.indexOf( '&diff=' ) > -1 ) expr = '//div[ @id="mw-diff-ntitle4" ]/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, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, 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, XPathResult.FIRST_ORDERED_NODE_TYPE, 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://www.pvxwiki.com/w/images/a/ae/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 ); } /* */