User:Octalc0de/monobook.js

// /* View Source */

$(function {  if (location.href.indexOf('viewsource=1') != -1) {    sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl);    ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed);    return;  }  editbutton = document.getElementById('ca-edit');  if (editbutton && location.href.indexOf('action=edit')==-1) {    editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';    tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];    na = document.createElement('a');    na.href = editlink; na.appendChild(document.createTextNode('view source'));    li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);    tabs.insertBefore(li,editbutton);  } });

/* godmode-light.js */

// - // God-like Monobook skin // Forked from code (c) 2005 Sam Hocevar  // as downloaded from http://sam.zoy.org/wikipedia/godmode-light.js // Alterations (c) 2006 Martijn Pieters  // $Id$ // -

// - // Language support, taken from phase3/languages/* // - var messages = { rollbacklink: 'rollback', cantrollback: 'Cannot revert edit; last contributor is only author of ' + 'this page.', alreadyrolled: 'Cannot rollback last edit of $1 by $2 ' + '(Talk); someone else has edited or rolled back the ' + 'page already. Last edit was by $3 (Talk). ', revertpage: 'Reverted edit of $2 (talk), ' + 'changed back to last version by $1', pleasewait: 'Please wait, reverting edits by $1...', badtoken: 'Bad authentication token!', gettinghistory: 'Getting article history ($1)...', parsefailed: 'Failed to parse XML data returned by the server.', pagedump: 'Dump of the unparseable page: ', getform: 'Getting article edit form ($1)...', submitting: 'Submitting form...' } switch (document.getElementsByTagName('html')[0].lang) { case 'fr': messages.rollbacklink = 'révoquer'; messages.cantrollback = 'Impossible de révoquer : dernier auteur est le ' + 'seul à avoir modifié cet article'; messages.alreadyrolled = 'Impossible de révoquer la dernière ' + 'modification de « $1 » effectuée par $2 (Talk); quelqu\'un d\'autre à déjà modifer ou révoquer ' + 'l\'article. La dernière modificaion a été effectuée par ' + '$3 (Talk).'; messages.revertpage = 'restitution de la dernière modification de $1'; break; case 'de': messages.rollbacklink = 'Rollback'; messages.cantrollback = 'Die Änderung kann nicht zurückgenommen werden; ' + 'der letzte Autor ist der einzige.'; messages.alreadyrolled = 'Die Zurücknahme des Artikels $1 von ' + '$2 (Diskussion) ist nicht ' + 'möglich, da eine andere Änderung oder Rücknahme erfolgt ist. Die ' + 'letzte Änderung ist von $3 (Diskussion)'; messages.revertpage = 'Wiederhergestellt zur letzten Änderung von $1'; break; case 'es': messages.rollbacklink = 'Revertir'; messages.cantrollback = 'No se pueden revertir las ediciones; el ' + 'último colaborador es el único autor de este artículo.'; messages.alreadyrolled = 'No se puede revertir la última edición de ' + '$1 por $2 (Discusión); alguien más ya ha editado o revertido ' + 'esa página. La última edición fue hecha por $3 ' + '(Discusión). ';   messages.revertpage = 'Revertida a la última edición por $1'; break; case 'it': //messages.rollbacklink = 'Not defined for it'; messages.cantrollback = 'Impossibile tornare ad una versione ' + 'precedente: l\'ultima modifica è stata apportata dall\'unico utente ' + 'che abbia lavorato a questo articolo.'; //messages.alreadyrolled = 'Not defined for it'; messages.revertpage = 'Riportata alla revisione precedente da $1'; break; case 'pt': messages.rollbacklink = 'voltar'; messages.cantrollback = 'Não foi possível reverter a edição; o ' + 'último contribuidor é o único autor deste artigo.'; messages.alreadyrolled = 'Não foi possível reverter as edições de ' + '$1 por $2 (Talk); alguém o editou ' + 'ou já o reverteu. A última edição foi de $3 (Conversar com ele). ';   messages.revertpage = 'Revertido para a última edição por $1'; break; case 'nl': messages.rollbacklink = 'Terugdraaien'; messages.cantrollback = 'Ongedaan maken van wijzigingen onmogelijk: Dit ' + 'artikel heeft slechts 1 auteur.'; messages.alreadyrolled = 'Kan de laatste wijziging van $1 door ' + '$2 niet ongedaan maken; iemand anders heeft de pagina ' + 'gewijzigd of heeft de wijzigingen al ongedaan gemaakt. Laatste ' + 'wijziging was door $3 (Overleg). ';   messages.revertpage = 'Hersteld tot de versie na de laatste wijziging ' + 'door $1.'; break; }

// - // XMLHttpRequest support // - if (document.implementation.createDocument) { var gml_xmlparser = new DOMParser; }

function gml_XMLParse(string) { if (document.implementation.createDocument) { return gml_xmlparser.parseFromString(string, "text/xml"); } else if (window.ActiveXObject) { var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM"); gml_xmldoc.async = "false"; ret = gml_xmldoc.loadXML(string); if (!ret) return null; return gml_xmldoc.documentElement; } return null; }

var gml_xmlhttp;

function HTTPClient { var gml_http; if(window.XMLHttpRequest) { gml_http = new XMLHttpRequest; } else if (window.ActiveXObject) { try { gml_http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { gml_http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { gml_http = false; }   }  }  return gml_http; }

// - // MD5 hash calculator // - // 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. // - md5 = { _hexcase: 0, _chrsz: 8,

hex: function(s) { return this._binl2hex(     this._core(this._str2binl(s), s.length * this._chrsz)); },

_core: function(x, len) { 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 = this._ff(a, b, c, d, x[i+ 0], 7, -680876936); d = this._ff(d, a, b, c, x[i+ 1], 12, -389564586); c = this._ff(c, d, a, b, x[i+ 2], 17, 606105819); b = this._ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = this._ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = this._ff(d, a, b, c, x[i+ 5], 12,  1200080426); c = this._ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = this._ff(b, c, d, a, x[i+ 7], 22, -45705983); a = this._ff(a, b, c, d, x[i+ 8], 7 ,  1770035416); d = this._ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = this._ff(c, d, a, b, x[i+10], 17, -42063); b = this._ff(b, c, d, a, x[i+11], 22, -1990404162); a = this._ff(a, b, c, d, x[i+12], 7 ,  1804603682); d = this._ff(d, a, b, c, x[i+13], 12, -40341101); c = this._ff(c, d, a, b, x[i+14], 17, -1502002290); b = this._ff(b, c, d, a, x[i+15], 22,  1236535329);

a = this._gg(a, b, c, d, x[i+ 1], 5, -165796510); d = this._gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = this._gg(c, d, a, b, x[i+11], 14, 643717713); b = this._gg(b, c, d, a, x[i+ 0], 20, -373897302); a = this._gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = this._gg(d, a, b, c, x[i+10], 9 ,  38016083); c = this._gg(c, d, a, b, x[i+15], 14, -660478335); b = this._gg(b, c, d, a, x[i+ 4], 20, -405537848); a = this._gg(a, b, c, d, x[i+ 9], 5 ,  568446438); d = this._gg(d, a, b, c, x[i+14], 9 , -1019803690); c = this._gg(c, d, a, b, x[i+ 3], 14, -187363961); b = this._gg(b, c, d, a, x[i+ 8], 20,  1163531501); a = this._gg(a, b, c, d, x[i+13], 5 , -1444681467); d = this._gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = this._gg(c, d, a, b, x[i+ 7], 14,  1735328473); b = this._gg(b, c, d, a, x[i+12], 20, -1926607734);

a = this._hh(a, b, c, d, x[i+ 5], 4, -378558); d = this._hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = this._hh(c, d, a, b, x[i+11], 16, 1839030562); b = this._hh(b, c, d, a, x[i+14], 23, -35309556); a = this._hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = this._hh(d, a, b, c, x[i+ 4], 11,  1272893353); c = this._hh(c, d, a, b, x[i+ 7], 16, -155497632); b = this._hh(b, c, d, a, x[i+10], 23, -1094730640); a = this._hh(a, b, c, d, x[i+13], 4 ,  681279174); d = this._hh(d, a, b, c, x[i+ 0], 11, -358537222); c = this._hh(c, d, a, b, x[i+ 3], 16, -722521979); b = this._hh(b, c, d, a, x[i+ 6], 23,  76029189); a = this._hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = this._hh(d, a, b, c, x[i+12], 11, -421815835); c = this._hh(c, d, a, b, x[i+15], 16,  530742520); b = this._hh(b, c, d, a, x[i+ 2], 23, -995338651);

a = this._ii(a, b, c, d, x[i+ 0], 6, -198630844); d = this._ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = this._ii(c, d, a, b, x[i+14], 15, -1416354905); b = this._ii(b, c, d, a, x[i+ 5], 21, -57434055); a = this._ii(a, b, c, d, x[i+12], 6 ,  1700485571); d = this._ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = this._ii(c, d, a, b, x[i+10], 15, -1051523); b = this._ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = this._ii(a, b, c, d, x[i+ 8], 6 ,  1873313359); d = this._ii(d, a, b, c, x[i+15], 10, -30611744); c = this._ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = this._ii(b, c, d, a, x[i+13], 21,  1309151649); a = this._ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = this._ii(d, a, b, c, x[i+11], 10, -1120210379); c = this._ii(c, d, a, b, x[i+ 2], 15,  718787259); b = this._ii(b, c, d, a, x[i+ 9], 21, -343485551);

a = this._safe_add(a, olda); b = this._safe_add(b, oldb); c = this._safe_add(c, oldc); d = this._safe_add(d, oldd); }   return Array(a, b, c, d); },

_cmn: function(q, a, b, x, s, t) { return this._safe_add(this._bit_rol(this._safe_add(this._safe_add(a, q), this._safe_add(x, t)), s),b); }, _ff: function(a, b, c, d, x, s, t) { return this._cmn((b & c) | ((~b) & d), a, b, x, s, t); }, _gg: function(a, b, c, d, x, s, t) { return this._cmn((b & d) | (c & (~d)), a, b, x, s, t); }, _hh: function(a, b, c, d, x, s, t) { return this._cmn(b ^ c ^ d, a, b, x, s, t); }, _ii: function(a, b, c, d, x, s, t) { return this._cmn(c ^ (b | (~d)), a, b, x, s, t); },

_safe_add: function(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); },

_bit_rol: function(num, cnt) { return (num << cnt) | (num >>> (32 - cnt)); },

_str2binl: function(str) { var bin = Array; var mask = (1 << this._chrsz) - 1; for(var i = 0; i < str.length * this._chrsz; i += this._chrsz) bin[i>>5] |= (str.charCodeAt(i / this._chrsz) & mask) << (i%32); return bin; },

_binl2hex: function(binarray) { var hex_tab = this._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; } }

// - // Helper function for i18n text // - var _placeholder = /\$(\d+)/; function _(msgid) { // Additional arguments are used to replace $N placeholders in the text, // starting at $1. text = messages[msgid] || msgid; while (_placeholder.test(text)) { var index = _placeholder.exec(text)[1]; var replacement = '[no replacement text given]'; if (index > 0 && index < arguments.length) replacement = arguments[index]; text = text.replace(_placeholder, replacement); } return text; }

// - // Simple MediaWiki markup expander // - // link and title var _mw_link = /]+)(?:|\|([^\+))]]/; function mw_expand(text) { while (_mw_link.test(text)) { var match = _mw_link.exec(text); var link = match[1]; var title = match[2]; if (!title) { title = link; title.replace('\s+\([^\)]*\)', );            // Hide parenthesized page qualifiers      title.replace('^[^:]+:', );                   // Hide namespace    }    link = link.replace(' ', '_');                    // Replace spaces with underscores    link = link[0].toUpperCase + link.substring(1); // Uppercase first character    link = '' + title + ''    text = text.replace(_mw_link, link)  }  return text }

// - // Our nice Revert functions // - var gml_vandal, gml_editor, gml_url;

function PerformRevert { 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 == 'token') { token = unescape(l[i].substring(n + 1)); } else if (name == 'title') { gml_url += '?' + l[i]; } }  if (!revert) return; document.getElementById('bodyContent').innerHTML = mw_expand(_('pleasewait', gml_vandal)); // Avoid XSS kiddies by using a special token if (token == '' || token != md5.hex(gml_url + gml_vandal + document.cookie)) { document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('badtoken')); return; }

gml_xmlhttp = HTTPClient; if (!gml_xmlhttp) return; history_url = gml_url + '&action=history&limit=50'; document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('gettinghistory', history_url)); gml_xmlhttp.open("GET", history_url, true); gml_xmlhttp.onreadystatechange = RevertStepTwo; gml_xmlhttp.send(null); }

function RevertStepTwo { if (gml_xmlhttp.readyState != 4) return; var l; var oldid; // Get the vandal and new editor names gml_vandal = gml_vandal.replace(/_/g, ' '); gml_editor = ''; // Hack for a MediaWiki bug xml = gml_xmlhttp.responseText.replace(//, ''); doc = gml_XMLParse(xml); if (!doc || !doc.getElementById('pagehistory')) { document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('parsefailed')); document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('pagedump')) + ' ' + xml.replace(/&/g, '&amp;').replace(//g, '&gt;'); 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) { title = gml_url.substring(gml_url.indexOf('title=') + 6); document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('alreadyrolled', title, gml_vandal, name)); return; } else if (i > 0 && name != gml_vandal) { oldid = l[i].getElementsByTagName('input')[0].value; gml_editor = name; break; } }  if (gml_editor == '') { document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('cantrollback')); return; }

gml_xmlhttp = HTTPClient; if (!gml_xmlhttp) return; editform_url = gml_url + '&action=edit&oldid=' + oldid; document.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('getform', 'GET ' + editform_url)); gml_xmlhttp.open('GET', editform_url, true); gml_xmlhttp.onreadystatechange = RevertStepThree; gml_xmlhttp.send(null); }

function RevertStepThree { if (gml_xmlhttp.readyState != 4) return var form, newform, l; // Insert the downloaded form in our current page, using // only hidden form inputs. doc = gml_XMLParse(gml_xmlhttp.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') { l[i].value = _('revertpage', 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’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.getElementById('bodyContent').innerHTML += ' ' + mw_expand(_('submitting')); document.getElementById('bodyContent').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.getElementById('bodyContent').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].href; if (vandal.indexOf('Special:Contributions') > -1) { vandal = vandal.substring(vandal.indexOf('target=') + 7); } else { vandal = vandal.substring(vandal.indexOf('User:') + 5); }     var t = l[i].innerHTML n = t.indexOf(') ) = 0 && article != '' && toplink.indexOf('oldid=') == -1) { l[i].innerHTML = t.substring(0, n + 5) + '   [' + _('rollbacklink') + '] ' + t.substring(n + 5, t.length); }   }  }  // 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 == 4) { vandal = a[0].innerHTML; } else { vandal = c.innerHTML.replace(/ \(.*/, ).replace(/.* /, );   }    l = document.getElementById('bodyContent').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('>' + _('rollbacklink') + ']') != -1)          break;      //if (t.indexOf('&amp;diff=0') != -1) {      if (t.indexOf(' (') != -1) { article = l[i].getElementsByTagName('a')[0].href.split('&')[0].replace(/[^\/]*\/\/[^\/]*/, ''); l[i].innerHTML += ' [' + _('rollbacklink') + ']'; }   }  } }

// - // Modify the page once it is loaded // - if (window.addEventListener) { window.addEventListener("load", PerformRevert, false); window.addEventListener("load", AddRevertButtons, false); } else if (window.attachEvent) { window.attachEvent("onload", PerformRevert); window.attachEvent("onload", AddRevertButtons); } //