Benutzer:DerHexer/admin.js
Zur Navigation springen
Zur Suche springen
Hinweis: Leere nach dem Veröffentlichen 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
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
// Dient dem Löschen, Sperren und Schützen
// Ursprünglich von [[Benutzer:DerHexer]]
// <nowiki>
if(!allowlogblock) var allowlogblock = false;
if(!blockedtext) var blockedtext = 'Zwei Stunden';
if(!disallowwhatlinkshere) var disallowwhatlinkshere = false;
if(!warningafterdeletion) var warningafterdeletion = false;
// API request for delete token; made by [[User:Codeispoetry]]
function newRequest()
{
try {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else {
return new ActiveXObject("MSXML2.XMLHTTP");
}
} catch (e) {
return false;
}
}
// get URL parameters (used for page type variables)
var UrlParameters = new Array ();
readparams();
function readparams() {
var asReadInUrlParameters;
var asReadInUrlParameter;
// Get URL parameters
asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
for (i = 0; i < asReadInUrlParameters.length; i++) {
asReadInUrlParameter = asReadInUrlParameters[i].split("=");
UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
}
}
// token functions
function generate_auser () {
return encodeURIComponent(mw.config.get('wgUserName'));
}
function validate_auser (auser) {
var retval = false;
if (encodeURIComponent(auser) == generate_auser() )
retval = true;
return retval;
}
function generate_atime () {
var arbitrary_datestamp = Date.UTC(2008,10,1,0,0,0,0); // 1.11.2008
var current_date = new Date();
var current_timestamp = current_date.getTime();
return ( Math.floor((current_timestamp - arbitrary_datestamp) / 1000) );
}
function validate_atime (atime) {
var retval = false;
var timediff = generate_atime() - atime;
if ((timediff >= 0) && (timediff < 45))
retval = true;
return retval;
}
function blocking(blockingreason, blockingduration) { // DerHexer
// Variables that should be defined in your monobook
if (typeof(autosave) == 'undefined')
autosave = false;
if (typeof(isPHP ) == 'undefined')
isPHP = (document.URL.indexOf('index.php') > 0);
var speichernpa = (autosave) ? "&auser=" + generate_auser() + "&atime=" + generate_atime() : "";
var lemma;
if ( UrlParameters["title"] > "" )
lemma = UrlParameters["title"];
else
lemma = decodeURIComponent(location.href.substring(location.href.indexOf("/wiki/") + 6)).split('#')[0];
if (isPHP) lemma=lemma.split('+').join('_');
if ((UrlParameters["oldid"] > 0) || (UrlParameters["diff"] > 0)) {
if(!isArticle){
var as =
document.getElementById("bodyContent").getElementsByTagName("table")[0].getElementsByTagName("td")[1].getElementsByTagName("a");
} else {
var as =
document.getElementById("bodyContent").getElementsByTagName("table")[1].getElementsByTagName("td")[1].getElementsByTagName("a");
}
for (i=0; i<as.length; i++) {
if (as[i].getAttributeNode("href").value.search(/\/wiki\/Spezial:Sperren\//) != -1) {
lemma = as[i].getAttributeNode("title").value;
}
}
}
if (lemma == 'Spezial:Beiträge') lemma = 'Benutzer:' + UrlParameters["target"].split('+').join('_');
if (lemma == 'Spezial:Sperren') lemma = 'Benutzer:' + UrlParameters["ip"];
if (lemma == 'Spezial:Logbuch') lemma = UrlParameters["page"];
if (lemma.match(/Benutzer:/) || lemma.match(/Benutzer_Diskussion:/) || lemma.match(/Spezial:Beiträge/)|| lemma.match(/Spezial:Sperren/)|| lemma.match(/Spezial:Gelöschte.Beiträge/)) {
// prompt, wenn Begründung geändert werden soll
if (blockingreason == 'prompt') {
blockingreason = prompt('Sperrbegründung:','');
}
if (blockingduration == 'prompt') {
blockingduration = prompt('Sperrdauer:','');
}
// Wir müssen die Seite erst zum Editieren öffnen
var replacedlemma = lemma.replace(/Benutzer:/, '').replace(/Benutzer_Diskussion:/, '').replace(/Spezial:Beiträge\//, '').replace(/Spezial:Sperren\//, '').replace(/Spezial:Gelöschte.Beiträge\//,'');
if ((replacedlemma != 'Beiträge') && (replacedlemma != 'Undefined')) {
var speichernpa = "&auser=" + generate_auser() + "&atime=" + generate_atime();
uri = '//de.wikipedia.org/w/index.php?title=Spezial:Sperren/' + encodeURIComponent( replacedlemma )
+ "&blockreason=" + blockingreason
+ "&blockduration=" + blockingduration;
+ speichernpa;
if (UrlParameters["oldid"] > 0) {
if(!isArticle){
var as =
document.getElementById("bodyContent").getElementsByTagName("table")[0].getElementsByTagName("td")[1].getElementsByTagName("a");
} else {
var as =
document.getElementById("bodyContent").getElementsByTagName("table")[1].getElementsByTagName("td")[1].getElementsByTagName("a");
}
if (as[6].childNodes[0].nodeValue == 'Zurücksetzen' && lemma.search(/\d+\.\d+\.\d+\.\d+/) != -1) {
uri = uri + speichernpa;
window.open(uri);
} else if (lemma.search(/\d+\.\d+\.\d+\.\d+/) == -1) {
if (as[7].childNodes[0].nodeValue == 'Zurücksetzen') {
window.open(uri);
} else {
location.href = uri;
}
} else {
uri = uri + speichernpa;
location.href = uri;
}
} else {
uri = uri + speichernpa;
location.href = uri;
}
}
}
}
function deleting(deletereason) { // DerHexer
// Variables that should be defined in your monobook
if (typeof(autosave) == 'undefined')
autosave = false;
if (typeof(isPHP ) == 'undefined')
isPHP = (document.URL.indexOf('index.php') > 0);
var speichernpa = (autosave) ? "&auser=" + generate_auser() + "&atime=" + generate_atime() : "";
var lemma = mw.config.get('wgPageName');
if (lemma == 'Spezial:Linkliste') lemma = document.getElementById('contentSub').getElementsByTagName('a')[0].innerHTML;
if (deletereason == 'prompt') {
deletereason = prompt('Löschbegründung:','');
if (trim(deletereason) == null) return;
} else if ((deletereason == 'nuke') && (mw.config.get('wgUserName') == 'DerHexer') && (mw.config.get('wgPageName') == 'Spezial:Beiträge')) {
var lemma2 = new Array();
var lis = document.getElementsByTagName('li');
var index = 0;
for(i=0;i<lis.length;i++) {
if(lis[i].getElementsByTagName('abbr')[0] && (lis[i].getElementsByTagName('abbr')[0].getAttribute('class') == 'newpage')) {
//alert(lis[i].getElementsByTagName('a')[0].getAttribute('title'));
lemma2[index] = lis[i].getElementsByTagName('a')[1].getAttribute('title');
index++;
}
}
}
// Normal UI request for deletion
var req2 = newRequest();
if (!req2)
return;
if ((deletereason == 'nuke') && (mw.config.get('wgUserName') == 'DerHexer') && (mw.config.get('wgPageName') == 'Spezial:Beiträge')) {
var nukereason = prompt('Nukebegründung:','');
// alert(lemma2.length);
// alert(lemma2[0]);
for(i=0;i<lemma2.length;i++){
// API request for delete token
var req = newRequest();
if (!req)
return;
req.open("GET", "/w/api.php?format=xml&action=query&meta=tokens&type=csrf");
req.send("");
var token = req.responseXML.getElementsByTagName("tokens")[0].getAttribute("csrftoken");
if (!token)
return;
var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/api.php?action=delete&title=" + lemma2[i].replace(/\s/g, "%20").replace(/\&/g, "%26").replace(/\"/g, "%22").replace(/\+/g, "%2B").replace(/\#/g, "%23") + "&reason=" + encodeURIComponent(nukereason);
req2.open("POST", url, true);
req2.setRequestHeader('Content-type','application/x-www-form-urlencoded');
req2.send(url + "&token=" + encodeURIComponent(token));
if(i==(lemma2.length-1)){
req2.onreadystatechange = function() {
if(req2.readyState == 4) {
document.getElementById('firstHeading').setAttribute('style', 'background-color:green;');
document.getElementById('firstHeading').innerHTML = 'Diese Seite wurde erfolgreich gelöscht.';
}
}
}
}
} else {
lemma = lemma.replace(/ /g, "%20").replace(/&/g, "%26").replace(/\"/g, "%22").replace(/\+/g, "%2B");
var req4;
if (req4 = newRequest()) {
var text = "/w/api.php?format=xml&action=query&prop=info&inprop=protection&titles=" + lemma;
req4.open("GET", text, false);
req4.send("");
var revisions = req4.responseXML.getElementsByTagName("pr");
if (!revisions[0]) {
var req5;
if (req5 = newRequest()) {
var text = "/w/api.php?format=xml&action=query&list=logevents&letype=delete&letitle=" + lemma;
req5.open("GET", text, false);
req5.send("");
var items = req5.responseXML.getElementsByTagName("item");
if ((items.length == 0) || (items.length > 0 && (items[0].getAttribute('action') != 'restore'))) {
var nobacklinks = false;
var req3;
if (req3 = newRequest()) {
req3.open("GET", "/w/api.php?format=xml&action=query&list=backlinks&bllimit=1&bltitle="+lemma, false);
req3.send("");
var linked = req3.responseXML.getElementsByTagName("bl");
if (linked.length == 0) {
var nobacklinks = true;
}
}
// API request for delete token
var req = newRequest();
if (!req)
return;
req.open("GET", "/w/api.php?format=xml&action=query&meta=tokens&type=csrf", false);
req.send("");
var token = req.responseXML.getElementsByTagName("tokens")[0].getAttribute("csrftoken");
if (!token)
return;
var req4;
if (req4 = newRequest()) {
var text = "/w/api.php?format=xml&action=query&prop=revisions&titles=" + lemma + "&rvlimit=10&rvstart=20000000000000&rvdir=newer&rvprop=user";
req4.open("GET", text, false);
req4.send("");
var revisions = req4.responseXML.getElementsByTagName("rev");
if (revisions[0] && warningafterdeletion && (revisions.length < 10)) {
var firstuser = revisions[0].getAttribute("user");
if (firstuser.match(/\d+\.\d+\.\d+\.\d+/)) {
var uri = "//de.wikipedia.org/w/index.php?title=Benutzer_Diskussion:" + firstuser + "&action=edit&warnuser=1";
window.setTimeout(function() { window.open(uri); }, 500);
}
}
}
var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/api.php?action=delete&title=" + lemma + "&reason=" + encodeURIComponent(deletereason.replace(/\%7C/g,'|'));
req2.open("POST", url, true);
req2.setRequestHeader('Content-type','application/x-www-form-urlencoded');
req2.send(url + "&token=" + encodeURIComponent(token));
req2.onreadystatechange = function() {
if(req2.readyState == 4)
if(!disallowwhatlinkshere && !nobacklinks && mw.config.get('wgNamespaceNumber') == '0') {
location.href = '//de.wikipedia.org/w/index.php?title=Spezial:Linkliste/'+lemma+'&articlecreatedby='+firstuser;
} else {
document.getElementById('firstHeading').setAttribute('style', 'background-color:green;');
document.getElementById('firstHeading').innerHTML = 'Diese Seite wurde erfolgreich gelöscht';
}
}
} else {
document.getElementById('firstHeading').setAttribute('class', 'recentlyrestored');
document.getElementById('firstHeading').setAttribute('style', 'text-decoration: blink; background-color:red;');
document.getElementById('firstHeading').innerHTML = 'Diese Seite wurde zuletzt wiederhergestellt.';
}
}
} else {
document.getElementById('firstHeading').setAttribute('class', 'protectedpage');
document.getElementById('firstHeading').setAttribute('style', 'text-decoration: blink; background-color:red;');
document.getElementById('firstHeading').innerHTML = 'Geschützte Seite.';
}
}
}
}
function protecting(protectreason, protectduration, protecttype, anotherprotecttype) { // DerHexer
// Variables that should be defined in your monobook
if (typeof(autosave) == 'undefined')
autosave = false;
if (typeof(isPHP ) == 'undefined')
isPHP = (document.URL.indexOf('index.php') > 0);
var speichernpa = (autosave) ? "&auser=" + generate_auser() + "&atime=" + generate_atime() : "";
if(!anotherprotecttype) anotherprotecttype = '';
var lemma = mw.config.get('wgPageName');
if (protectreason == 'prompt') {
protectreason = prompt('Schutzbegründung:','');
}
if (protectduration == 'prompt') {
protectduration = prompt('Schutzdauer:','');
}
// Wir müssen die Seite erst zum Editieren öffnen
uri = '//de.wikipedia.org/w/index.php?title=' + encodeURIComponent(lemma) + "&redirect=no&action=protect"
+ "&protectreason=" + encodeURIComponent(protectreason)
+ "&protectduration=" + encodeURIComponent(protectduration)
+ "&protecttype=" + encodeURIComponent(protecttype)
+ "&anotherprotecttype=" + encodeURIComponent(anotherprotecttype)
+ speichernpa;
location.href = uri;
}
function newprotect(protectreason) { // DerHexer
if (mw.config.get('wgUserName') == 'DerHexer') {
// Variables that should be defined in your monobook
if (typeof(autosave) == 'undefined')
autosave = false;
if (typeof(isPHP ) == 'undefined')
isPHP = (document.URL.indexOf('index.php') > 0);
var speichernpa = (autosave) ? "&auser=" + generate_auser() + "&atime=" + generate_atime() : "";
var lemma = mw.config.get('wgPageName');
// Wir müssen die Seite erst zum Editieren öffnen
uri = '//de.wikipedia.org/w/index.php?title=' + encodeURIComponent(lemma) + "&redirect=no&action=protect"
+ "&newprotectreason=1"
+ speichernpa;
location.href = uri;
}
}
function doblock() {
if (UrlParameters["blockreason"] != "abcxyz") {
document.getElementsByName('wpReason-other')[0].value = UrlParameters["blockreason"];
} else {
document.getElementsByName('wpReason-other')[0].value = "[[Hilfe:Anmelden#Hinweise_zur_Wahl_des_Benutzernamens|Ungeeigneter Benutzername]]";
document.getElementsByName('wpDisableEmail')[0].checked=true;
}
if (UrlParameters["blockduration"].match(/\s/) || UrlParameters["blockduration"] == 'infinite' || UrlParameters["blockduration"] == 'indefinite') {
document.getElementsByName('wpExpiry-other')[0].value = UrlParameters["blockduration"];
} else if (UrlParameters["blockduration"].match(/\d+/)) {
document.getElementsByName('wpExpiry-other')[0].value = UrlParameters["blockduration"] + " hours";
}
if ((UrlParameters["blockduration"] == 'infinite') || (UrlParameters["blockduration"] == 'indefinite')) {
document.getElementsByName('wpDisableUTEdit')[0].checked=false;
}
var req;
if (req = newRequest()) {
var text = "/w/api.php?format=xml&action=query&list=logevents&letype=block&letitle=User:" + UrlParameters["title"].replace(/Spezial\:Sperren\//, '');
req.open("GET", text, false);
req.send("");
var blocks = req.responseXML.getElementsByTagName("block");
if (blocks.length < 3) {
if ((UrlParameters["title"].search(/\d+\.\d+\.\d+\.\d+/) != -1) || (UrlParameters["blockreason"] == 'abcxyz')) {
if (!document.getElementsByTagName('h2')[0] || (document.getElementsByTagName('ul')[0] && document.getElementsByTagName('ul')[0].innerHTML.search(/bereits.gesperrt/)!=-1)) {
if (validate_auser (UrlParameters["auser"])) {
if (validate_atime (UrlParameters["atime"])) {
var inputlength = document.getElementsByTagName('fieldset')[0].getElementsByTagName('input').length;
window.setTimeout(function() { document.getElementsByTagName('fieldset')[0].getElementsByTagName('input')[inputlength-1].click(); }, 500);
} else {
alert("Token zur automatischen Speicherung ist abgelaufen.");
}
}
}
}
} else {
document.getElementById('firstHeading').setAttribute('class', 'ipyetthreetimesblocked');
document.getElementById('firstHeading').setAttribute('style', 'text-decoration: blink; background-color:red;');
document.getElementById('firstHeading').innerHTML = 'Diese IP wurde schon mehr als dreimal gesperrt.';
}
}
}
if (UrlParameters["blockreason"] && UrlParameters["blockduration"]) $(doblock);
function doprotect() {
document.getElementById("mwProtect-reason").value = UrlParameters["protectreason"];
document.getElementById("mwProtectExpirySelection-edit").selectedIndex = 0;
document.getElementById("mwProtectExpirySelection-move").selectedIndex = 0;
document.getElementById("mwProtect-edit-expires").value = UrlParameters["protectduration"];
document.getElementById("mwProtect-move-expires").value = UrlParameters["protectduration"];
document.getElementById("mwProtect-level-edit").selectedIndex = UrlParameters["protecttype"];
if (UrlParameters["anotherprotecttype"] != '') {
document.getElementById("mwProtect-level-move").selectedIndex = UrlParameters["anotherprotecttype"];
} else {
document.getElementById("mwProtect-level-move").selectedIndex = UrlParameters["protecttype"];
}
if (validate_auser (UrlParameters["auser"])) {
if (validate_atime (UrlParameters["atime"])) {
document.getElementById('mw-Protect-submit').click();
if (mw.config.get('wgUserName') == "DerHexer") window.setTimeout(function() { window.close(); }, 500);
} else {
alert("Token zur automatischen Speicherung ist abgelaufen.");
}
}
}
if (UrlParameters["protectreason"] && UrlParameters["protectduration"] && UrlParameters["protecttype"]) $(doprotect);
function erlvm(){
if (document.editform.wpTextbox1.value.search(/==([^\d]*\d+\.\d+\.\d+\.\d+[^\d]*)==/) != -1) {
if ((document.editform.wpTextbox1.value.search(/\(erl\.\)[\s]*==/) == -1) && (document.editform.wpTextbox1.value.search(/\(erledigt\)[\s]*==/) == -1)) {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/==([^\d]*\d+\.\d+\.\d+\.\d+[^\d]*)==/, "==$1(erl.) ==");
document.editform.wpSummary.value = document.editform.wpSummary.value + "erl";
var req;
if (req = newRequest()) {
var checkip = document.editform.wpTextbox1.value.match(/==[^\d]*(\d+\.\d+\.\d+\.\d+)[^\d]*==/);
var checkip2 = RegExp.$1;
var text = "/w/api.php?format=xml&action=query&list=logevents&letype=block&letitle=User:" + checkip2;
req.open("GET", text, false);
req.send("");
if ((req.responseXML.getElementsByTagName("block").length != 0) && (req.responseXML.getElementsByTagName("item").length != 0)) {
var lastblock = req.responseXML.getElementsByTagName("block")[0].getAttribute('duration');
var lastuser = req.responseXML.getElementsByTagName("item")[0].getAttribute('user');
if (lastuser == mw.config.get('wgUserName')) {
insertTagsWrapper(':', ' ' + usersignature, lastblock);
} else {
var newblockedtext = 'Gesperrt von ' + lastuser + ' mit der Dauer „' + lastblock + '“.';
insertTagsWrapper(':', ' ' + usersignature, newblockedtext);
}
} else {
insertTagsWrapper(':', ' ' + usersignature, blockedtext);
}
}
}
}
}
if ((mw.config.get('wgPageName') == "Wikipedia:Vandalismusmeldung") && (UrlParameters["section"] > '')) $(erlvm);
function warnafterdeletion(){
document.forms["editform"].wpWatchthis.checked=false;
if (document.forms["editform"].wpTextbox1.value == "") {
document.editform.wpSummary.value = "Hinweis";
document.forms["editform"].wpTextbox1.value = "\{\{subst:Gelöscht\}\} " + usersignature;
document.editform.wpSave.click();
window.setTimeout(function() { window.close(); }, 1500);
} else {
var speichernpa = "&auser=" + generate_auser() + "&atime=" + generate_atime();
var blockurl = "//de.wikipedia.org/w/index.php?title=Spezial:Sperren/" + mw.config.get('wgTitle') + "&blockduration=2&blockreason=Erstellt unsinnige Artikel"+speichernpa;
window.setTimeout(function() { location.href = blockurl; }, 500);
}
}
if (UrlParameters["warnuser"]) $(warnafterdeletion);
function createlinksonbacklinks() { // DerHexer
var placetoadd = document.getElementsByTagName('fieldset')[1].getElementsByTagName('a')[2];
var newlink = document.createElement('a');
newlink.setAttribute('href', mw.config.get('wgServer')+'/w/index.php?title=Special:Block&wpBlockAddress='+UrlParameters['articlecreatedby']+'&wpBlockReason=Erstellt%20unsinnige%20Artikel&wpBlockOther=2%20hours');
var EditTextNode = document.createTextNode("Sperre den Ersteller des Artikels");
newlink.appendChild(EditTextNode);
placetoadd.parentNode.insertBefore( newlink, placetoadd.nextSibling );
placetoadd.parentNode.insertBefore( document.createTextNode(' | '), placetoadd.nextSibling );
var newlink2 = document.createElement('a');
newlink2.setAttribute('href', mw.config.get('wgServer')+'/wiki/Spezial:Wiederherstellen/'+document.getElementById('mw-whatlinkshere-target').getAttribute('value').replace(/\s/g, "%20").replace(/\&/g, "%26").replace(/\"/g, "%22").replace(/\+/g, "%2B").replace(/\#/g, "%23"));
var EditTextNode = document.createTextNode("Wiederherstellen");
newlink2.appendChild(EditTextNode);
placetoadd.parentNode.insertBefore( newlink2, placetoadd.nextSibling );
placetoadd.parentNode.insertBefore( document.createTextNode(' | '), placetoadd.nextSibling );
}
if ((mw.config.get('wgCanonicalSpecialPageName') == 'Whatlinkshere') && (UrlParameters['articlecreatedby'])) $(createlinksonbacklinks);
function dcp(dcpreason, dcpduration, dcptype, dcpcontent, dcpbeginning) { // DerHexer
var userName = mw.config.get('wgUserName');
if (userName == 'DerHexer' || userName == 'Pfalzfrank' || userName == 'Complex' || userName == 'Sinn' || userName == 'FritzG' || userName == 'Pill') {
// Variables that should be defined in your monobook
if (typeof(autosave) == 'undefined')
autosave = false;
if (typeof(isPHP ) == 'undefined')
isPHP = (document.URL.indexOf('index.php') > 0);
var speichernpa = (autosave) ? "&auser=" + generate_auser() + "&atime=" + generate_atime() : "";
var lemma = mw.config.get('wgPageName');
switch (dcpbeginning) {
case "0" : var actiontype = "delete";break;
case "1" : var actiontype = "edit";break;
case "2" : var actiontype = "protect";break;
}
// Wir müssen die Seite erst zum Editieren öffnen
uri = '//de.wikipedia.org/w/index.php?title=' + encodeURIComponent(lemma) + "&redirect=no&action=" + actiontype
+ "&dcpreason=" + encodeURIComponent(dcpreason)
+ "&dcpduration=" + encodeURIComponent(dcpduration)
+ "&dcptype=" + encodeURIComponent(dcptype)
+ "&dcpcontent=" + encodeURIComponent(dcpcontent)
+ "&dcp=" + encodeURIComponent(dcpbeginning)
+ speichernpa;
location.href = uri;
}
}
if(!allowlogblock) mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:DerHexer/logblock.js&action=raw&ctype=text/javascript'); // [[Benutzer:DerHexer/logblock.js]]
// </nowiki>