Benutzer:WWWIG/monobook.js

Aus Watch-Wiki
Zur Navigation springen Zur Suche springen

Hinweis: Leere nach dem Speichern den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Gehe zu Menü → Einstellungen (Opera → Einstellungen auf dem Mac) und dann auf Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
/* -- */
// my_vkdebug = true;

addOnloadHook( function () {
    LoadTemCatGenForm();
});

var t_wikiurl = wgServer + wgScriptPath + '/api.php';
var t_Files = new Array();
var t_FilesChecked = new Array();
var t_processnext = 0;
var t_restartintervall = 120*1000;


t_blackwordlist = new Array(
'comment',
'porn',
'angel',
'fire',
'sex',
'animal',
'movies',
'film',
'gift',
'free',
'self',
'young',
'donna',
'teens',
'girls',
'craig',
'generic',
'extend',
'discount',
'pills',
'insurance',
'life',
'valium',
'robaxin',
'vimax',
'xtreme',
'bodybuilding',
'tits',
'total',
'gym',
'reverse',
'number',
'asses',
'big');

function LoadTemCatGenForm() {

	window.setTimeout( "LoadTemCatGenForm()", t_restartintervall );

	if ( document.getElementById( 'InsertcheckRCForm' ) ) {
		out =	'<form method="get" style="width:100%" name="TemCatGenForm">' +
			'<fieldset><legend>Recentchanges</legend>' +
			'<div style="margin-top:.5em; margin-left:1em; margin-right:1em;">' +
			'<p><input type="button" value="Hole RC" ' +
			'title="" onClick="CheckRC()">&nbsp;' +
			'</p>' +
			'<label for="Status" style="vertical-align:top;">Status:</label>' +
			'<p id="Status" style="border: 1px solid #aaa; padding:.5em;" > ...</p>' +
			'<div id="PreviewForm"></div>' +
			'<div id="InsertRCForm"></div>' +
			'</div></fieldset></form>';

		document.getElementById( 'InsertcheckRCForm' ).innerHTML = out;
	}
}

function CheckRC() {

	var t_parameters = '?action=query&format=json&list=recentchanges&rclimit=50&rctype=new&rcprop=user|comment|flags|timestamp|title|ids|sizes';
	var t_http_req = null;
	if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
	else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
	t_http_req.open("GET", t_wikiurl + t_parameters, true);
	t_http_req.onreadystatechange = function() {
		if(t_http_req.readyState != 4) {
			document.getElementById( 'Status' ).innerHTML = 'RC-Liste wird angefordert ...';
		}
		if(t_http_req.readyState == 4 && t_http_req.status == 200) {
			GotRC( eval("(" + t_http_req.responseText + ")"), t_http_req.responseText );
		}
	}
	t_http_req.send(null);
}

function GotRC( queryData, rawData ) {

	t_Files.splice( 0, t_Files.length );

	if ( queryData.query && queryData.query.recentchanges ) {
		for ( t_Change = 0; t_Change < queryData.query.recentchanges.length; t_Change++ ) {
			if ( typeof queryData.query.recentchanges[t_Change].anon != 'undefined' ) {
				if ( CheckBadWord( queryData.query.recentchanges[t_Change].comment ) ) {
					var t_File = new Array( queryData.query.recentchanges[t_Change].title,
								queryData.query.recentchanges[t_Change].revid,
								queryData.query.recentchanges[t_Change].user,
								queryData.query.recentchanges[t_Change].comment );
					t_Files.push( t_File );
				}
		        } else {
			}
		}
	}

	if ( t_Files.length == 0 ) {
		document.getElementById( 'Status' ).innerHTML = 'Prüfung durchgeführt ('+GetTimeStamp()+')<hr style="margin-top:1em;"><ul>';
	} else {
		document.getElementById( 'InsertRCForm' ).innerHTML = '<hr style="margin-top:1em;"><ul>';
		CheckTitles();
	}
}

function GetTimeStamp() {

	var t_now = new Date();
	
	t_GetTimeStamp = ('0000'+t_now.getUTCFullYear()).substr(String(t_now.getUTCFullYear()).length,4)+'-'+('00'+(t_now.getUTCMonth()+1)).substr(String((t_now.getUTCMonth()+1)).length,2)+'-'+('00'+t_now.getUTCDate()).substr(String(t_now.getUTCDate()).length,2)+'T'+
('00'+t_now.getUTCHours()).substr(String(t_now.getUTCHours()).length,2)+':'+('00'+t_now.getUTCMinutes()).substr(String(t_now.getUTCMinutes()).length,2)+':'+('00'+t_now.getUTCSeconds()).substr(String(t_now.getUTCSeconds()).length,2)+'Z';
	
	return t_GetTimeStamp;
}

function CheckBadWord( t_text ) {

	if ( t_text ) {
		for ( t_Word = 0; t_Word < t_blackwordlist.length; t_Word++ ) {
			if ( String( t_text.toUpperCase() ).indexOf( String( t_blackwordlist[t_Word]).toUpperCase() ) != -1 ) return true;
		}
		return false;
	}
}

function CheckTitles() {

	if ( t_processnext < t_Files.length ) {

		document.getElementById( 'InsertRCForm' ).innerHTML +=  '<li>' + t_Files[t_processnext][0]+'<br>'+t_Files[t_processnext][1]+'<br>'+t_Files[t_processnext][2]+'<br>'+t_Files[t_processnext][3] + '</li>';

		var t_parameters = '?action=query&format=json&prop=info|revisions&intoken=delete&titles=' + 
				encodeURIComponent( t_Files[t_processnext][0] ) + '';
		var t_http_req = null;
		if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
		else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
		t_http_req.open("GET", CatGenForm.t_wikiurl + t_parameters, true);
		t_http_req.onreadystatechange = function() {
			if(t_http_req.readyState != 4) {
				document.getElementById( 'Status' ).innerHTML += '<br>' + 'Datei-Token wird angefordert ...';
			}
			if(t_http_req.readyState == 4 && t_http_req.status == 200) {
				DeleteTitles( eval("(" + t_http_req.responseText + ")"), t_http_req.responseText );
			}
		}
		t_http_req.send(null);
	}
}

function DeleteTitles ( queryData, rawData  ) {

	if ( queryData ) {
		if ( queryData.query && queryData.query.pages ) {
			var t_token = "";
			var t_timestamp = "";
			var t_some_pages = queryData.query.pages;
			for ( var t_Page in t_some_pages ) {
				if ( t_some_pages[t_Page].edittoken ) {
					t_token = encodeURIComponent( t_some_pages[t_Page].edittoken );
				} else
				if ( t_some_pages[t_Page].deletetoken ) {
					t_token = encodeURIComponent( t_some_pages[t_Page].deletetoken );
				}
				if ( t_some_pages[t_Page].revisions ) {
					var t_some_revisions = t_some_pages[t_Page].revisions;
					for ( var i = 0; i < t_some_revisions.length; i++ )	{
						if (t_some_revisions[i].timestamp) {
							t_timestamp = t_some_revisions[i].timestamp;
						}
					}
				}
				document.getElementById( 'Status' ).innerHTML += '<br>' + t_some_pages[t_Page].starttimestamp;
			}

			t_summary = '&reason=' + encodeURIComponent( 'automatisch gelöscht' );

			var t_parameters = '?action=delete&format=json&title=' + encodeURIComponent( t_some_pages[t_Page].title ) +
					   t_summary + '&watch&basetimestamp=' + t_timestamp +
					   '&token=' + t_token + '&bot=1';

			var t_http_req = null;
			if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
			else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
			t_http_req.open("POST", CatGenForm.t_wikiurl + t_parameters, true);
			t_http_req.onreadystatechange = function() {
				if( t_http_req.readyState != 4 ) {
					document.getElementById( 'Status' ).innerHTML +=
						'<br>' + '<small>'+t_some_pages[t_Page].title+'</small><br>wird gelöscht ...';
				}
				if( t_http_req.readyState == 4 && t_http_req.status == 200 ) {
					DeleteTitlesProcessed( eval("(" + t_http_req.responseText + ")" ), t_http_req.responseText );
				}
			}
			t_http_req.send(null);
		}
	}
}

function CheckUsers() {

	if ( t_processnext < t_Files.length ) {
		var t_parameters = '?action=block&format=json&user=' + 
				encodeURIComponent( t_Files[t_processnext][2] ) + '&gettoken';
		var t_http_req = null;
		if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
		else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
		t_http_req.open("POST", CatGenForm.t_wikiurl + t_parameters, true);
		t_http_req.onreadystatechange = function() {
			if(t_http_req.readyState != 4) {
				document.getElementById( 'Status' ).innerHTML += '<br>' + 'Benutzer-Token wird angefordert ...';
			}
			if(t_http_req.readyState == 4 && t_http_req.status == 200) {
				BlockUsers( eval("(" + t_http_req.responseText + ")"), t_http_req.responseText );
			}
		}
		t_http_req.send(null);
	}
}

function BlockUsers ( queryData, rawData  ) {

	document.getElementById( 'Status' ).innerHTML += '<br>' + rawData;

	if ( queryData ) {
		if ( queryData.block && queryData.block.blocktoken ) {
			var t_token = queryData.block.blocktoken;

			var t_parameters = '?action=block&format=json&user=' + 
					encodeURIComponent( t_Files[t_processnext][2] ) + '&reason=' + 
					encodeURIComponent( 'spam (automatisch gesperrt)' )  + '&token=' + 
					encodeURIComponent( t_token );
			var t_http_req = null;
			if (window.XMLHttpRequest) {t_http_req = new XMLHttpRequest();}
			else if (window.ActiveXObject) {t_http_req = new ActiveXObject("Microsoft.XMLHTTP");}
			t_http_req.open("POST", CatGenForm.t_wikiurl + t_parameters, true);
			t_http_req.onreadystatechange = function() {
				if(t_http_req.readyState != 4) {
					document.getElementById( 'Status' ).innerHTML += '<br>' + 'Benutzer wird gesperrt ...';
				}
				if(t_http_req.readyState == 4 && t_http_req.status == 200) {
					DeleteTitlesProcessed( eval("(" + t_http_req.responseText + ")"), t_http_req.responseText );
				}
			}
			t_http_req.send(null);
		}
	}
}

function DeleteTitlesProcessed( queryData, rawData ) {

	if ( queryData['delete'] ) {
		if ( queryData['delete'].title && queryData['delete'].reason ) {
			document.getElementById( 'Status' ).innerHTML += '<br>' + queryData['delete'].title + '<br>' + queryData['delete'].reason;
			t_processnext++;
			if ( t_processnext < t_Files.length ) {
				CheckTitles();
			} else {
			    t_processnext = 0;
				CheckUsers();
			}
		}
	}  else
	if ( queryData['block'] && queryData['block'].user ) {
		document.getElementById( 'Status' ).innerHTML += '<br>' + queryData['block'].user + ' wurde gesperrt';
		t_processnext++;
		if ( t_processnext < t_Files.length ) {
			CheckUsers();
		}
	} else {
		document.getElementById( 'Status' ).innerHTML += '<br>Unbekannter Fehler ' + rawData;
	}
	if ( t_processnext >= t_Files.length ) {
		document.getElementById( 'InsertRCForm' ).innerHTML += '</ul>';
		document.getElementById( 'Status' ).innerHTML = 'Prüfung durchgeführt ('+GetTimeStamp()+')<hr style="margin-top:1em;"><ul>';
	}
}