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.
/*
 Transform "Upload log" page in a Gallery
 Usefull to filter images by tag (For example for hide uploads from flickr using the tag uploadwizard)
 "Upload log" page: https://commons.wikimedia.org/w/index.php?title=Special:Log/upload&user={{YOUR USERNAME}}
*/
$(function() {
    'use strict';
    mw.util.addPortletLink ('p-tb', '/w/index.php?title=Special:Log&offset=&limit=350&type=upload&user='+wgUserName+'&page=&tagfilter=uploadwizard&subtype=upload', 'Gallery log');
    mw.util.addPortletLink ('p-personal', '/w/index.php?title=Special:Log&offset=&limit=350&type=upload&user='+wgUserName+'&page=&tagfilter=uploadwizard&subtype=upload', 'Gallery log');
    
    const uploadLogPage = 'Log';
    const uploadListContainer = ".mw-logline-upload";
    const resultContent = "#mw-content-text";
    const groupSize = 5;
	
	function _getPageName() {
		return mw.config.get('wgCanonicalSpecialPageName');
	}
    function _getImageName(aElement) {
        var imageName = null;

        const imageNode = $(aElement).find("a").last().attr('href').split(":");

        if (imageNode.length > 0) {
            if (imageNode[1].indexOf(".") !== -1) {
                imageName = imageNode[1];
            }
        }

        return imageName;
    }
    function _getMultiple(valor, multiple)
    {
        var resto = valor % multiple;
        return (resto===0);
    }
        
    function _arrayListToGroup(arrayList)
    {
    	var groupList = [];
    	var tempImageList = [];
    	var iSize = 0;
	    jQuery.each( arrayList, function( i, val ) {
		  tempImageList.push(val);
		  iSize++;
		  if (iSize==50) {
		  	groupList.push(tempImageList);
		  	tempImageList = [];
		  
			iSize =0;
		  }
		});
		
		if (tempImageList.length>0) groupList.push(tempImageList);

		return groupList;
    }
    function _getImageList() {
        var imageList = [];
		var imageName = null;

        $(uploadListContainer).each(function() {
			
            imageName = _getImageName(this);
			
			if (imageName !== null) {
				imageList.push(imageName);
			}

            $(this).remove();
        });

        return imageList;
    }

    function _addGallery(htmlText) {
        $(resultContent).find("ul").append(htmlText);
    }

    function _wikiToHTML() {
		const imageGroupList = _arrayListToGroup(_getImageList());

		var wikiHTML = [];
		
		jQuery.each( imageGroupList, function( i, imageList ) {
			
			wikiHTML.push(jQuery.getJSON(
				mw.util.wikiScript('api'), {
					'format': 'json',
					'action': 'parse',
					'contentmodel': 'wikitext',
					'text': _imageListToWikiText(imageList)
				},
				function(data) {
					//_addGallery(data.parse.text["*"]);
					return (data.parse.text["*"]);
				}
			));
			
		});
		
		$.when.apply($, wikiHTML).done(function(){
			var wikiText = [];
			
			for(var i = 0; i < arguments.length; i++){
				console.log(arguments[i]);
				if (typeof arguments.parse !== 'undefined')
				{
					wikiText.push(arguments.parse.text["*"]);
				} 
				else if ((typeof arguments[i] !== 'undefined')&&(typeof arguments[i].parse !== 'undefined'))
				{
					wikiText.push(arguments[i].parse.text["*"]);
				} 
				else if ((typeof arguments[i][0] !== 'undefined')&&(typeof arguments[i][0].parse !== 'undefined'))
				{
					wikiText.push(arguments[i][0].parse.text["*"]);
				}
			}
			
			var newUnique = [];
			
			$.each(wikiText , function (i, el) {
			    
			    if ($.inArray(el, newUnique ) === -1) {
			        newUnique.push(el);
			    } 
			    
			    else {
			        var index = newUnique.indexOf(el);
			        if(index > -1){
			           newUnique.splice(index, 1);
			        }
			    }
			});
			
			_addGallery(newUnique.join(""));
			
		});
		
        
    }
    
    function _imageListToWikiText(imageList) {
    	 return "<gallery>\nFile:" + imageList.join("\nFile:") + "\n</gallery>";
    }

    if (uploadLogPage === _getPageName()) {
		
        _wikiToHTML();
    }
});