fix: auth magic

This commit is contained in:
Xmader 2020-11-09 14:09:25 -05:00
parent b594dd9a1c
commit 4de6343cb8
No known key found for this signature in database
GPG key ID: A20B97FB9EB730E4

View file

@ -1,11 +1,11 @@
/* eslint-disable no-extend-native */ /* eslint-disable no-extend-native */
import scoreinfo from './scoreinfo' import scoreinfo from './scoreinfo'
import { webpackHook } from './webpack-hook' import { webpackHook, webpackGlobalOverride } from './webpack-hook'
import { hookNative } from './anti-detection'
const FILE_URL_MODULE_ID = 'iNJA' const FILE_URL_MODULE_ID = 'iNJA'
const MAGIC_REG = /^\d+(img|mp3|midi)\d(.+)$/ const AUTH_MODULE_ID = 'FNf8'
const MAGIC_ARG_INDEX = 3
type FileType = 'img' | 'mp3' | 'midi' type FileType = 'img' | 'mp3' | 'midi'
@ -18,16 +18,17 @@ const getApiUrl = (id: number, type: FileType, index: number): string => {
* I know this is super hacky. * I know this is super hacky.
*/ */
let magic: Promise<string> | string = new Promise((resolve) => { let magic: Promise<string> | string = new Promise((resolve) => {
hookNative(String.prototype, 'charCodeAt', (_fn, detach) => { webpackGlobalOverride(AUTH_MODULE_ID, (_, r, t) => { // override
return function (i: number) { const fn = r.a
const m = this.match(MAGIC_REG) t.d(r, 'a', () => {
if (m) { return (...args) => {
resolve(m[2]) if (typeof magic !== 'string') {
magic = m[2] magic = args[MAGIC_ARG_INDEX]
detach() resolve(magic)
}
return fn(...args) as string
} }
return _fn.call(this, i) as number })
}
}) })
}) })