Created
August 29, 2024 22:01
-
-
Save thepsion5/cef03a3e57a069ff124cc389bd7298dd to your computer and use it in GitHub Desktop.
Converts the data on Fallout 76 legendary rewards
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
// Data Source: https://nukaknights.com/articles/legendary-mods-all-descriptions-and-usages.html | |
const modWrapperSelector = '.mod_fallout76rewards_legendarymods'; | |
const modData = []; | |
const containers = $(modWrapperSelector); | |
getRankFromRow = function(row) { | |
let parent = $(row).parents(modWrapperSelector)[0]; | |
for (let index = 0; index < containers.length; index++) { | |
if (containers[index] == parent) { | |
return index+1; | |
} | |
} | |
return -1; | |
} | |
getDescription = function(row) { | |
let desc = $(row).find('.mod_desc').text().trim().replaceAll("'", '').replaceAll('"', ''); | |
if(desc.includes('\n')) { | |
let multiLineDesc = desc.split('\n'); | |
if (multiLineDesc[0].trim() == multiLineDesc[1].trim()) { | |
desc = multiLineDesc[0].trim(); | |
} | |
} | |
return desc; | |
} | |
getTypes = function(row) { | |
let types = []; | |
$(row).find('.mod_rel img').each(function(index) { | |
let type = $(this).attr('data-original-title').trim(); | |
types.push(type); | |
}); | |
return types.toString(); | |
} | |
getName = function(row) { | |
return $(row).find('.mod_name').text().trim().replaceAll("'", '').replaceAll('"', ''); | |
} | |
$('.mod_fallout76rewards_legendarymods .row').each(function(index) { | |
const row = { | |
'rank': getRankFromRow(this), | |
'name': getName(this), | |
'desc': getDescription(this), | |
'types': getTypes(this), | |
'crafting': $(this).find('.mod_addon').text().trim() | |
} | |
modData.push(row); | |
}); | |
console.log('Legendary Mods:'); | |
console.table(modData); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment