Jump to content

User:SD0001/edits-since-decline.js

From Wikipedia, the free encyclopedia
Note:After saving, you have to bypass your browser's cache to see the changes.Google Chrome,Firefox,Microsoft EdgeandSafari:Hold down the⇧ Shiftkey and click theReloadtoolbar button. For details and instructions about other browsers, seeWikipedia:Bypass your cache.
/**
* Script to show an [edits since this decline] link on the latest decline banner
* on an AFC draft.
* Per [[Wikipedia_talk:WikiProject_Articles_for_creation#Shortcut_for_viewing_changes_since_last_decline?]]
*
* Installation: add the following to your common.js page
importScript('User:SD0001/edits-since-decline.js') // [[User:SD0001/edits-since-decline.js]]
*
*/

$.when(
$.ready,
mw.loader.using(['ext.gadget.morebits','ext.gadget.libExtraUtil','mediawiki.api'])
).then(function(){

if(mw.config.get('wgCanonicalNamespace')!=='Draft'||
!$('.ombox-notice td.mbox-text:contains( "Submission declined on" )').length)return;

newMorebits.wiki.page(Morebits.pageNameNorm).load(function(pageobj){
vartemplates=extraJs.parseTemplates(pageobj.getPageText());
vardeclinets=templates.find(function(t){
returnt.name==='AFC submission'&&t.parameters[0].value==='d';
}).getParam('declinets').value;
newmw.Api().get({
"action":"query",
"format":"json",
"prop":"revisions",
"titles":Morebits.pageNameNorm,
"formatversion":"2",
"rvprop":"ids|timestamp",
"rvlimit":"2",
"rvstart":declinets,
"rvdir":"newer"
}).then(function(json){
varrevid=json.query.pages[0].revisions[0].revid;
varlink=mw.util.getUrl(Morebits.pageNameNorm,{
diff:'cur',
oldid:revid
});
varspan=$('.ombox-notice td.mbox-text span:contains( "Submission declined on" )')[0];
$(span).append(
' ',
$('<a>').text('[edits since this decline]').attr('href',link)
);
});

});

});