Benutzer:Guidod/Automation/wikipedia.rollback.code.js
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
// ----------------------------------------------------------------------- 100 -*- java -*-
// Wikipedia Rollback Buttons
// (c) 2006 Guido Draheim <guidod@gmx.de>
// Version: 2006-07-11
// Quelle: http://guidod.homelinux.org/greasemonkey/
// Lizenz: http://creativecommons.org/licenses/by-nc-sa/2.0/de/
// - based on / basierend auf:
// God-like Monobook skin
// (c) 2005 Sam Hocevar <sam@zoy.org>
// Version: 2006-04-03 20:25:37Z
// ----------------------------------------------------------------------
function document_get_lang() {
return document.getElementsByTagName('html')[0].lang;
}
function document_content() {
return document.getElementById('bodyContent');
}
// --------------------------------------------------------------------------
// Language support, taken from phase3/languages/*
// --------------------------------------------------------------------------
var LinkRollback = 'rollback';
var LinkVandal = 'vandal';
var LinkWeird = 'weird';
var LinkDisk = 'disk';
var NoRollbackFirst =
'Cannot revert edit; last contributor is only author of this page.';
var NoRollbackAlreadyDone =
'Cannot rollback last edit of [[$1]] by [[User:$2|$2]] ([[User talk:$2|Talk]]);'
+' someone else has edited or rolled back the page already.'
+' Last edit was by [[User:$3|$3]] ([[User talk:$3|Talk]]). ';
var MsgRevert =
'Reverted edits by [[Special:Contributions/$2|$2]], back to last version by $1';
var MsgVandal =
'Reverted vandalism by [[Special:Contributions/$2|$2]], back to last version by $1';
var MsgWeird =
'Reverted wrong stuff by [[Special:Contributions/$2|$2]], back to last version by $1';
var MsgDisk = ', see talk page!';
var StartingRevert =
'Please wait, reverting edits by [$1]...';
var BadToken =
'Bad authentication token!';
var GettingHistory =
'Getting article history ($1)...';
var HistoryParseFailed = ""
+'<br />Failed to parse XML data returned by the server.<br /><b>Hint:'
+' try to disable both "Enable section editing by right-clicking on section titles (JavaScript)"'
+' and "Edit pages on double click (JavaScript)" in your editing preferences'
+' until a proper fix is found</b>.'
+'<br />Dump of the unparseable page : <br />$1';
var LastEditorChanged =
+'Error: Last editor is [$1], not [$2]!';
var LastEditorIsFirst =
'Error: $1 is the only editor!';
var GettingEditForm =
'Getting article edit form ($1)...';
var SubmitEditForm =
'Submitting edited article form...';
switch (document_get_lang()) {
case 'fr':
LinkRollback = 'révoquer';
LinkVandal = 'vandalisme';
LinkWeird = 'maltraitise';
LinkDisk = 'discussion';
NoRollbackFirst = 'Impossible de révoquer:'
+' dernier auteur est le seul à avoir modifié cet article';
NoRollbackAlreadyDone =
'Impossible de révoquer la dernière modification de [[$1]] par [[User:$2|$2]]'
+' ([[User talk:$2|Talk]]); quelqu\'un d\'autre à déjà modifer ou révoquer l\'article.'
+' La dernière modificaion était de [[User:$3|$3]] ([[User talk:$3|Talk]]). ';
MsgRevert = "Révocation des modifications de [[Special:Contributions/$2|$2]]"
+" en arrviant a la précédente version de $1";
MsgVandal = "Révocation du vandalisme de [[Special:Contributions/$2|$2]]"
+" en arrivant a la précédente version de $1";
MsgWeird = "Révocation du maltraitise de [[Special:Contributions/$2|$2]]"
+" en arrivant a la précédente version de $1";
MsgDisk = ", voir discussion!";
break;
case 'de':
LinkRollback = 'Revert';
LinkVandal = 'Vandal';
LinkWeird = 'Unfug';
LinkDisk = 'Disku';
NoRollbackFirst =
'Die Änderung kann nicht zurückgenommen werden;'
+' der letzte Autor ist der einzige.';
NoRollbackAlreadyDone =
'Die Zurücknahme des Artikels [[$1]] von [[Benutzer:$2|$2]]'
+' ([[Benutzer Diskussion:$2|Diskussion]]) ist nicht möglich,'
+' da eine andere Änderung oder Rücknahme erfolgt ist.'
+' Die letzte Änderung ist von [[Benutzer:$3|$3]] ([[Benutzer Diskussion:$3|Diskussion]])';
MsgRevert = 'Revert Änderungen von [[Spezial:Contributions/$2|$2]]'
+' auf letzte Version von [[Spezial:Contributions/$1|$1]]';
MsgVandal = 'Revert Vandalismus von [[Spezial:Contributions/$2|$2]]'
+' auf letzte Version von [[Spezial:Contributions/$1|$1]]';
MsgWeird = 'Revert Unfug von [[Spezial:Contributions/$2|$2]]'
+' auf letzte Version von [[Spezial:Contributions/$1|$1]]';
MsgDisk = ', siehe Diskussion!';
StartingRevert = 'Bitte warten, Revert ist unterwegs für Änderungen von [$1]...';
BadToken = 'Prüfsumme zur Authentifizierung ist falsch!';
GettingHistory = 'Hole jetzt die Versionsgeschichte ($1)...';
HistoryParseFailed = ""
+'<br />Konnte die XML Ausgabe des Serves nicht parsen.<br /><b>Beachte: Das Abschalten'
+' von "Enable section editing by right-clicking on section titles (JavaScript)"'
+' und "Edit pages on double click (JavaScript)" in your editing preferences'
+' kann hilfreich sein.</b>.'
+'<br />Der problematische Text ist: <br />$1';
LastEditorChanged = 'Fehler: Der letzte Autor ist [$1], statt erwartetem [$2]!';
LastEditorIsFirst = 'Fehler: $1 ist der einzige Autor!';
GettingEditForm = 'Hole jetzt das Edit-Formular des Artikels ($1)...';
SubmitEditForm = 'Sende jetzt das Edit-Formular zurück...';
break;
case 'es':
LinkRollback = 'Revertir';
LinkVandal = 'Revertir';
LinkWeird = 'Revertir';
LinkDisk = 'Revertir';
NoRollbackFirst = 'No se pueden revertir las ediciones;'
+' el último colaborador es el único autor de este artículo.';
NoRollbackAlreadyDone =
'No se puede revertir la última edición de [[$1]] por [[Colaborador:$2|$2]]'
+' ([[Colaborador Discusión:$2|Discusión]]); alguien más ya ha editado o revertido'
+' esa página. La última edición'
+' fue hecha por [[Colaborador:$3|$3]] ([[Colaborador Discusión:$3|Discusión]]). ';
MsgRevert = 'Revertida a la última edición de $1';
MsgVandal = 'Revertida a la última edición de $1';
MsgWeird = 'Revertida a la última edición de $1';
MsgDisk = ', discussion!';
break;
case 'it':
LinkRollback = 'rollback';
LinkVandal = 'rollback';
LinkWeird = 'rollback';
NoRollbackFirst = 'Impossibile tornare ad una versione precedente: l\'ultima modifica'
+' è stata apportata dall\'unico utente che abbia lavorato a questo articolo.';
//NoRollbackAlreadyDone = '';
MsgRevert = 'Riportata alla revisione precedente da $1';
MsgVandal = 'Riportata alla revisione precedente da $1';
MsgWeird = 'Riportata alla revisione precedente da $1';
MsgDisk = ', discussion!';
break;
case 'pt':
LinkRollback = 'voltar';
LinkVandal = 'voltar';
LinkWeird = 'voltar';
LinkDisk = 'voltar';
NoRollbackFirst = 'Não foi possível reverter a edição;'
+' o último contribuidor é o único autor deste artigo.';
NoRollbackAlreadyDone = 'Não foi possível reverter as edições de [[$1]] por [[User:$2|$2]]'
+' ([[User talk:$2|Talk]]); alguém o editou ou já o reverteu. A última edição'
+' foi de [[User:$3|$3]] ([[User talk:$3|Conversar com ele]]). ';
MsgRevert = 'Revertidas edições por [[Special:Contributions/$2|$2]],'
+' para a última versão por $1';
MsgVandal = 'Revertidas edições por [[Special:Contributions/$2|$2]],'
+' para a última versão por $1';
MsgWeird = 'Revertidas edições por [[Special:Contributions/$2|$2]],'
+' para a última versão por $1';
MsgDisk = ', discussion!';
break;
}
// ================================================================ Formatter
function str1(format, arg1) {
return format.replace(/\$1/g, arg1);
}
function str2(format, arg1, arg2) {
return format.replace(/\$1/g, arg1).replace(/\$2/g, arg2);
}
function str3(format, arg1, arg2, arg3) {
return format.replace(/\$1/g, arg1).replace(/\$2/g, arg2).replace(/\$3/g, arg3);
}
function str_code(text) {
return xml.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
}
// ================================================================ XML HELPER ==
function gml_XMLParse(string) {
if (document.implementation.createDocument) {
var xmlparser = new DOMParser();
return xmlparser.parseFromString(string, "text/xml");
} else if (window.ActiveXObject) {
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = "false";
ret = xmldoc.loadXML(string);
if (! ret) return null;
return xmldoc.documentElement;
}
return null;
}
function new_XMLHttpRequest() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
return false;
}
}
}
return false;
}
// ================================================================ MD5 HELPER ==
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
// ================================================================ THE SCRIPT ==
var gml_vandal, gml_editor, gml_url, gml_reason;
function TryPerformRevert() {
var l, token = '', revert = false;
// Look for '&fakeaction=rollback' in URL
gml_url = location.pathname;
l = location.search.substring(1).split('&');
for (i = 0; i < l.length; i++) {
var n = l[i].indexOf('=');
var name = l[i].substring(0, n);
if (name == 'fakeaction') {
if (l[i].substring(n + 1) == 'rollback')
revert = true;
} else if (name == 'vandal') {
gml_vandal = unescape(l[i].substring(n + 1));
} else if (name == 'reason') {
gml_reason = unescape(l[i].substring(n + 1));
} else if (name == 'token') {
token = unescape(l[i].substring(n + 1));
} else if (name == 'title') {
gml_url += '?' + l[i];
}
}
if (! revert) { return; }
if (token == '' || token != hex_md5(gml_url + gml_vandal + document.cookie)) {
// Avoid XSS kiddies by using a hash token
document_content().innerHTML += '<br />'+BadToken;
return;
}
RevertStepOne();
}
function RevertStepOne() {
document_content().innerHTML = str1(StartingRevert, gml_vandal);
var http = new_XMLHttpRequest(); if (! http) return;
var history_url = gml_url + '&action=history&limit=50';
document_content().innerHTML += '<br />'+str1(GettingHistory, history_url);
http.open("GET", history_url, true);
http.onreadystatechange = function() {
if (http.readyState == 4) RevertStepTwo(http);
}
http.send(null);
}
function RevertStepTwo(details) {
var l;
var oldid;
// Get the vandal and new editor names
gml_vandal = gml_vandal.replace(/_/g, ' ');
gml_editor = '';
xml = details.responseText.replace(/<body.*"ns-4">/, '<body class="ns-4">');
doc = gml_XMLParse(xml);
if (! doc || ! doc.getElementById('pagehistory')) { // Hack for a MediaWiki bug
document_content().innerHTML += str1(HistoryParseFailed, str_code(xml));
return;
}
l = doc.getElementById('pagehistory').getElementsByTagName('li');
//l = doc.selectSingleNode('//*[@id="pagehistory"]').getElementsByTagName('li');
for (i = 0; i < l.length; i++) {
var name = l[i].getElementsByTagName('span')[0]
.getElementsByTagName('a')[0].innerHTML.replace(/_/g, ' ');
if (i == 0 && name != gml_vandal) {
document_content().innerHTML += '<br />'+str2(LastEditorChanged, name, gml_vandal);
return;
} else if (i > 0 && name != gml_vandal) {
oldid = l[i].getElementsByTagName('input')[0].value;
gml_editor = name;
break;
}
}
if (gml_editor == '') {
document_content().innerHTML += '<br />'+str1(LastEditorIsFirst, gml_vandal);
return;
}
var http = new_XMLHttpRequest(); if (! http) return;
next_url = gml_url + '&action=edit&oldid=' + oldid;
document_content().innerHTML += '<br />'+str1(GettingEditForm, next_url);
http.open('GET', next_url, true);
http.onreadystatechange = function() {
if (http.readyState == 4) RevertStepThree(http);
}
http.send(null);
}
function RevertStepThree(details) {
var form, newform, l;
// Insert the downloaded form in our current page, using
// only hidden form inputs.
doc = gml_XMLParse(details.responseText);
form = doc.getElementById('editform');
newform = document.createElement('form');
l = form.getElementsByTagName('textarea');
for (i = l.length; i--; ) {
var t = document.createElement('input');
t.type = 'hidden';
t.name = l[i].name;
t.value = l[i].value;
newform.appendChild(t);
}
l = form.getElementsByTagName('input');
for (i = l.length; i--; ) {
if (l[i].name == 'wpSummary') {
if (gml_reason == 'vandal') {
l[i].value = str2(MsgVandal, gml_editor, gml_vandal);
} else if (gml_reason == 'weird') {
l[i].value = str2(MsgWeird, gml_editor, gml_vandal);
} else if (gml_reason == 'disk') {
l[i].value = str2(MsgRevert, gml_editor, gml_vandal);
l[i].value += MsgDisk;
} else {
l[i].value = str2(MsgRevert, gml_editor, gml_vandal);
}
} else if (l[i].name == 'wpMinoredit') {
l[i].value = '1';
} else if (l[i].name == 'wpWatchthis') {
if (!l[i].checked)
continue; // Don�$-1òùt touch the "watch" status
l[i].value = "on";
} else if (l[i].name == 'wpPreview') {
continue;
} else if (l[i].name == 'wpDiff') {
continue;
}
l[i].type = 'hidden';
newform.appendChild(l[i]);
}
newform.name = form.name;
newform.method = form.method;
newform.id = form.id;
newform.action = form.action;
document_content().innerHTML += '<br />'+SubmitEditForm;
document_content().appendChild(newform);
// Submit the form
newform.submit();
}
// -----------------------------------------------------------------------------
// Add revert buttons to the page
// -----------------------------------------------------------------------------
function AddRevertButtons() {
var l, article = '', vandal;
// Add 'revert' links to a diff page
l = document_content().getElementsByTagName('td');
for (i = 0; i < l.length; i++) {
if (l[i].className == 'diff-otitle') {
article = l[i].getElementsByTagName('a')[0]
.href.split('&')[0].replace(/[^\/]*\/\/[^\/]*/, '');
} else if (l[i].className == 'diff-ntitle') {
var toplink = l[i].getElementsByTagName('a')[0].href;
// vandal = l[i].getElementsByTagName('a')[1].title.split(':')[1];
vandal = l[i].getElementsByTagName('a')[2].innerHTML;
var tt = l[i].innerHTML;
var nn = tt.indexOf('</a>) <br') + tt.indexOf('</A>) <BR') + 1; // XXX: WOW HACK!!!!
var n2 = tt.indexOf('</span><br />') + tt.indexOf('</SPAN><BR />')
+ tt.indexOf('</span><br>') + tt.indexOf('</SPAN><BR>') +3;
var n3 = tt.indexOf('<br /><br />') + tt.indexOf('<BR /><BR />')
+ tt.indexOf('<br><br>') + tt.indexOf('<BR><BR>') +3;
if (n2 > 0) { nn = n2 + 6; x = ":"; }
if (n3 > 0) { nn = n3 + 3; x = ","; }
if (nn >= 0 && article != '' && toplink.indexOf('oldid=') == -1) {
var token = hex_md5(article + vandal + document.cookie);
l[i].innerHTML = tt.substring(0, nn + 5)
+ ' <strong>'
+ '[<a href="' +article+ '&fakeaction=rollback&reason=reset&vandal=' +vandal
+ '&token=' +token+ '">' +LinkRollback+ '</a>]'
+ '[<a href="' +article+ '&fakeaction=rollback&reason=vandal&vandal=' +vandal
+ '&token=' +token+ '">' +LinkVandal+ '</a>]'
+ '[<a href="' +article+ '&fakeaction=rollback&reason=weird&vandal=' +vandal
+ '&token=' +token+ '">' +LinkWeird+ '</a>]'
+ '[<a href="' +article+ '&fakeaction=rollback&reason=disk&vandal=' +vandal
+ '&token=' +token+ '">' +LinkDisk+ '</a>]'
+ '</strong> '+ tt.substring(nn + 5);
}
}
}
// Add 'revert' links to a contributions page
if (location.href.indexOf(':Contributions') != -1) {
var c = document.getElementById('contentSub');
var a = c.getElementsByTagName('a');
if (a.length >= 2) {
vandal = a[0].innerHTML;
} else {
vandal = c.innerHTML.replace(/ \(.*/, '').replace(/.* /, '');
}
l = document_content().getElementsByTagName('li');
for (i = 0; i < l.length; i++) {
var t = l[i].innerHTML;
// If we are already a sysop on this wiki, abort
if (t.indexOf('>' + LinkRollback + '</a>]') != -1)
break;
if (t.indexOf('<strong> (') != -1) {
var token = hex_md5(article + vandal + document.cookie);
article = l[i].getElementsByTagName('a')[0]
.href.split('&')[0].replace(/[^\/]*\/\/[^\/]*/, '');
l[i].innerHTML += ' [<a href="' +article+ '&fakeaction=rollback&vandal=' +vandal
+ '&token=' +token+ '">' + LinkRollback + '</a>]';
}
}
}
}
function AddLoadHint() {
var elem = document.getElementById('contentSub');
if (! elem) return;
elem.innerHTML += " (loaded)";
}
// -----------------------------------------------------------------------------
// Modify the page once it is loaded
// -----------------------------------------------------------------------------
if (window.addEventListener) {
window.addEventListener("load", TryPerformRevert, false);
window.addEventListener("load", AddRevertButtons, false);
window.addEventListener("load", AddLoadHint, false);
} else if (window.attachEvent) {
window.attachEvent("onload", TryPerformRevert);
window.attachEvent("onload", AddRevertButtons);
window.attachEvent("onload", AddLoadHint);
}