Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
// [[User:quarl/rollback.js]] - rollback button for non-admins// requires util.js, md5.js, wikipage.js, wikiedit.js// based on http://sam.zoy.org/wikipedia/godmode-light.js// - more robust (works with Popups, etc)// - factored code// <pre><nowiki>// -----------------------------------------------------------------------------// God-like Monobook skin// (c) 2005 Sam Hocevar <sam@zoy.org>// Forked from: Id: godmode-light.js 980 2005-11-12 01:51:51Z sam // -----------------------------------------------------------------------------// -----------------------------------------------------------------------------// Language support, taken from phase3/languages/*// -----------------------------------------------------------------------------varrollbacklink='rollback';varcantrollback='Cannot revert edit; last contributor is only author of this page.';varalreadyrolled='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]]). ';varrevertpage='Reverted edits by [[User:$2|$2]] ([[User talk:$2|t]]) ([[Special:Contributions/$2|c]]) to last version by $1';// -----------------------------------------------------------------------------// Our nice Revert functions// -----------------------------------------------------------------------------vargml_vandal,gml_editor;functionrollback_Revert(){if(typeofqueryVars==='undefined')return;vartoken=queryVars['token'];gml_vandal=queryVars['vandal'];document.cont=document.getElementById('bodyContent');document.cont.innerHTML='Please wait, reverting edits by '+gml_vandal+'...';// Avoid XSS kiddies by using a special tokenif(!token||token!=rollback_mkToken(wikiPage,gml_vandal)){document.cont.innerHTML+='ERROR: Bad authentication token!';return;}document.getElementById('bodyContent').innerHTML+='<br />Getting article history...';asyncDownloadXML(wikiPage.qurl+'&action=history&limit=50',rollback_Revert2);}// Get the vandal and new editor namesfunctionrollback_parseHistory(doc){varl=doc.getElementById('pagehistory').getElementsByTagName('li');for(i=0;i<l.length;i++){varname=l[i].getElementsByTagName('span')[0].getElementsByTagName('a')[0].innerHTML.replace(/_/g,' ');if(!name)continue;if(i==0){if(name!=gml_vandal){document.cont.innerHTML+='<br />Error: Last editor is '+name+', not '+gml_vandal+'!';return{};}}else{if(name!=gml_vandal){varoldid=l[i].getElementsByTagName('input')[0].value;vareditor=name;return{'oldid':oldid,'editor':editor};}}}return{};}functionrollback_Revert2(xmlhttp){doc=xmlhttp.responseXML;varr=rollback_parseHistory(doc);varoldid=r.oldid;gml_editor=r.editor;if(!gml_editor){document.cont.innerHTML+='<br />Error: '+gml_vandal+' is the only editor!';return;}varurl=wikiPage.qurl+'&action=edit&oldid='+oldid;document.cont.innerHTML+='<br />Getting article edit form...';asyncDownloadXML(url,rollback_Revert3);}functionrollback_Revert3(xmlhttp){summary_text=revertpage.replace(/\$1/g,gml_editor).replace(/\$2/g,gml_vandal);document.cont.innerHTML+='<br />Submitting form...';varwd=newWikiDocument(xmlhttp.responseXML,wikiPage);vareditor=newWikiEditor(wd);editor.wpSummary=summary_text;editor.submit();}functionrollback_mkToken(wp,vandal){returnhex_md5(wp.page+'%'+vandal+'%'+document.cookie);}functionrollback_mkUrl(wp,vandal){returnurl_getpath(wp.qurl+'&fakeaction=rollback&vandal='+escape(vandal)+'&token='+escape(rollback_mkToken(wp,vandal)));}// -----------------------------------------------------------------------------// Add revert buttons to the page// -----------------------------------------------------------------------------functionrollback_AddButtonDiff(){if(wikiDoc.editingP)return;// preview diff pages will also be edit pages and shouldn't have rollback buttonsvardifftag=getElementsByClass('diff-ntitle',document.getElementById('bodyContent'),'td')[0];if(!difftag)return;// if toplink has an oldid then this is not a diff against current revision.vartoplink=difftag.getElementsByTagName('a')[0].href;if(toplink.match(/oldid=/))return;varvandal=getUsernameFromLink(difftag.getElementsByTagName('a')[1]);if(!vandal){alert("Couldn't parse username in diff page!");return;}varurl=rollback_mkUrl(wikiPage,vandal);varnewtext=' <strong>[<a href="'+url+'">'+rollbacklink+'</a>]</strong> ';difftag.innerHTML=difftag.innerHTML.replace(/(<\/a>\))( *<br)/i,'$1'+newtext+'$2');}functionrollback_AddButtonContributions(){if(wikiPage.page!='Special:Contributions')return;varvandal=relevantUser;// defined in wikipage.jsif(!vandal)return;varl=document.getElementById('bodyContent').getElementsByTagName('li');for(i=0;i<l.length;i++){vart=l[i].innerHTML;// If we are already a sysop on this wiki, abortif(t.match(/>rollback<\/a>]/))return;if(t.match(/<strong> \(/)){varwp=newWikiPage(l[i].getElementsByTagName('a')[0].href);varurl=rollback_mkUrl(wp,vandal);l[i].innerHTML+=' [<a href="'+url+'">'+rollbacklink+'</a>]';}}}functionrollback_Load(){if(typeofqueryVars==='undefined')return;if(queryVars['fakeaction']=='rollback'){rollback_Revert();}else{rollback_AddButtonDiff();rollback_AddButtonContributions();}}$(rollback_Load);// </nowiki></pre>