Skip to content

Commit

Permalink
fix: anti-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmader committed Nov 6, 2020
1 parent 763c592 commit 06dd28f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/anti-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ export function hookNative<T extends object, M extends (keyof T)> (
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)
Expand Down

0 comments on commit 06dd28f

Please sign in to comment.