User:RiazACU/common.js

/*** Updated version of restorer Main author User:BrandonXLF $(function {	function restore (user, revid) {		var add_sum = prompt("Please add a reason (optional)");		if( add_sum === null ){			mw.notify('Cancelled restore action');		} else{		$.post( mw.config.get('wgScriptPath') + '/api.php', { action: 'edit', pageid: mw.config.get('wgArticleId'), undo: mw.config.get('wgCurRevisionId'), undoafter: revid,

summary: "Restored revision " + revid + " by " + user + ". " + add_sum + " (Restorer)",

token: mw.user.tokens.get('csrfToken'), format: 'json' })		.fail(function (a,b,c,d,e) { mw.notify('an error occurred while restore the revision.', {type:'error'}); })		.done(function (result) { if (result.error) { mw.notify(result.error.info, {type:'error'}); } else { mw.notify('revision restored successfully'); location.reload; }		});		}	} function addLink (item) {		var revid = item.getAttribute('data-mw-revid'), user, links, ele, parent;		if (revid != mw.config.get('wgCurRevisionId')) {			user = item.getElementsByClassName('mw-userlink')[0]. textContent.replace('User:','');			links = item.getElementsByClassName('mw-changeslist-links');			links = links[links.length - 1];			parent = document.createElement('span');			parent.classList.add("mw-history-undo");			ele = document.createElement('a');			ele.addEventListener('click', function { restore(user, revid); });			ele.innerHTML = 'Restorer';			parent.appendChild(ele);			links.appendChild(parent);		}	}	(function { if (location.search.includes('action=history')) { var i, parents = document.querySelectorAll('li[data-mw-revid]'); for (i = 0; i < parents.length; i++) { addLink(parents[i]); }		}	}); }); //

importScript('Wikipedia:AutoEd/complete.js') importScript('user:Qwertyytrewqqwerty/DisamAssist.js'); // Backlink: user:Qwertyytrewqqwerty/DisamAssist.js