Jump to content

User:Oxymoron83/aivreporthelper.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// If TwinkleConfig aint exist.
 if( typeof( TwinkleConfig ) == 'undefined' ) {
	TwinkleConfig = {};
 }

$(twinkleaivreporthelper);
 
//Eintragungen auf VM
function twinkleaivreporthelper () {
  
  if ( (wgPageName == "Wikipedia:Administrator_intervention_against_vandalism") && (QueryString.get( 'aivhelper' ) ) ) {
          
	var vandal = QueryString.get( 'vandal' );
	var article = QueryString.get( 'vanarticle' ).replace( /^(Image|Category):/i, ':$1:' );

        if(vandal ==  wgUserName) {
		alert('You don\'t want to report yourself, do you?');
		return;
	}      

	var text = document.getElementById( 'wpTextbox1' ).value;
 	var re = new RegExp( "\\{\\{\\s*(?:(?:[Ii][Pp])?[Vv]andal|[Uu]serlinks)\\s*\\|\\s*(?:1=)?\\s*" + RegExp.escape( vandal, true ) + "\\s*\\}\\}" );
 	var myArr;

	if( ( myArr = re.exec( text ) ) ) {
		return;
	}

	var notice;
	if ( QueryString.exists('vanarticlerevid') && QueryString.exists('vanarticlegoodrevid') ) {
		var query = {
			'title': article,
			'diff': QueryString.get( 'vanarticlerevid' ),
			'oldid': QueryString.get( 'vanarticlegoodrevid' )
		};
		notice = "On [[" + article + "]] ([" +  mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?" + QueryString.create( query ) + " diff])";
	}

	if ( isIPAddress( vandal ) ) {
		notice = "*{{IPvandal|" + vandal + "}} - " + notice + " vandalism after final warning" + " ~~" + "~~";
	} else {
		notice = "*{{Vandal|" + vandal + "}} - " + notice + "vandalism after final warning, actions evidently indicate a vandalism only account" + " ~~" + "~~";
	}

	document.getElementById( 'wpTextbox1' ).value = text + notice;
	document.getElementById( 'wpSummary' ).value = "Reporting [[Special:Contributions/" + vandal + "|" + vandal + "]]";
	if( TwinkleConfig.markAIVReportAsMinor ) {
		document.getElementById( 'wpMinoredit' ).checked = true;
	}
	  
	if( confirm( "Add " + vandal + " who vandalized " + article + "?" ) ) {
	   document.getElementById('editform').submit();
        }

        //window.setTimeout(function() { window.close(); }, 2000);
     }
 }