From 06dd28f515ee3173aadb240fb8a395f89f874101 Mon Sep 17 00:00:00 2001 From: Xmader Date: Fri, 6 Nov 2020 12:37:32 -0500 Subject: [PATCH] fix: anti-detection --- src/anti-detection.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/anti-detection.ts b/src/anti-detection.ts index 83516e3..5b2819e 100644 --- a/src/anti-detection.ts +++ b/src/anti-detection.ts @@ -51,13 +51,15 @@ export function hookNative ( export const hideFromArrFilter = (() => { const l = new Set() - hookNative(Array.prototype, 'filter', (_filter) => { + const qsaHook = (_fn) => { return function (...args) { - const arr = _filter.apply(this, args) + const arr = _fn.apply(this, args) // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return _filter.call(arr, (e) => !l.has(e)) + return Array.prototype.filter.call(arr, (e) => !l.has(e)) } - }) + } + hookNative(Element.prototype, 'querySelectorAll', qsaHook) + hookNative(document, 'querySelectorAll', qsaHook) return (item: any) => { l.add(item)