User:Nekomimi97/global.js

/* Tabkey */ var tabKeyEnabled = true; /* Chat */ importArticles({    type: 'script',     articles: [         // ...         'u:kocka:MediaWiki:Emoticons/code.js',         // ...     ] }); importScriptPage('MediaWiki:PrivateMessageAlert/code.js', 'dev');

/* Articles */ importArticles({   type: 'script',    articles: [        // ...        'u:dev:LastEdited/code.js',        // ...    ] }); // Script to look for unused files // Document variables var allFilesListDiv=document.getElementById('all-files-list'); var usedFilesOl=document.getElementById('used-files'); var unusedFilesOl=document.getElementById('unused-files');

// Create textarea and button and assign them to the variables var textarea=document.createElement('textarea'); textarea.setAttribute('id', 'all-files-textarea'); textarea.setAttribute('style', 'width:100%'); allFilesListDiv.appendChild(textarea); var allFilesTextarea=document.getElementById('all-files-textarea');

var button=document.createElement('div'); button.setAttribute('id', 'all-files-button'); button.setAttribute('class', 'wds-button'); button.textContent='Check files'; allFilesListDiv.appendChild(button); var allFilesButton=document.getElementById('all-files-button');

// Event listener allFilesButton.addEventListener('click', checkFilesUsage);

// Main function function checkFilesUsage { // Create array of provided files var filesList=allFilesTextarea.value.split(/\n/); // Create api variable var api = new mw.Api; // Api call for each element filesList.forEach( function (file) {       api.get({ action: "query", format: "json", list: "imageusage", formatversion: "2", iutitle: file }).done( function (iuresult) { if (iuresult.query.imageusage.length==0) { unusedFilesOl.innerHTML+="" + file + ""; } else { usedFilesOl.innerHTML+="" + file + "" }       });    }) }