User:LVDP01/common.js

//============ // Purge tab //===========

$(function {	if ($('#ca-purge').length || !mw.config.get('wgIsArticle')) return;	var node = mw.util.addPortletLink( 'p-cactions', mw.util.getUrl(null, {action: 'purge'}), mw.config.get('skin') === 'vector' ? 'Refresh page' : 'Refresh page', 'ca-purge', 'Purge the server cache of this page', 'Refresh page' );	$(node).on('click', function (e) { new mw.Api.post({				action: 'purge',				titles: mw.config.get( 'wgPageName' )}).then(function {					location.reload;		}, function  {mw.notify('Purge failed', {type: 'error'})}); e.preventDefault; }); });

//================================================ // Ask for user confirmation before rollbacking // Really handy in case I'd misclick //================================================ $("a.mw-rollback-link[data-action = 'rollback'],\ .mw-custom-rollback-link").on('click', function(e) {    var linkText = $(e.target).text,    count = linkText.match(/\d/) ? linkText.match(/\d+/)[Number(0)] : null,    message = 'Rollback ' + (count ? count + ' edits' : 'edit') + ' by ' +               mw.util.getParamValue('from', e.target.href) + '?';	if(!confirm(message)) return e.preventDefault; });

//============== // Gadgets //==============

importScript('User:Mesidast/Tidy citations.js'); // Backlink: User:Mesidast/Tidy citations.js