Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// ########## only for commons ##########

// Change "Upload file" link from [[Commons:Upload]] to [[Special:Upload&uploadformstyle=basic]]
var d = document.getElementById("n-uploadbtn");
d.innerHTML = d.innerHTML.replace("wiki/Commons:Upload", "w/index.php?title=Special:Upload&uploadformstyle=basic");

// Cat-a-lot [[Help:Gadget-Cat-a-lot]]
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":false,"docleanup":true};

// markAdmins [[MediaWiki:Gadget-markAdmins.js]]
markwdadmins  = true; // additionaly mark Wikidata admins

// JustReplace [[User:Sreejithk2000/JustReplace.js]]
mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Sreejithk2000/JustReplace.js&action=raw&ctype=text/javascript');

// SVGedit [[User:Rillke/SVGedit.js]]
mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Rillke/SVGedit.js&action=raw&ctype=text/javascript');


// modify default text for upload form
var d = new Date();
var day = d.getDate();
var month = d.getMonth()+1;
var year = d.getFullYear();
var date = year + '-' +
    (month<10 ? '0' : '') + month + '-' +
    (day<10 ? '0' : '') + day;
    
var UploadForm_autofill = false;
var prefill = [
    '== {{int:filedesc}} ==',
    '{{Information',
    '|Description=',
    '|Source=',
    '|Date=' + date,
    '|Author=[[User:Patrick87|Patrick87]]',
    '|Permission=',
    '|other_versions=',
    '}}',
    '',
    '== {{int:license-header}} =='].join('\n');
if (!mw.util.getParamValue('wpUploadDescription') && !mw.util.getParamValue('wpForReUpload')) {
	$('#wpUploadDescription').val(prefill);
}


// WikiEditor [[mw:Extension:WikiEditor]]
var customizeToolbarCommons = function() {
    // commons group in advanced section
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'groups': {
            'commons': {
                'label': 'Commons'
            }
        }
    } );
    // int:filedesc button
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'advanced',
        group: 'commons',
        tools: {
            "filedesc": {
                label: 'file description header',
                type: 'button',
                icon: '//upload.wikimedia.org/wikipedia/commons/b/be/Button_Filedesc.png',
                action: {
                    type: 'replace',
                    options: {
                        pre: "== {{int:filedesc}} ==",
                        post: "\n"
                    }
                }
            }
        }
    } );
    // int:license button
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'advanced',
        group: 'commons',
        tools: {
            "license": {
                label: 'license header',
                type: 'button',
                icon: '//upload.wikimedia.org/wikipedia/commons/1/15/Button_License.png',
                action: {
                    type: 'replace',
                    options: {
                        pre: "== {{int:license-header}} ==",
                        post: "\n"
                    }
                }
            }
        }
    } );
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
    mw.loader.using( 'user.options', function () {
    if ( mw.user.options.get('usebetatoolbar') ) {
            mw.loader.using( 'ext.wikiEditor', function () {
                $( customizeToolbarCommons );
            } );
        }
    } );
}