MediaWiki:Gadget-ResourcePacks.js/Hypixel+.css/update.js

/* * THIS IS NOT A SCRIPT TO BE LOADED ON THE WIKI * * Instead, this is a script that can be pasted into the browser's console while on a wiki page. * This script can be used to generate updated CSS for the parent css page */

( => {	const BASE = 'https://projects.fewfre.com/hypixel/skyblock/resourcepacks/Hypixel+_0_18_0/assets/minecraft/mcpatcher/cit';	const resourcepack = {		'/skyblock': {			'/tools': {				'/mining': {					_files: {						bob_omb: { wiki: 'Bob-omb' },					}				},				'/combat': {					_files: {						jingle_bells: { wiki: 'Jingle Bells' },					}				}			}		}	};	// recursive function	function flattenResourcePackObj(prefix, { _files, ...folders }) {		return [			// Add all files to list			...Object.entries(_files ?? {}).map(([packFilename,wikiData]) => packDataToCssRule(prefix, packFilename, wikiData)),			// rescursively add child folder object contents			...Object.entries(folders ?? {}).map(([folderName, obj]) => flattenResourcePackObj(`${prefix}${folderName}`, obj))		].flat;	}	function packDataToCssRule(packPrefix, packFilename, { wiki, ...wikiData }) {		let selectors = [ `img[alt='${wiki}']`, `img[alt='${wiki}.png']`, ...(wikiData.selectors ?? []) ];		return `${selectors.join(', ')} { content: url('${packPrefix}/${packFilename}.png') }`;	}	const cssEntries = flattenResourcePackObj(BASE, resourcepack);	/////////////////////////////////	// Display results	/////////////////////////////////	function openModal(content) {		mw.hook('dev.modal').add((module) => { const id = 'hsw-rp-hypixel-plus-' + Date.now; const modal = new module.Modal({ id, content, size: 'full' }); modal.create; modal.show; });	}

console.log('Completed CSS generation! View the results in the modal on screen!'); cssEntries.unshift('/* Script for updating this page is on MediaWiki:Gadget-ResourcePacks.js/Hypixel+.css/update.js */') openModal(		[			" ",			`${cssEntries.join('\n')} `,			' '		].join('')	);

return 'Generating CSS...'; });