From ac99e8373d79f2bf159d31eaa88ddf3557dd3dd0 Mon Sep 17 00:00:00 2001 From: Xmader Date: Wed, 18 Nov 2020 13:57:56 -0500 Subject: [PATCH] fix: auth magics --- src/file.ts | 23 ++++++++++++++--------- src/webpack-hook.ts | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/file.ts b/src/file.ts index bef7308..be4574a 100644 --- a/src/file.ts +++ b/src/file.ts @@ -5,11 +5,11 @@ import { onPackLoad, webpackContext } from './webpack-hook' type FileType = 'img' | 'mp3' | 'midi' -const AUTH_REG = /[0-9a-f]{40}/ +const AUTH_REG = /,(function\(\)\{var \w=Array.prototype.slice.*?)\)\[/ enum PACK_ID { - img = 9, - midi = 118, - mp3 = 74, + img = 'F/w+', + midi = 'yihj', + mp3 = '2oYV', } /** @@ -18,14 +18,19 @@ enum PACK_ID { const magicHookConstr = (type: FileType) => { // request pack // eslint-disable-next-line no-void, @typescript-eslint/no-unsafe-return - void webpackContext.then((ctx) => ctx.e(PACK_ID[type])).then(console.log) + void webpackContext.then((ctx) => ctx.e(PACK_ID[type])) return new Promise((resolve) => { onPackLoad((pack) => { if (pack[0].includes(PACK_ID[type])) { Object.values(pack[1]).forEach((mod) => { const m = mod.toString().match(AUTH_REG) - if (m && m[0]) resolve(m[0]) + if (m) { + const code = m[1] + // eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval + const magic = Function(`return (${code})`)() + resolve(magic) + } }) } }) @@ -33,9 +38,9 @@ const magicHookConstr = (type: FileType) => { } const magics: Record> = { - img: Promise.resolve('8c022bdef45341074ce876ae57a48f64b86cdcf5'), - midi: Promise.resolve('38fb9efaae51b0c83b5bb5791a698b48292129e7'), - mp3: Promise.resolve('63794e5461e4cfa046edfbdddfccc1ac16daffd2'), + img: magicHookConstr('img'), + midi: magicHookConstr('midi'), + mp3: magicHookConstr('mp3'), } const getApiUrl = (type: FileType, index: number): string => { diff --git a/src/webpack-hook.ts b/src/webpack-hook.ts index 4cb7c38..5db01ab 100644 --- a/src/webpack-hook.ts +++ b/src/webpack-hook.ts @@ -9,7 +9,7 @@ interface Module { (module, exports, __webpack_require__): void; } -type WebpackJson = [number[], { [id: string]: Module }, any[]?][] +type WebpackJson = [(number | string)[], { [id: string]: Module }, any[]?][] const moduleLookup = (id: string, globalWebpackJson: WebpackJson) => { const pack = globalWebpackJson.find(x => x[1][id])!