User:Dark Yada/global.js

var qtUserPageTemplate = ''; var qtEnableUserPageOverwrite = true; massBlockDelay = 1000; WHAMBotMe = true; WHAMBotReason = "Cleanup"; WHAMDelay = 100; batchDeleteDelay = 1000; massRenameDelay = 1000; massRenameSummary = 'Nom français'; QuickCommentsdeletereason = "Commentaire inutile";

importArticles({   type: 'script',    articles: [        'u:de.trollocool:MediaWiki:VanguardTools.js',        'u:dev:AddBlockUserTag/code.js',        'u:dev:MediaWiki:AjaxCommentDelete/code.js',        'u:dev:MediaWiki:AjaxBatchDelete/code.2.js',        'u:dev:MediaWiki:AjaxBatchUndelete/code.js',        'u:dev:MediaWiki:AjaxRC/code.js',        'u:dev:MediaWiki:AjaxUndo/code.js', 'dev',        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:MediaWiki:CategoryRenameAuto-update/code.js',        'u:dev:MediaWiki:DiscussionsFeed.js',        'u:dev:MediaWiki:DiscussionsViewer/code.js',        'u:dev:MediaWiki:FileUsageAuto-update/code.js',        'u:dev:MediaWiki:GlobalEditcount/code.js',        'u:dev:MediaWiki:MassBlock/code.js',        'u:dev:MediaWiki:MassCategorization/code.js',        'u:dev:MediaWiki:MassRename/code.js',        'u:dev:MediaWiki:MassNullEdit/code.js',        'u:dev:MediaWiki:NewPagesUser.js', 'u:dev:MediaWiki:Nuke/code.js', 'dev', 'u:dev:MediaWiki:PageRenameAuto-update/code.js', 'u:dev:MediaWiki:QuickCreateUserPage/code.js', 'u:dev:MediaWiki:QuickComments/advanced.js',

'u:dev:MediaWiki:SandboxTab/code.js',

'u:dev:MediaWiki:Sine/code.js', 'u:dev:TVMH.js', 'u:dev:MediaWiki:UnhideUserMasthead/code.js', 'u:dev:MediaWiki:VSTFReport.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:YouShallNotPass/code.js', 'u:dev:QuickIW/code.js' ] });

if (window.location.pathname.indexOf('Special:InfoboxBuilder') != -1) {    var name = window.location.pathname.split('Special:InfoboxBuilder/')[1];     location.replace(document.URL.replace(window.location.href.split('/wiki/')[1],'Template:'+name+'?action=edit&useeditor=source')); } if (window.location.pathname.indexOf('Spécial:InfoboxBuilder') != -1) {    var name = window.location.pathname.split('Spécial:InfoboxBuilder/')[1];     location.replace(document.URL.replace(window.location.href.split('/wiki/')[1],'Modèle:'+name+'?action=edit&useeditor=source')); } importScriptURI('//internal-vstf.fandom.com/index.php?title=User:Dark Yada/scripts.js&action=raw&ctype=text/javascript');

/* Old version of MultiUpload */ (function($) {   // Don't load twice..    if (window.MultiUploadLoaded) {        return;    }    window.MultiUploadLoaded = true;

var config = mw.config.get([       'wgCanonicalSpecialPageName',        'wgUserName',        'wgUserGroups'    ]);

function init(i18n) { var MultiUpload = { init: function { $('#my-tools-menu').prepend(                   $('', { class: 'custom' }).append( $('', {                           href: mw.util.getUrl('Special:BlankPage', { blankspecial: 'MultiUpload' }),                           text: i18n.msg('title').plain                        }) )               );                if (config.wgCanonicalSpecialPageName === 'Blankpage' && $.getUrlVar('blankspecial') === 'MultiUpload') { if (config.wgUserName === null || !$.inArray('autoconfirmed', config.wgUserGroups)) { /* If the user don't have multiple upload rights (if it's not autoconfirmed) */ $('#mw-content-text').html(i18n.msg('logout').plain); return false; }                   var MultiUploadoption = window.MultiUploadoption || {}; $.extend(MultiUpload, MultiUploadoption); $('#mw-content-text').remove; $('#WikiaArticle').append('\n Ici \n ' + i18n.msg('update').plain + ' '); $('#editor').css('display', 'none'); var token = mw.user.tokens.get('editToken'); $('.page-header__title').text(i18n.msg('title').plain); document.title = i18n.msg('title').plain; var filename; }           },            updatelicensebutton: function(licencestext) { if (licencestext !== null) { var licences = licencestext.trim.split('\n'); $('.licence').replaceWith(' '); $('.licence').prepend(' ' + i18n.msg('nolicence').plain + ' '); for (i = 0; i < licences.length; i++) { if (licences[i].indexOf('**') === 0) { licences[i] = licences[i].replace("**", ""); if (licences[i].split('|')[0] == MultiUpload.defaultlicence) { $('.licence').find('optgroup:last-child').append('' + licences[i].split('|')[1] + ' '); } else { $('.licence').find('optgroup:last-child').append('' + licences[i].split('|')[1] + ' '); }                       } else { licences[i] = licences[i].replace('*', ''); $('.licence').append('</optgroup'); }                   }                }            },            getlicence: function { $.ajax({                   type: "GET",                    url: mw.util.wikiScript('api') + '?action=query&meta=allmessages&ammessages=Licenses&format=json',                    success: function(data) {                        var content = data.query.allmessages[0]['*'];                        MultiUpload.updatelicensebutton(content);                    },                    error: function(data) {                        alert(i18n.msg('errorapi').plain + ' : ' + data.error.info);                    }                }); },           update: function { if ($('fieldset').length > 0) { MultiUpload.handleFileSelect; return false; }               $('#editor').css('display', 'block'); $('#fileinput').attr("disabled", true); input = document.getElementById('fileinput'); $('#editor').html(''); if (input.files.length === 0) { alert(i18n.msg('nofile').plain); return false; }               if(!MultiUpload.max || typeof MultiUpload.max !== 'number' || MultiUpload.max < 0 || MultiUpload.max > 101) { if(/staff|helper|util|bot-global/.test(config.wgUserGroups.join)) { MultiUpload.max = 200; } else if (/bureaucrat|bot/.test(config.wgUserGroups.join)) { MultiUpload.max = 70; } else if ($.inArray('sysop', config.wgUserGroups) > -1) { MultiUpload.max = 50; } else if ($.inArray('rollback', config.wgUserGroups) > -1) { MultiUpload.max = 30; } else { MultiUpload.max = 20; }               }                if (!MultiUpload.max) { alert(lng.problem); return false; }               var limit; if (MultiUpload.max < input.files.length) { limit = MultiUpload.max; } else { limit = input.files.length; }               for (i = 0; i < limit; i++) { $('#editor').append(' ' + i18n.msg('imagename').plain + ' ' + (i + 1) + ' ' + i18n.msg('filename').plain + '  ' + i18n.msg('licensetext').plain + ' '); }               MultiUpload.getlicence; $('#editor').append(' ' + i18n.msg('filedescription').plain + '  '); $('#go').html(i18n.msg('uploadfiles').plain); $(' ' + i18n.msg('ignorewarnings').plain + ' ').insertAfter('#go'); },           handleFileSelect: function { input = document.getElementById('fileinput'); if (!input.files) { alert(i18n.msg('browsersupport').plain); $('#fileinput').attr("disabled", false); } else if (!input.files[0]) { alert(i18n.msg('problem').plain); $('#fileinput').attr("disabled", false); } else { $('fieldset').attr('disabled', 'disabled'); $('#go').attr('disabled', 'disabled'); var numberfiles = $('fieldset').length - 1; if (numberfiles > 0) { for (i = 0; i < numberfiles; i++) { file = input.files[i]; filename = $('.imagename').eq(i).val || input.files[i].name; if ($('#WikiaArticle').find('select:eq(' + i + ')').find('option:selected').val !== "none") { licence = '{' + '{' + $('#WikiaArticle').find('select:eq(' + i + ')').find('option:selected').val + '}}' + '\n' + $('#UploadDescription').val; } else { licence = $('#UploadDescription').val; }                           $('#loading' + (i + 1)).css('display', 'initial'); MultiUpload.uploadfiles(file, filename, licence); }                       alert(i18n.msg('success').plain); $('#go').html(i18n.msg('reset').plain); $('#go').removeAttr('disabled'); $('#go').click(function(event) {                           if ($('#go').html == i18n.msg('reset').plain) {                                event.stopPropagation;                                $('#WikiaArticle').find('*').attr("disabled", false);                                $('#editor').html();                                $('#editor').css('display', 'none');                                $('#go').html(i18n.msg('update').plain);                                $('#fileinput').val();                            }                        }); }               }            },            uploadfiles: function(fileToUpload, fileName, licence) { var lFileName = fileName;

formdata = new FormData; // see https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects formdata.append('action', 'upload'); formdata.append('filename', lFileName); formdata.append('token', mw.user.tokens.get('editToken')); formdata.append('file', fileToUpload); formdata.append('text', licence); formdata.append('format', 'json'); if ($('#ignorewarnings').prop('checked')) { formdata.append('ignorewarnings', '1'); }

// as we now have created the data to send, we send it... $.ajax({ // https://stackoverflow.com/a/8244082                   url: mw.util.wikiScript('api'), //url to api.php                     contentType: false,                    processData: false,                    type: 'POST',                    data: formdata, //the formdata object we created above                    dataType: 'json',                    async: false,                    success: function(data) {                        //        console.log(data);                        if (data.upload.result == 'Warning') {                            if (data.upload.warnings.hasOwnProperty('duplicate')) {                                //if file is a duplicate, we use the name of the first existing file                                lFileName = data.upload.warnings.duplicate[0];                                alert(i18n.msg('duplicate').plain + lFileName);                                MultiUpload.uploadfinished(false); } else if (data.upload.warnings.hasOwnProperty('exists')) { lFileName = prompt(i18n.msg('alreadyname').plain, lFileName); if (lFileName !== null) { lFileName = MultiUpload.uploadfiles(fileToUpload, lFileName, licence); } else { MultiUpload.uploadfinished(false); }                           }                        } else { MultiUpload.uploadfinished(true); }                   },                    error: function(xhr, status, error) { alert(error); MultiUpload.uploadfinished(false); }               });            },            uploadfinished: function(result) {                if (result) {                    $('#loading' + (i + 1) + ' > img').attr('src', 'https://vignette.wikia.nocookie.net/guigui/images/e/ef/Success.png/revision/latest?path-prefix=fr');                } else {                    $('#loading' + (i + 1) + ' > img').attr('src', 'https://vignette.wikia.nocookie.net/guigui/images/8/8a/Problem.png/revision/latest?path-prefix=fr');                }            }        };        $('#WikiaArticle').on("click", "#go", function { MultiUpload.update; });       MultiUpload.init; // Start script    }    mw.hook('dev.i18n').add(function(i18n) { i18n.loadMessages('MultiUpload').then(init); });   importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' }); })(jQuery);