Last active
May 10, 2024 00:34
-
-
Save veteran29/126c03b73219ae1be5464ff91837b97a to your computer and use it in GitHub Desktop.
Arma Launcher HMTL Modlist to JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getWorkshopIdFromUrl(url) { | |
return url.split('id=')[1]; | |
}; | |
function getNodeType(node) { | |
return node.getAttribute('data-type') | |
}; | |
function getNodeDataValue(node) { | |
switch(getNodeType(node)) { | |
case 'Link': | |
return getWorkshopIdFromUrl(node.textContent); | |
default: | |
return node.textContent; | |
}; | |
}; | |
function getModsData() { | |
const modContainers = document.querySelectorAll("[data-type=ModContainer]"); | |
return Array.from(modContainers) | |
.map(row => row.querySelectorAll('[data-type]')) | |
.map(nodes => { | |
return Array.from(nodes).reduce((obj, node) => { | |
const key = getNodeType(node).toLowerCase(); | |
return Object.assign(obj, { [key]: getNodeDataValue(node) }); | |
}, {}); | |
}); | |
}; | |
/* | |
Build mod list for F.A.S.T | |
*/ | |
function sanitizeVal(val) { | |
return val.replace(',', ''); | |
}; | |
var modDate = '01.01.1970' | |
var output = '\n'; | |
getModsData().forEach(mod => { | |
output = output.concat(`${mod.link},${sanitizeVal(mod.displayname)},${modDate},01.01.1970,public\n`); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment