varundoComment=newfunction(){varoldrev,newrevthis.onLoad=function(){//get undo revisionsoldrev=document.URL.match(/&undoafter=(\d+)/)[1]newrev=document.URL.match(/&undo=(\d+)/)[1]if(!oldrev||!newrev)return//append new summary buttonvarbuts=document.getElementById('userSummaryButtonsA')if(!buts)returna=document.createElement('a')a.innerHTML='отмена…'a.href='javascript:undoComment.Go()'buts.appendChild(a)}this.Go=function(){apiRun(insertSummary,'query&prop=revisions&rvlimit=10&rvprop=ids|user&titles='+encodeURIComponent(mw.config.get('wgPageName'))+'&rvstartid='+newrev)}functioninsertSummary(response){data=responsetry{eval('q='+response)}catch(e){return}if(!q||!q.query||!(q.query.pages))returnalert('Непонятный ответ с сервера')vari,authors='',po=-1,pn=-1,hist=anyChild(q.query.pages).revisions//find revisionsfor(i=hist.length-1;i>=0;i--)if(hist[i].revid==oldrev)po=ifor(i=po;i>=0;i--)if(hist[i].revid==newrev)pn=iif(po<0||pn<0)returnalert('Старая версия не найдена в десяти предшествующих правках')//find all usersfor(i=pn;i<po;i++)if(authors.indexOf([hist[i].user])==-1)authors+=((authors=='')?'':', ')+[hist[i].user]document.getElementById('wpSummary').value='Отмена '+(po-pn)+' правок '+((authors.indexOf(',')==-1)?'['+'[User:'+authors+'|'+authors+']]':'('+authors+')')+', возврат к версии '+oldrev+' участника '+hist[po].user+' : '}functionapiRun(func,params){varajax=sajax_init_object()ajax.onreadystatechange=function(){if(ajax.readyState!=4)returnif(ajax.status==200){func(ajax.responseText)}elsefunc(null)}ajax.open('GET','/w/api.php?format=json&action='+params,true)//ajax.setRequestHeader('Accept','text/*')ajax.send(null)}functionanyChild(obj){for(varkeyinobj)returnobj[key];returnnull;}}if((mw.config.get('wgAction')=='edit'||mw.config.get('wgAction')=='submit')&&document.URL.indexOf('undo=')!=-1)$(undoComment.onLoad)