fix: download pdf

This commit is contained in:
Xmader 2020-11-14 17:23:22 -05:00
parent 125013d455
commit 7705320ce9
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 10 additions and 8 deletions

View File

@ -3,7 +3,7 @@
import scoreinfo from './scoreinfo'
import { webpackHook, webpackGlobalOverride, ALL } from './webpack-hook'
let AUTH_MODULE_ID: string
let authModuleId: string
const AUTH_FN = '+3],22,-1044525330)'
const MAGIC_ARG_INDEX = 1
@ -17,13 +17,15 @@ let magic: Promise<string> | string = new Promise((resolve) => {
webpackGlobalOverride(ALL, (n, r, t) => { // override
const fn = n.exports
if (typeof fn === 'function' && fn.toString().includes(AUTH_FN)) {
AUTH_MODULE_ID = n.i
n.exports = (...args) => {
if (magic instanceof Promise) {
magic = args[MAGIC_ARG_INDEX]
resolve(magic)
if (!authModuleId && n.i) {
authModuleId = n.i
n.exports = (...args) => {
if (magic instanceof Promise) {
magic = args[MAGIC_ARG_INDEX]
resolve(magic)
}
return fn(...args) as string
}
return fn(...args) as string
}
}
})
@ -43,7 +45,7 @@ const getApiAuth = async (type: FileType, index: number): Promise<string> => {
const str = String(scoreinfo.id) + type + String(index)
const fn: (str: string, magic: string) => string = webpackHook(AUTH_MODULE_ID)
const fn: (str: string, magic: string) => string = webpackHook(authModuleId)
return fn(str, magic)
}