MediaWiki:CommonSysop.js: Unterschied zwischen den Versionen

Aus Watch-Wiki
Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
 
/* ------------------------------------------------ */
 
/* ------------------------------------------------ */
 
/* Script zum Erzeugen von Vorlagen und Kategorien  */
 
/* Script zum Erzeugen von Vorlagen und Kategorien  */
/* ------------------------------------------------ */
+
/* ------------------------------------------------
  
 
addOnloadHook( function () {
 
addOnloadHook( function () {
Zeile 19: Zeile 19:
 
var t_max_lang = 10;
 
var t_max_lang = 10;
 
var t_createnext = 0;
 
var t_createnext = 0;
var t_wikiurl = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php';
+
var t_wikiurl = wgServer + wgScriptPath + '/api.php';
 
var t_stopp = false;
 
var t_stopp = false;
  
Zeile 124: Zeile 124:
 
}
 
}
 
}
 
}
 
+
*/
 
/* ---------------------------------------------------- */
 
/* ---------------------------------------------------- */
 
/* Script für Voreinstellungen beim Sperren und Löschen */
 
/* Script für Voreinstellungen beim Sperren und Löschen */
 
/* ---------------------------------------------------- */
 
/* ---------------------------------------------------- */
  
$( function () {
+
addOnloadHook( function () {
 +
 
 
for ( var i = 0; i < document.getElementsByTagName( "A" ).length; i++ ) {
 
for ( var i = 0; i < document.getElementsByTagName( "A" ).length; i++ ) {
 
if ( href = document.getElementsByTagName("A")[i].getAttribute("href") ) {
 
if ( href = document.getElementsByTagName("A")[i].getAttribute("href") ) {
Zeile 140: Zeile 141:
  
 
if ( document.getElementById('ca-delete' ) ) {
 
if ( document.getElementById('ca-delete' ) ) {
if ( href = document.getElementById('ca-delete' ).firstChild.getAttribute("href") ) {
+
//if ( href = document.getElementById('ca-delete' ).firstChild.getAttribute("href") ) {
document.getElementById('ca-delete' ).firstChild.setAttribute("href", href + "&wpReason=%0A");
+
// document.getElementById('ca-delete' ).firstChild.setAttribute("href", href + "&wpReason=%0A");
}
+
//}
 
}
 
}
 
});
 
});
  
 
/* ---------------------------------------------------- */
 
/* ---------------------------------------------------- */

Version vom 18. Februar 2022, 03:24 Uhr

/* ------------------------------------------------ */
/* Script zum Erzeugen von Vorlagen und Kategorien  */
/* ------------------------------------------------

addOnloadHook( function () {

	if ( document.getElementById( 'InsertCreateForm' ) && ( wgUserName == "WWWIG" || wgUserName == "Torsten" || wgUserName == "Holger" ) ) {
		document.getElementById( 'InsertCreateForm' ).innerHTML = '<form method="get" style="width:100%" name="createform">' +
			'<fieldset><legend>Vorlagen- und Kategoriegenerator</legend>' +
			'<label for="Status" style="vertical-align:top">Status:</label>' +
			'<p id="Status">Vor dem Erzeugen bitte die Namen und Inhalte überprüfen ...</p>' +
			'<label for="Summary" style="vertical-align:top">Zusammenfassung:</label>' +
			'<p><input id="Summary" type="text" size="50" value="Mit neuer Vorlage generiert"></p>' +
			'<p><input type="button" value="Erzeugen" onClick="CreateVKFiles()">&nbsp;<input type="button" value="Abbrechen" onClick="StopCreateVKFiles()"></p></fieldset></form>';
	}
});

var t_Files = new Array();
var t_max_lang = 10;
var t_createnext = 0;
var t_wikiurl = wgServer + wgScriptPath + '/api.php';
var t_stopp = false;

function StopCreateVKFiles() {
	t_stopp = true;
}

function CreateVKFiles() {
	t_Files.splice( 0, t_Files.length );
	t_createnext = 0;
	t_stopp = false;

	for ( i = 1; i <= t_max_lang; i++ ) {
		t_FileV = document.getElementById( 'FileV' + i );
		t_InhaltV = document.getElementById( 'InhaltV' + i );
		if ( t_FileV && t_InhaltV ) {
			var t_File = new Array( t_FileV.getElementsByTagName("A")[0].innerHTML, t_InhaltV.innerHTML );
			t_Files.push( t_File );
		}
	}
	for ( i = 1; i <= t_max_lang; i++ ) {
		t_FileK = document.getElementById( 'FileK' + i );
		t_InhaltK = document.getElementById( 'InhaltK' + i );
		if ( t_FileK && t_InhaltK ) {
			var t_File = new Array( t_FileK.getElementsByTagName("A")[0].innerHTML, t_InhaltK.innerHTML );
			t_Files.push( t_File );
		}
	}
	CreateNextVKFile();
}

function CreateNextVKFile() {
	if ( t_createnext < t_Files.length ) {
	    var t_parameters = '?action=query&format=json&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent( t_Files[t_createnext][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", t_wikiurl + t_parameters, true);
		t_http_req.onreadystatechange = function() {
			if(t_http_req.readyState != 4) {
				document.getElementById('Status').innerHTML = 'Token wird angefordert ...';
			}
			if(t_http_req.readyState == 4 && t_http_req.status == 200) {
				GotToken( eval("(" + t_http_req.responseText + ")") );
			}
		}
		t_http_req.send(null);
	}
}

function GotToken( queryData ) {
	if ( queryData ) {
		if ( queryData.query && queryData.query.pages ) {
			var t_edittoken = "";
			var t_timestamp = "";
			var t_some_pages = queryData.query.pages;
			for ( var t_Page in t_some_pages ) {
				t_edittoken = encodeURIComponent( t_some_pages[t_Page].edittoken );
				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 = t_some_pages[t_Page].starttimestamp;
			}

			t_summary = document.getElementById('Summary').getAttribute('value');
			t_text = t_Files[t_createnext][1];
			t_text = t_text.replace(/&lt;/g, "<");
			t_text = t_text.replace(/&gt;/g, ">");
			t_text = t_text.replace(/&amp;/g, "&");
			var t_parameters = '?action=edit&format=json&title=' + encodeURIComponent( t_some_pages[t_Page].title ) +
					   '&summary=' + encodeURIComponent( t_summary ) + '&watch&basetimestamp=' + t_timestamp +
					   '&token=' + t_edittoken + '&bot=1' + '&text=' + encodeURIComponent( t_text );
			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", t_wikiurl + t_parameters, true);
			t_http_req.onreadystatechange = function() {
				if(t_http_req.readyState != 4) {
					document.getElementById('Status').innerHTML = ''+t_some_pages[t_Page].title+' wird mit '+t_text+' geschrieben ('+t_summary+') ...';
				}
				if(t_http_req.readyState == 4 && t_http_req.status == 200) {
					WrittenVKFile( eval("(" + t_http_req.responseText + ")") );
				}
			}
			t_http_req.send(null);
		}
	}
}

function WrittenVKFile( queryData ) {
	if ( queryData.edit && queryData.edit.result ) {
		document.getElementById('Status').innerHTML = queryData.edit.result;
		if ( t_stopp ) {
			document.getElementById('Status').innerHTML = "Auf Benutzerwunsch abgebrochen ...";
		} else {
			t_createnext++;
			CreateNextVKFile();
		}
	}
}
*/
/* ---------------------------------------------------- */
/* Script für Voreinstellungen beim Sperren und Löschen */
/* ---------------------------------------------------- */

addOnloadHook( function () {

	for ( var i = 0; i < document.getElementsByTagName( "A" ).length; i++ ) {
		if ( href = document.getElementsByTagName("A")[i].getAttribute("href") ) {
			Benutzer = href.split("Spezial:Sperren/");
			if ( Benutzer.length > 1 ) {
				document.getElementsByTagName("A")[i].setAttribute("href", href + "&wpBlockExpiry=infinite&wpBlockReason=spam");
			}
		}
	}

	if ( document.getElementById('ca-delete' ) ) {
		//if ( href = document.getElementById('ca-delete' ).firstChild.getAttribute("href") ) {
		//	document.getElementById('ca-delete' ).firstChild.setAttribute("href", href + "&wpReason=%0A");
		//}
	}
});

/* ---------------------------------------------------- */