User:Mdaniels5757/PurgeTab.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 guide to 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 the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:Mdaniels5757/PurgeTab. |
/**
* Add buttons (located in the "more" tab for vector users) to
* purge, hard purge (forcerecursivelinkupdate=1), and null edit
*
* @source https://en.wikisource.org/wiki/MediaWiki:Gadget-PurgeTab.js
* @revision revid 9616727 (03:55, September 25, 2019)
*/
jQuery(document).ready(function () {
if (!mw.config.get('wgArticleId'))
return;
var link;
link = mw.util.addPortletLink(
'p-cactions', mw.util.getUrl(mw.config.get('wgPageName'), { 'action': 'purge' }),
(mw.user.options.get( 'skin' ) == 'vector' ) ? "Purge" : "*",
'ca-purge', "Purge cache for this page", '*'
);
link = mw.util.addPortletLink(
// not sure if raw link is valid for extra params Using wikiScript instead of getUrl
'p-cactions', mw.util.wikiScript('api') + '?action=purge&titles=' + mw.config.get('wgPageName') + '&forcerecursivelinkupdate=1&redirects=1',
(mw.user.options.get( 'skin' ) == 'vector' ) ? "Hard purge" : "**",
'ca-purge-forcerecursivelinkupdate', "Purge with forced recursive-link table update", ','
);
link.addEventListener('click', function (ev) {
mw.loader.using( 'mediawiki.api' ).done(function() {
( new mw.Api() ).post({
action: 'purge',
pageids: mw.config.get('wgArticleId'),
forcerecursivelinkupdate: 1,
redirects: 1
}).then(function () {
location.reload();
}, function (code, details) {
var mesg;
switch (code) {
case 'http':
mesg = 'HTTP error: ' + details.xhr.statusText;
break;
case 'ok-but-empty':
mesg = 'Received empty response.';
break;
default:
mesg = details.error.info;
}
mw.util.jsMessage('<b>Hard purge failed</b>: ' + mesg);
console.error(arguments);
} );
} );
ev.preventDefault();
}, false);
link = mw.util.addPortletLink(
'p-cactions', 'javascript:void window.warranty',
(mw.user.options.get( 'skin' ) == 'vector' ) ? "Null edit" : "***",
'ca-nulledit', "Null edit", '0'
);
link.addEventListener('click', function (ev) {
mw.loader.using( 'mediawiki.api' ).done( function() {
( new mw.Api() ).post({
action: 'edit',
pageid: mw.config.get('wgArticleId'),
appendtext: '',
watchlist: 'nochange',
nocreate: '1',
token: mw.user.tokens.get('csrfToken')
}).then(function () {
location.reload();
}, function (code, details) {
var mesg;
switch (code) {
case 'http':
mesg = 'HTTP error: ' + details.xhr.statusText;
break;
case 'ok-but-empty':
mesg = 'Received empty response.';
break;
default:
mesg = details.error.info;
}
mw.util.jsMessage('<b>Null edit failed</b>: ' + mesg);
console.error(arguments);
} );
} );
ev.preventDefault();
}, false);
} );