MediaWiki:Gadget-speedy.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
* Gadget that shows a notification if there are pages that are marked for
* deletion. It checks the number of transclusions of Template:Delete instead
* of the category because pages in translation namespaces aren't categorized.
*
* The gadget will only show a notification once per hour, and only if there
* actually are any pages to be deleted.
*
* @authors Jon Harald Søby
* @license CC-zero
* @version 1.1.1 (2024-04-02)
*/
let lastShown = mw.storage.get( 'mw-twn-deleteGadgetTime' ) || 0,
now = Date.now();
if ( now - lastShown > 60*60*1000 ) {
let api = new mw.Api();
api.get( {
action: 'query',
prop: 'transcludedin',
titles: 'Template:Delete',
tilimit: 100,
maxage: 60*60,
smaxage: 60*60
}).then( ( data ) => {
let relevant = data.query.pages[ '5504159' ].transcludedin;
if ( relevant ) {
api.loadMessagesIfMissing( [ 'gadget-speedy-delete' ] ).then( () => {
mw.notify(
$( '<p>' ).append( mw.message(
'gadget-speedy-delete',
relevant.length,
mw.util.getUrl(
'Special:WhatLinksHere/Template:Delete',
{
hideredirs: 1,
hidelinks: 1
}
)
).parseDom()
),
{
autoHide: false,
type: 'warn'
}
);
});
}
mw.storage.set( 'mw-twn-deleteGadgetTime', now );
});
}