User:FunIsOptional/RestoreButton.js

$(document).ready( function {	if (mw.config.get('wgAction') === 'history') {   		var links = document.getElementsByClassName('mw-changeslist-links');   		for (var i = 3; i < links.length; i++) {   			// This stops anything other than the end links (undo & thank) from having a restore button, as the others have other classes   			if (links[i].className != 'mw-changeslist-links') {   				continue;   			}			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'); var revisionAuthor = links[i].parentNode.querySelector('.history-user').firstChild.firstChild.textContent; var editSummary = "Restored revision " + revisionId + " by " + revisionAuthor + " (RestoreButton)";

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

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