- Fixed login getting stuck
- Updated packages
- Fixed some errors not throwing
This commit is contained in:
TheNetsky
2024-02-05 11:47:48 +01:00
parent 2fea17c415
commit f7aa5039f9
5 changed files with 45 additions and 35 deletions

View File

@@ -95,13 +95,13 @@ export default class BrowserFunc {
const scripts = Array.from(document.querySelectorAll('script'))
const targetScript = scripts.find(script => script.innerText.includes('var dashboard'))
if (targetScript) {
return targetScript.innerText
} else {
throw this.bot.log('GET-DASHBOARD-DATA', 'Script containing dashboard data not found', 'error')
}
return targetScript?.innerText ? targetScript.innerText : null
})
if (!scriptContent) {
throw this.bot.log('GET-DASHBOARD-DATA', 'Dashboard data not found within script', 'error')
}
// Extract the dashboard object from the script content
const dashboardData = await this.bot.homePage.evaluate(scriptContent => {
// Extract the dashboard object using regex
@@ -110,11 +110,13 @@ export default class BrowserFunc {
if (match && match[1]) {
return JSON.parse(match[1])
} else {
throw this.bot.log('GET-DASHBOARD-DATA', 'Dashboard data not found within script', 'error')
}
}, scriptContent)
if (!dashboardData) {
throw this.bot.log('GET-DASHBOARD-DATA', 'Unable to parse dashboard script', 'error')
}
return dashboardData
}