User:PhantomTech/scripts/PhantomBotHelperScript.js

// Makes working with User:ThePhantomBot and its logs easier.

importScript("MediaWiki:Gadget-morebits.js");

( function ( $, mw ) {	'use strict';	$( document ).ready( function {

function deleteLog( revid, $selector ) { var fullLogRegex = new RegExp('\\{\\{ ?User:ThePhantomBot\/log\/logitem ?\\|.*?\\| msg ?=.*?' + revid + '.*?\\| status ?=.*?}}(?:\n\n?)','im'); var page = new Morebits.wiki.page( mw.config.get('wgPageName') ); page.load( function {				var text = page.getPageText;				text = text.replace(fullLogRegex, '');

if (text !== page.getPageText) { page.setPageText(text); page.setMinorEdit(true); page.setMaxConflictRetries(0); page.setEditSummary('Removing log with PBHS'); page.save( function {						$selector.text('Removed');					}, function  {						$selector.text('Failed');					}); } else { $selector.text('Already removed'); }			});		}

if ( mw.config.get('wgPageName' ) === 'User:ThePhantomBot/reports/UA/bad_pages') { var $logSelector = $( '.thephantombot-logitem' ); var logItemRegex = /"Special:Diff\/(\d+)"/im;

$logSelector.each( function {				var reMatch = $( this ).html.match(logItemRegex);				$(this).after( ' [Remove log]' );			});

$( '.thephantombot-logitem-delete' ).click( function {				$( this ).text('Removing...');				deleteLog( $( this ).attr("id"), $( this ) );			} ); }	}); }( jQuery, mediaWiki) );