fix: auth magic

This commit is contained in:
Xmader 2020-11-12 13:29:10 -05:00
parent 8beb23ae69
commit e50f0e3e8e
No known key found for this signature in database
GPG key ID: A20B97FB9EB730E4

View file

@ -1,10 +1,10 @@
/* eslint-disable no-extend-native */ /* eslint-disable no-extend-native */
import scoreinfo from './scoreinfo' import scoreinfo from './scoreinfo'
import { webpackHook, webpackGlobalOverride } from './webpack-hook' import { webpackHook, webpackGlobalOverride, ALL } from './webpack-hook'
const FILE_URL_MODULE_ID = 'iNJA' const FILE_URL_MODULE_ID = 'iNJA'
const AUTH_MODULE_ID = 'F08J' const ARG_NUMBER = 4
const MAGIC_ARG_INDEX = 3 const MAGIC_ARG_INDEX = 3
type FileType = 'img' | 'mp3' | 'midi' type FileType = 'img' | 'mp3' | 'midi'
@ -14,8 +14,9 @@ type FileType = 'img' | 'mp3' | 'midi'
*/ */
let magic: Promise<string> | string = new Promise((resolve) => { let magic: Promise<string> | string = new Promise((resolve) => {
// todo: hook module by what it does, not what it is called // todo: hook module by what it does, not what it is called
webpackGlobalOverride(AUTH_MODULE_ID, (_, r, t) => { // override webpackGlobalOverride(ALL, (_, r, t) => { // override
const fn = r.a const fn = r.a
if (typeof fn === 'function' && fn.length === ARG_NUMBER) {
t.d(r, 'a', () => { t.d(r, 'a', () => {
return (...args) => { return (...args) => {
if (magic instanceof Promise) { if (magic instanceof Promise) {
@ -25,6 +26,7 @@ let magic: Promise<string> | string = new Promise((resolve) => {
return fn(...args) as string return fn(...args) as string
} }
}) })
}
}) })
}) })