From 4de6343cb8f3e144f3080989b3478069b1037f2c Mon Sep 17 00:00:00 2001 From: Xmader Date: Mon, 9 Nov 2020 14:09:25 -0500 Subject: [PATCH] fix: auth magic --- src/file.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/file.ts b/src/file.ts index c4a8ceb..6be081d 100644 --- a/src/file.ts +++ b/src/file.ts @@ -1,11 +1,11 @@ /* eslint-disable no-extend-native */ import scoreinfo from './scoreinfo' -import { webpackHook } from './webpack-hook' -import { hookNative } from './anti-detection' +import { webpackHook, webpackGlobalOverride } from './webpack-hook' 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' @@ -18,16 +18,17 @@ const getApiUrl = (id: number, type: FileType, index: number): string => { * I know this is super hacky. */ let magic: Promise | string = new Promise((resolve) => { - hookNative(String.prototype, 'charCodeAt', (_fn, detach) => { - return function (i: number) { - const m = this.match(MAGIC_REG) - if (m) { - resolve(m[2]) - magic = m[2] - detach() + webpackGlobalOverride(AUTH_MODULE_ID, (_, r, t) => { // override + const fn = r.a + t.d(r, 'a', () => { + return (...args) => { + if (typeof magic !== 'string') { + magic = args[MAGIC_ARG_INDEX] + resolve(magic) + } + return fn(...args) as string } - return _fn.call(this, i) as number - } + }) }) })