MediaWiki:Gadget-FastRevert.js

/** ************* FastRevert ******************* * Allows one to restore an old version    * *                                         * * Author: Quentinv57, for Wikimedia        * *         -- 06 Feb. 2010 --              * ******************************************** */

$( document ).ready( function { 	if (mw.util.getParamValue('action') === 'history') {		var chemin = '//en.wiktionary.org/w/index.php?action=edit&retablir';		var pageHistory = document.getElementById('pagehistory');        pageHistory = pageHistory && pageHistory.getElementsByTagName('li');        var prevUser;        for (var i = 0; i < pageHistory.length; i++) {            var li = pageHistory[i];            var oldid = li.dataset.mwRevid; // data-mw-revid="..."            var userLink = li.querySelector(".history-user .mw-userlink");            // Get inside of bdi tag if it's present.            while (userLink.firstElementChild) {                userLink = userLink.firstElementChild;            }            var username = userLink.textContent;			if (i !== 0) {				var revertLink = document.createElement( "a" );				revertLink.href = chemin + '&oldid=' + oldid + '&user=' + username + '&user2=' + prevUser; revertLink.appendChild( document.createTextNode( "FastRevert" ) ); li.appendChild( document.createTextNode( " \u2014 (" ) );				li.appendChild( revertLink );				li.appendChild( document.createTextNode( ")" ) ); }           prevUser = username; }   } else if (location.href.match(/&retablir&/)) { var user2 = mw.util.getParamValue('user2'); var message = prompt(           'What message do you want to leave?',            'Reverted edits by ' + user2 + ''        ); var user = mw.util.getParamValue('user'); document.getElementById('wpSummary').value = (message ? message + '; ' : '') + 'Restore to version ' + mw.util.getParamValue('oldid') + ' by ' + user + ''; if (message != null) document.getElementById('editform').submit; } });