Last active
June 19, 2017 12:25
-
-
Save eps1lon/0de26396f2f2751129f271ffac82be11 to your computer and use it in GitHub Desktop.
poe db unique item parsercan be used to diff http://cb.poedb.tw/us/unique.php?l=1 with http://poedb.tw/us/unique.php?l=1
This file contains hidden or 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
(() => { | |
const items = {}; | |
for (const row of document.querySelectorAll('tr td:nth-of-type(2)')) { | |
const full_name_element = row.querySelector('a.item_unique'); | |
if (full_name_element !== undefined) { | |
const full_name = full_name_element.innerText; | |
let implicits = []; | |
let explicits = []; | |
let is_implicit = true; | |
for (const mod_candidate of row.querySelectorAll('span, div')) { | |
if (mod_candidate.className.indexOf('item_magic') !== -1) { | |
const mod = mod_candidate.innerText; | |
if (is_implicit) { | |
implicits.push(mod) | |
} else { | |
explicits.push(mod) | |
} | |
} else if (mod_candidate.className.indexOf('ItemUniqueSeparator') !== -1) { | |
is_implicit = false | |
} | |
} | |
// no separator | |
if (is_implicit) { | |
explicits = implicits.slice() | |
implicits = [] | |
} | |
const name_element = row.querySelector('span:last-child'); | |
let name, base_item | |
if (name_element !== undefined) { | |
name = name_element.innerText; | |
base_item = full_name.replace(name, '').trim(); | |
} else { | |
name = full_name; | |
base_item = undefined | |
} | |
// remove accordingly to your prefered diff | |
items[name] = { base_item, implicits, explicits }; | |
} | |
} | |
console.log(items) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment