User:SD0001/edits-since-decline.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes.A guideto help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at theappropriate village pump. This codewillbe executed when previewing this page. |
![]() | Thisuser scriptseems to have a documentation page atUser:SD0001/edits-since-decline. |
/**
* 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)
);
});
});
});