Skip to content

Instantly share code, notes, and snippets.

@SethClydesdale
Last active September 5, 2017 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SethClydesdale/9b887d9bfedaf644d91d2350ec32db74 to your computer and use it in GitHub Desktop.
Save SethClydesdale/9b887d9bfedaf644d91d2350ec32db74 to your computer and use it in GitHub Desktop.
Grabs drop chart data from Ephinea for use with the drop charts addon : https://github.com/SethClydesdale/psobb-drop-charts
// script used for grabbing drop charts from ephinea
// https://ephinea.pioneer2.net/drop-charts/normal/
// HOW TO USE
// Paste the script in your console (F12/CTRL+SHIFT+I > Console) and execute it while viewing a drop chart,
// the lua table will automatically be copied to your clipboard.
// Delete the contents of the respective difficulty file (i.e. normal, hard, very hard, etc...) and add "return" to the beginning
// of the file, once you've done this, paste the previously copied code and save.
// Repeat the above steps for each difficulty.
// removes empty cells
$('tr').filter(function () {
if (this.querySelector('td[colspan="11"]')) {
return false
} else {
return this.innerHTML.indexOf(' ') != -1
}
}).remove()
// key list for identifying section id by color
var section_id = {
'#00A562' : 'Viridia',
'#76FE43' : 'Greenill',
'#59F9F9' : 'Skyly',
'#4488FF' : 'Bluefull',
'#CC00FF' : 'Purplenum',
'#FF87CB' : 'Pinkal',
'#F70F0F' : 'Redria',
'#F7830F' : 'Oran',
'#F7F715' : 'Yellowboze',
'#FFFFFF' : 'Whitill'
}
// loop vars
var chart = {},
table = document.querySelectorAll('table'),
i = 0,
j = table.length,
td, k, l, m, enemy, episode, b, abbr, dar, rare;
// loop over the table cells to retrieve the drop chart data
for (; i < j; i++) {
td = table[i].querySelectorAll('td');
episode = td[0].innerText;
k = 1;
l = td.length;
console.log(episode)
if (chart[episode]) {
episode += ' Boxes'
chart[episode] = {};
} else {
chart[episode] = {};
}
for (; k < l; k++) {
if (section_id[td[k].bgColor]) {
if (!chart[episode][section_id[td[k].bgColor]]) {
chart[episode][section_id[td[k].bgColor]] = []
}
b = td[k].querySelector('b');
abbr = td[k].querySelector('abbr');
dar = abbr ? abbr.title.match(/DAR: (.*?)%/) : '';
rare = abbr ? abbr.title.match(/Rare Rate: (.*?)%/) : '';
if (abbr && !rare) {
rare = abbr.title.match(/1P:.*?\((.*?)%\)/)
}
chart[episode][section_id[td[k].bgColor]].push({
target : enemy,
item : b ? b.innerText : '',
dar : dar && dar[1] ? parseFloat(dar[1]) : 100,
rare : rare && rare[1] ? parseFloat(rare[1]) : 0
});
} else if (td[k].colSpan == 11) {
for (m in chart[episode]) {
chart[episode][m].push({
target : 'SEPARATOR'
});
}
} else {
enemy = td[k].innerText;
}
}
}
// stringify the object and convert it to lua table syntax, then copy it to the clipboard
copy(JSON.stringify(chart, null, 2).replace(/"(.*?)":/g, '["$1"] =').replace(/= \[/g, '= {').replace(/\],/g, '},').replace(/ ]\n }/g, ' }\n }').replace(/%/g, '%%').replace(/⁄/g, '/').replace(/\\r/g, '\\n'));
console.log('DROP CHARTS COPIED');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment