Jump to content

User:DerHexer/admin.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.
 // Originally from [[User:DerHexer]]
 // <nowiki>
 
 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) ? "&" + speichernp + "=1" : "";
   
   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) {
     var as = 
document.getElementById("bodyContent").getElementsByTagName("table")[0].getElementsByTagName("td")[1].getElementsByTagName("a");
     for (i=0; i<as.length; i++) {
       if (as[i].getAttributeNode("href").value.search(/\/wiki\/Special:Block\//) != -1) {
         lemma = as[i].getAttributeNode("title").value;
       }
     }
   }
   if (lemma == 'Special:Contributions') lemma = 'User:' + UrlParameters["target"].split('+').join('_');
   if (lemma == 'Special:Block') lemma = 'User:' + UrlParameters["ip"];
 
   if (lemma.match(/User:/) || lemma.match(/User_talk:/) || lemma.match(/Special:Contributions/)|| lemma.match(/Special:Block/)) { 
 
     // Wir müssen die Seite erst zum Editieren öffnen
     uri = 'http://en.wikipedia.org/w/index.php?title=Special:Block/' + encodeURIComponent( lemma.replace(/User:/, '').replace(/User_talk:/, '').replace(/Special:Contributions\//, '').replace(/Special:Block\//, '') )
             + "&blockreason=" + blockingreason
             + "&blockduration=" + blockingduration;
     if (UrlParameters["oldid"] > 0) {
       var as = document.getElementById("bodyContent").getElementsByTagName("table")[0].getElementsByTagName("td")[1].getElementsByTagName("a");
       if (as[6].childNodes[0].nodeValue == 'rollback' && 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 == 'rollback') {
           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) ? "&" + speichernp + "=1" : "";
 
   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 (lemma.search(/Special:Whatlinkshere\//) != -1) lemma = lemma.replace(/Special:Whatlinkshere\//, '');
  
   // Wir müssen die Seite erst zum Editieren öffnen
   uri = 'http://en.wikipedia.org/w/index.php?title=' + encodeURIComponent(lemma) + '&action=delete'
           + '&deletereason=Speedy deleted per ([[WP:CSD%23' + encodeURIComponent(deletereason.split("|")[0]) + '|CSD ' + encodeURIComponent(deletereason.split("|")[0]) + ']]), ' + encodeURIComponent(deletereason.split("|")[1].replace(/does not/, 'doesn\'t').replace(/did not/, 'didn\'t').replace(/was not/, 'wasn\'t').replace(/were not/, 'weren\'t').replace(/has not/, 'hasn\'t').replace(/have not/, 'haven\'t'))
           + speichernpa;
   location.href = uri;
 }
 
 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) ? "&" + speichernp + "=1" : "";
   if(!anotherprotecttype) anotherprotecttype = '';
 
   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('_');
  
   // Wir müssen die Seite erst zum Editieren öffnen
   uri = 'http://en.wikipedia.org/w/index.php?title=' + encodeURIComponent(lemma) + "&action=protect"
           + "&protectreason=" + encodeURIComponent(protectreason)
           + "&protectduration=" + encodeURIComponent(protectduration)
           + "&protecttype=" + encodeURIComponent(protecttype)
           + "&anotherprotecttype=" + encodeURIComponent(anotherprotecttype)
           + speichernpa;
   location.href = uri;
 }
 
 // </nowiki>