fix: obtain scoreinfo

This commit is contained in:
Xmader 2020-10-23 10:11:52 -04:00
parent 769851ba9f
commit b232462947
2 changed files with 9 additions and 5 deletions

View File

@ -10,9 +10,6 @@ import * as recaptcha from './recaptcha'
import scoreinfo from './scoreinfo'
const main = (): void => {
// @ts-ignore
if (!window?.UGAPP?.store?.page?.data?.score) { return }
// init recaptcha
// eslint-disable-next-line @typescript-eslint/no-floating-promises
recaptcha.init()

View File

@ -1,10 +1,17 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
const scoreinfo = {
// run at document-start
export const ugappJsStore = (() => {
const el = document.querySelector('.js-store') as HTMLDivElement
const json = el.dataset.content as string
return JSON.parse(json)
})()
export const scoreinfo = {
get playerdata (): any {
// @ts-ignore
return window.UGAPP.store.page.data.score
return ugappJsStore.store.page.data.score
},
get id (this: typeof scoreinfo): number {