-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Situation
The result of a character request by ID always shows classes, etc. as null. I found the issue and made a fix, but I rather not make a pull request as this is a very dirty fix. I will still explain what I did and what caused the issue in case you want to fix it.
Explaining the problem
In the page-parser.ts only the DOM from the character profile will be requested, so /lodestone/character/:id. But not from the Class/Job overview, so /lodestone/character/:id/class_job. That is the one we need in order to apply the css query selectors for the classes.
My (dirty) fix for that
What i just did now is, I added another DOM request at the start of the parse() function that is very similar to the existing one, but for the /class_job path:
const classJobDataAll = await axios.get(`${this.getURL(req)}/class_job`).catch((err: any) => {
throw new Error(err.response.status)
})
const classJobData = classJobDataAll.data
const classJobDom = new JSDOM(classJobData)
let classJobDocument = classJobDom.window.documentNow we have document for all the general info and classJobDocument for the classes.
Then later, when we call this.handleColumn() in currently line 54, we have to pass in the classJobDocument instead of document if the column is one of the classes.
For that (and this is the very dirty part), I just made a simple array with all classes and checked the column:
let correctDocument = document
if (
['Bozja', 'Eureka', 'Paladin', 'Warrior', 'Darkknight', 'Gunbreaker', 'Monk', 'Dragoon', 'Ninja', 'Samurai', 'Whitemage', 'Scholar', 'Astrologian', 'Bard', 'Machinist', 'Dancer', 'Blackmage', 'Summoner', 'Redmage', 'Bluemage', 'Carpenter', 'Blacksmith', 'Armorer', 'Goldsmith', 'Leatherworker', 'Weaver', 'Alchemist', 'Culinarian', 'Miner', 'Botanist', 'Fisher']
.includes(column)
) {
correctDocument = classJobDocument
} else correctDocument = documentNow we just have to pass correctDocument to this.handleColumn() instead of document and it will work again.
And this is the result with the same character after the fix:

(Eureka is in fact null, because I never played that, but I saw the Eureka info on a friends char!)
