From 13afe431c8498ca1cbdeb9c65391e97d766f0c88 Mon Sep 17 00:00:00 2001 From: Xmader Date: Sat, 7 Nov 2020 21:03:26 -0500 Subject: [PATCH] refactor: hookNative --- src/anti-detection.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/anti-detection.ts b/src/anti-detection.ts index 134920e..8d916de 100644 --- a/src/anti-detection.ts +++ b/src/anti-detection.ts @@ -5,20 +5,20 @@ * make hooked methods "native" */ export const makeNative = (() => { - const l = new Set() + const l = new Map() hookNative(Function.prototype, 'toString', (_toString) => { return function () { if (l.has(this)) { - // "function () {\n [native code]\n}" - return _toString.call(parseInt) as string + const _fn = l.get(this) || parseInt // "function () {\n [native code]\n}" + return _toString.call(_fn) as string } return _toString.call(this) as string } }, true) - return (fn: Function) => { - l.add(fn) + return (fn: Function, original: Function) => { + l.set(fn, original) } })() @@ -40,10 +40,10 @@ export function hookNative ( target[method] = hookedFn if (!async) { - makeNative(hookedFn as any) + makeNative(hookedFn as any, _fn as any) } else { setTimeout(() => { - makeNative(hookedFn as any) + makeNative(hookedFn as any, _fn as any) }) } }