fix: auth magics
This commit is contained in:
parent
0e96b9dc08
commit
06b7bda575
1 changed files with 30 additions and 9 deletions
39
src/file.ts
39
src/file.ts
|
@ -5,24 +5,45 @@ import { onPackLoad, webpackContext } from './webpack-hook'
|
||||||
|
|
||||||
type FileType = 'img' | 'mp3' | 'midi'
|
type FileType = 'img' | 'mp3' | 'midi'
|
||||||
|
|
||||||
const AUTH_REG = /,(function\(\)\{var \w=Array.prototype.slice.*?)\)\[/
|
const AUTH_REG = /,((\d+\.\..+?)?function\(\)\{var \w=Array.prototype.slice.*?)\)(\[|\.then)/
|
||||||
enum PACK_ID {
|
const PACK_ID_REG = /\((\{.*?"\})\[\w\]\|\|\w\)/
|
||||||
img = 'F/w+',
|
const packIdPromise: Promise<Record<FileType, (string | number)>> = webpackContext.then((ctx) => {
|
||||||
midi = 'yihj',
|
const ids = {
|
||||||
mp3 = '2oYV',
|
img: '9',
|
||||||
}
|
midi: '',
|
||||||
|
mp3: '',
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const fn = ctx.e.toString()
|
||||||
|
const packsData = fn.match(PACK_ID_REG)[1] as string
|
||||||
|
// eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
|
||||||
|
const packs = Function(`return (${packsData})`)() as { [id: string]: string }
|
||||||
|
|
||||||
|
Object.entries(packs).forEach(([id, name]) => {
|
||||||
|
if (name.includes('audio') && !ids['mp3']) ids['mp3'] = id
|
||||||
|
if (name.includes('piano_roll') && !ids['midi']) ids['midi'] = id
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I know this is super hacky.
|
* I know this is super hacky.
|
||||||
*/
|
*/
|
||||||
const magicHookConstr = (type: FileType) => {
|
const magicHookConstr = async (type: FileType) => {
|
||||||
|
const packId = await packIdPromise
|
||||||
|
|
||||||
// request pack
|
// request pack
|
||||||
// eslint-disable-next-line no-void, @typescript-eslint/no-unsafe-return
|
// eslint-disable-next-line no-void, @typescript-eslint/no-unsafe-return
|
||||||
void webpackContext.then((ctx) => ctx.e(PACK_ID[type]))
|
void webpackContext.then((ctx) => ctx.e(packId[type]))
|
||||||
|
|
||||||
return new Promise<string>((resolve) => {
|
return new Promise<string>((resolve) => {
|
||||||
onPackLoad((pack) => {
|
onPackLoad((pack) => {
|
||||||
if (pack[0].includes(PACK_ID[type])) {
|
if (pack[0].includes(packId[type]) || pack[0].includes(+packId[type])) {
|
||||||
Object.values(pack[1]).forEach((mod) => {
|
Object.values(pack[1]).forEach((mod) => {
|
||||||
const m = mod.toString().match(AUTH_REG)
|
const m = mod.toString().match(AUTH_REG)
|
||||||
if (m) {
|
if (m) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue