Jump to content

User:FunIsOptional/RestoreButton.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by FunIsOptional (talk | contribs) at 07:58, 3 August 2022 (Created page with '$(document).ready( function () { if (mw.config.get('wgAction') === 'history') { var links = document.getElementsByClassName('mw-changeslist-links'); for (var i = 0; i < links.length; i++) { var restoreSpan = document.createElement('span'); var restoreA = document.createElement('a'); var revisionId = links[i].parentNode.getAttribute(data-mw-revid); var pageTitle = mw.config.get('wgPageName'); restoreA.setAttribute('href', '//en.wi...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
$(document).ready( function () {
	if (mw.config.get('wgAction') === 'history') {
   		var links = document.getElementsByClassName('mw-changeslist-links');
   		for (var i = 0; i < links.length; i++) {
			var restoreSpan = document.createElement('span');
			var restoreA = document.createElement('a');

			var revisionId = links[i].parentNode.getAttribute(data-mw-revid);
			var pageTitle = mw.config.get('wgPageName');

			restoreA.setAttribute('href', '//en.wikipedia.org/w/index.php?title={pageTitle}&oldid={revisionId}&action=edit');
			restoreA.textContent = 'restore';

			restoreSpan.appendChild(restoreA);
       		links[i].appendChild(restoreSpan);
   		}
	}	
});