MediaWiki:Gadget-FastRevert.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- The following documentation is located at MediaWiki:Gadget-FastRevert.js/documentation. [edit]
- This script is a part of the
FastRevert
gadget (edit definitions)- Description (edit): FastRevert: easily restore a previous version of a page.
- Useful links: subpage list • links • redirects
See also: Special:Gadgets.
/**
************* 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 [[Special:Contributions/' + user2 + '|' + user2 + ']]'
);
var user = mw.util.getParamValue('user');
document.getElementById('wpSummary').value = (message ? message + '; ' : '')
+ 'Restore to version ' + mw.util.getParamValue('oldid')
+ ' by [[Special:Contributions/' + user + '|' + user + ']]';
if (message != null) document.getElementById('editform').submit();
}
});