Benutzer:WWWIG/monobook.js: Unterschied zwischen den Versionen

Aus Watch-Wiki
Zur Navigation springen Zur Suche springen
(+ kat)
 
(96 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 2: Zeile 2:
 
// my_vkdebug = true;
 
// my_vkdebug = true;
  
addOnloadHook( function () {
+
importScript('MediaWiki:Gadget-CheckRCForm.js');
    LoadTemCatGenForm();
+
importScript('MediaWiki:Gadget-CatGenRepairForm.js');
 +
 
 +
if ( wgAction=="edit" &&
 +
  ( wgNamespaceNumber==0 || wgNamespaceNumber==10 ) )
 +
addOnloadHook(function() {
 +
 +
  if ( t_Position = document.getElementById( 'firstHeading' ) ) {
 +
 +
      var t_NewElement = document.createElement('input');
 +
      t_NewElement.setAttribute( 'id', 'mw-new-element' );
 +
      t_NewElement.setAttribute( 'type', 'button' );
 +
      t_NewElement.setAttribute( 'onclick', 'do_new_action();' );
 +
 +
      t_Position.insertBefore( t_NewElement, t_Position.firstChild );
 +
      t_Position.insertBefore( document.createTextNode( ' ' ), t_Position.firstChild );
 +
  }
 
});
 
});
  
var t_wikiurl = wgServer + wgScriptPath + '/api.php';
+
function do_new_action() {
var t_Files = new Array();
+
  if ( !document.getElementById( 'wpTextbox1' ) ) return;
var t_FilesChecked = new Array();
+
  var t_Inhalt = document.getElementById( 'wpTextbox1' ).value;
var t_processnext = 0;
+
  var t_Template = '';
 
+
  var t_Sprache = '';
t_blackwordlist = new Array(
+
  if ( t_Inhalt.indexOf('{{Andere Sprachen|') != -1 ) {
'comment',
+
      t_Template = 'Andere Sprachen';
'porn',
+
      t_Sprache = 'de';
'angel',
+
  } else
'fire',
+
  if ( t_Inhalt.indexOf('{{andere Sprachen|') != -1 ) {
'sex',
+
      t_Template = 'andere Sprachen';
'animal',
+
      t_Sprache = 'de';
'movies',
+
  } else
'film',
+
  if ( t_Inhalt.indexOf('{{другие языки|') != -1 ) {
'gift',
+
      t_Template = 'другие языки';
'free',
+
      t_Sprache = 'ru';
'self',
+
  } else
'young',
+
  if ( t_Inhalt.indexOf('{{Andere talen|') != -1 ) {
'donna',
+
      t_Template = 'Andere talen';
'teens',
+
      t_Sprache = 'nl';
'girls',
+
  } else
'craig',
+
  if ( t_Inhalt.indexOf('{{andere talen|') != -1 ) {
'generic',
+
      t_Template = 'andere talen';
'extend',
+
      t_Sprache = 'nl';
'discount',
+
  } else
'pills',
+
  if ( t_Inhalt.indexOf('{{Other languages|') != -1 ) {
'insurance',
+
      t_Template = 'Other languages';
'life',
+
      t_Sprache = 'en';
'valium',
+
  } else
'robaxin',
+
  if ( t_Inhalt.indexOf('{{other languages|') != -1 ) {
'vimax',
+
      t_Template = 'other languages';
'xtreme',
+
      t_Sprache = 'en';
'bodybuilding',
+
  } else
'tits',
+
  if ( t_Inhalt.indexOf('{{Andere Sprachen|') != -1 ) {
'total',
+
      t_Template = 'Andere Sprachen';
'gym',
+
      t_Sprache = '';
'reverse',
+
  } else {
'number'
+
      alert( 'Vorlage nicht gefunden!' );
);
+
      return;
 
+
  }
function LoadTemCatGenForm() {
 
 
 
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 ) {
 
 
 
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 {
 
}
 
}
 
}
 
 
 
document.getElementById( 'InsertRCForm' ).innerHTML = '<hr style="margin-top:1em;"><ul>';
 
CheckTitles();
 
}
 
 
 
function CheckBadWord( t_text ) {
 
 
 
if ( t_text ) {
 
for ( t_Word = 0; t_Word < t_blackwordlist.length; t_Word++ ) {
 
if ( String( t_text ).indexOf( t_blackwordlist[t_Word] ) != -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 ( ( t_PositionStart = t_Inhalt.indexOf( '{{'+t_Template+'|' ) ) != -1 ) {
if ( queryData.block && queryData.block.blocktoken ) {
+
      t_PositionEnd = t_Inhalt.indexOf('}}', t_PositionStart );
var t_token = queryData.block.blocktoken;
+
      var t_Andere_Sprachen = t_Inhalt.slice( t_PositionStart, t_PositionEnd + 2 );
  
var t_parameters = '?action=block&format=json&user=' +
+
      // alert( 't_Andere_Sprachen' + t_Andere_Sprachen );
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);
 
}
 
}
 
  
 +
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen + '\r\n', '' );
 +
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen + '\r', '' );
 +
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen + '\n', '' );
 +
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen, '' );
  
 +
      t_Andere_Sprachen = t_Andere_Sprachen.replace( '}}', '' );
 +
      var t_Interwikis = t_Andere_Sprachen.split("|[[");
 +
      var t_InterwikiAusgabe = '';
  
}
+
      for ( var i = 1; i < t_Interwikis.length; i++ ) {
 +
          t_Interwikis[i] = t_Interwikis[i].replace( ']]', '' );
 +
          var t_Interwiki = t_Interwikis[i].split("|");
 +
          if ( t_Interwiki[1] && ( t_Interwiki[1] != t_Sprache || t_Interwiki[0] != wgTitle ) ) {
 +
            t_InterwikiAusgabe += '[[' + t_Interwiki[1] + ':' + t_Interwiki[0] + ']]\r\n';
 +
          }
 +
      }
 +
      t_Inhalt += t_InterwikiAusgabe;
 +
 
 +
      // alert( 'Go' + t_InterwikiAusgabe );
  
function DeleteTitlesProcessed( queryData, rawData ) {
+
      document.getElementById( 'wpTextbox1' ).value = t_Inhalt;
  
if ( queryData['delete'] ) {
+
      document.editform.wpSummary.value = 'Vorlage '+t_Template+' in Interwikis getauscht';
if ( queryData['delete'].title && queryData['delete'].reason ) {
+
      document.editform.wpMinoredit.checked = true;
document.getElementById( 'Status' ).innerHTML += '<br>' + queryData['delete'].title + '<br>' + queryData['delete'].reason;
+
      document.editform.submit();
t_processnext++;
+
  }
if ( t_processnext < t_Files.length ) {
 
CheckTitles();
 
} else {
 
    t_processnext = 0;
 
CheckUsers();
 
}
 
}
 
} else {
 
document.getElementById( 'Status' ).innerHTML += '<br>Unbekannter Fehler ' + rawData;
 
}
 
document.getElementById( 'InsertRCForm' ).innerHTML += '</ul>';
 
 
}
 
}

Aktuelle Version vom 17. August 2011, 06:54 Uhr

/* -- */
// my_vkdebug = true;

importScript('MediaWiki:Gadget-CheckRCForm.js');
importScript('MediaWiki:Gadget-CatGenRepairForm.js');

if ( wgAction=="edit" &&
   ( wgNamespaceNumber==0 || wgNamespaceNumber==10 ) )
addOnloadHook(function() {
 
   if ( t_Position = document.getElementById( 'firstHeading' ) ) {
 
      var t_NewElement = document.createElement('input');
      t_NewElement.setAttribute( 'id', 'mw-new-element' );
      t_NewElement.setAttribute( 'type', 'button' );
      t_NewElement.setAttribute( 'onclick', 'do_new_action();' );
 
      t_Position.insertBefore( t_NewElement, t_Position.firstChild );
      t_Position.insertBefore( document.createTextNode( ' ' ), t_Position.firstChild );
   }
});

function do_new_action() {
   if ( !document.getElementById( 'wpTextbox1' ) ) return;
   var t_Inhalt = document.getElementById( 'wpTextbox1' ).value;
   var t_Template = '';
   var t_Sprache = '';
   if ( t_Inhalt.indexOf('{{Andere Sprachen|') != -1 ) {
      t_Template = 'Andere Sprachen';
      t_Sprache = 'de';
   } else
   if ( t_Inhalt.indexOf('{{andere Sprachen|') != -1 ) {
      t_Template = 'andere Sprachen';
      t_Sprache = 'de';
   } else
   if ( t_Inhalt.indexOf('{{другие языки|') != -1 ) {
      t_Template = 'другие языки';
      t_Sprache = 'ru';
   } else
   if ( t_Inhalt.indexOf('{{Andere talen|') != -1 ) {
      t_Template = 'Andere talen';
      t_Sprache = 'nl';
   } else
   if ( t_Inhalt.indexOf('{{andere talen|') != -1 ) {
      t_Template = 'andere talen';
      t_Sprache = 'nl';
   } else
   if ( t_Inhalt.indexOf('{{Other languages|') != -1 ) {
      t_Template = 'Other languages';
      t_Sprache = 'en';
   } else
   if ( t_Inhalt.indexOf('{{other languages|') != -1 ) {
      t_Template = 'other languages';
      t_Sprache = 'en';
   } else
   if ( t_Inhalt.indexOf('{{Andere Sprachen|') != -1 ) {
      t_Template = 'Andere Sprachen';
      t_Sprache = '';
   } else {
      alert( 'Vorlage nicht gefunden!' );
      return;
   }

   if ( ( t_PositionStart = t_Inhalt.indexOf( '{{'+t_Template+'|' ) ) != -1 ) {
      t_PositionEnd = t_Inhalt.indexOf('}}', t_PositionStart );
      var t_Andere_Sprachen = t_Inhalt.slice( t_PositionStart, t_PositionEnd + 2 );

      // alert( 't_Andere_Sprachen' + t_Andere_Sprachen );

      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen + '\r\n', '' );
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen + '\r', '' );
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen + '\n', '' );
      t_Inhalt = t_Inhalt.replace( t_Andere_Sprachen, '' );

      t_Andere_Sprachen = t_Andere_Sprachen.replace( '}}', '' );
      var t_Interwikis = t_Andere_Sprachen.split("|[[");
      var t_InterwikiAusgabe = '';

      for ( var i = 1; i < t_Interwikis.length; i++ ) {
          t_Interwikis[i] = t_Interwikis[i].replace( ']]', '' );
          var t_Interwiki = t_Interwikis[i].split("|");
          if ( t_Interwiki[1] && ( t_Interwiki[1] != t_Sprache || t_Interwiki[0] != wgTitle ) ) {
             t_InterwikiAusgabe += '[[' + t_Interwiki[1] + ':' + t_Interwiki[0] + ']]\r\n';
          }
      }
      t_Inhalt += t_InterwikiAusgabe;
  
      // alert( 'Go' + t_InterwikiAusgabe );

      document.getElementById( 'wpTextbox1' ).value = t_Inhalt;

      document.editform.wpSummary.value = 'Vorlage '+t_Template+' in Interwikis getauscht';
      document.editform.wpMinoredit.checked = true;
      document.editform.submit();
   }
}