fix: anti-detection
This commit is contained in:
parent
67dc352004
commit
f51e0742d7
2 changed files with 28 additions and 9 deletions
26
src/anti-detection.ts
Normal file
26
src/anti-detection.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* eslint-disable no-extend-native */
|
||||||
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make hooked methods "native"
|
||||||
|
*/
|
||||||
|
export const makeNative = (() => {
|
||||||
|
const l: Set<Function> = new Set()
|
||||||
|
|
||||||
|
const _toString = Function.prototype['toString']
|
||||||
|
const toString = function () {
|
||||||
|
if (l.has(this)) {
|
||||||
|
// "function () {\n [native code]\n}"
|
||||||
|
return _toString.call(parseInt) as string
|
||||||
|
}
|
||||||
|
return _toString.call(this) as string
|
||||||
|
}
|
||||||
|
Function.prototype.toString = toString
|
||||||
|
|
||||||
|
// make `Function.prototype.toString` itself "native"
|
||||||
|
l.add(toString)
|
||||||
|
|
||||||
|
return (fn: Function) => {
|
||||||
|
l.add(fn)
|
||||||
|
}
|
||||||
|
})()
|
11
src/file.ts
11
src/file.ts
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import scoreinfo from './scoreinfo'
|
import scoreinfo from './scoreinfo'
|
||||||
import { webpackHook } from './webpack-hook'
|
import { webpackHook } from './webpack-hook'
|
||||||
|
import { makeNative } from './anti-detection'
|
||||||
|
|
||||||
const FILE_URL_MODULE_ID = 'iNJA'
|
const FILE_URL_MODULE_ID = 'iNJA'
|
||||||
const MAGIC_REG = /^\d+(img|mp3|midi)\d(.+)$/
|
const MAGIC_REG = /^\d+(img|mp3|midi)\d(.+)$/
|
||||||
|
@ -35,15 +36,7 @@ let magic: Promise<string> | string = new Promise((resolve) => {
|
||||||
}
|
}
|
||||||
target[method] = hookFn
|
target[method] = hookFn
|
||||||
|
|
||||||
// make hooked methods "native"
|
makeNative(hookFn)
|
||||||
const _toString = Function.prototype['toString']
|
|
||||||
Function.prototype.toString = function s () {
|
|
||||||
if (this === hookFn || this === s) {
|
|
||||||
// "function () {\n [native code]\n}"
|
|
||||||
return _toString.call(parseInt) as string
|
|
||||||
}
|
|
||||||
return _toString.call(this) as string
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getFileUrl = async (type: FileType, index = 0): Promise<string> => {
|
export const getFileUrl = async (type: FileType, index = 0): Promise<string> => {
|
||||||
|
|
Loading…
Reference in a new issue