User:Vid gmail/pages.js
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
// This code dynamically updates an HTML table of files with specified extensions on a MediaWiki site as it works (async function() { const extensions = ['pub', 'png', 'gif', 'jpg', 'jpeg', 'pdf', 'xls', 'docx', 'pptx', 'doc', 'ppt', 'svg', 'xml', 'mpg', 'odp', 'odt', 'wmv', 'flv', 'vsd', 'mpp', 'ai', 'zip', 'txt', 'wpd', 'rtf', 'drf', 'xlsx', 'xlsm', 'oft', 'swf', 'ppsx', 'dotx', 'potx']; const updateTable = (extension, count) => { const tableBody = document.getElementById('files-table-body'); if (tableBody) { const row = `<tr><td>${extension}</td><td>${count}</td></tr>`; tableBody.innerHTML += row; } else { console.error('Files table body element not found'); } }; for (const extension of extensions) { let continueParam = ''; let totalCount = 0; do { const response = await fetch(`https://wiki.gccollab.ca/api.php?action=query&list=allimages&aifrom=${extension}&ailimit=max&format=json${continueParam}`); const data = await response.json(); const files = data.query.allimages || []; // Filter files by extension const filteredFiles = files.filter(file => file.name.endsWith(`.${extension}`)); totalCount += filteredFiles.length; continueParam = data.continue ? `&aicontinue=${data.continue.aicontinue}` : ''; } while (continueParam); // Update the table with the extension and count updateTable(extension, totalCount); } })();