User:Begoon/purgeThumbnail.js

//add a link to toolbox on file pages to purge a specific thumbnail

//check if file namespace (6) - otherwise pointless var nSpace = mw.config.get('wgNamespaceNumber'); if (nSpace == 6) {

//ensure mediawiki.util loaded ////////////////////////////// mw.loader.using( 'mediawiki.util', function { //call on page load /////////////////// jQuery( function( $ ) {

//add Thumbnail link to tools ////////////////////////////////// var followNode = document.getElementById("t-specialpages").nextSibling; mw.util.addPortletLink('p-tb', '#thumbnail-purge',              'Thumbnail purge', 't-thumbnailp', 'Force thumbnail purge','',followNode);

var el = document.getElementById('t-thumbnailp'); el.onclick = purgeThumbp;

function purgeThumbp { function IsNumeric(val) { return Number(val)==val; } var tsizep = prompt("Thumbnail size to purge?", "800"); if (IsNumeric(tsizep) && tsizep > 0) {

//set local server name var serverNamep = mw.config.get('wgServer'); // If the page has no local history if (!( $( '#ca-history' )[0] )) { //must be commons file, so    //alert ("commons file"); serverNamep = "//commons.wikimedia.org"; }

var filenamep = wgPageName.substring(wgPageName.indexOf(":") + 1); //removes namespace (File:) prefix var purgeurlp = "https:" + serverNamep + "/w/thumb.php?f=" + encodeURIComponent(filenamep) + "&w=" + tsizep; //alert (purgeurlp); window.open (purgeurlp, "_blank"); } } //close functions ///////////////// }); //jQuery( function( $ ) { }); //mw.loader.using( 'mediawiki.util', function { }