From f1a6fd81eb5961470d9936197bc6b51b71dfa939 Mon Sep 17 00:00:00 2001 From: Xmader Date: Sat, 7 Nov 2020 20:53:31 -0500 Subject: [PATCH] refactor: remove unused anti-detection code --- src/anti-detection.ts | 32 -------------------------------- src/btn.ts | 13 ------------- 2 files changed, 45 deletions(-) diff --git a/src/anti-detection.ts b/src/anti-detection.ts index aeed983..134920e 100644 --- a/src/anti-detection.ts +++ b/src/anti-detection.ts @@ -47,35 +47,3 @@ export function hookNative ( }) } } - -export const hideFromArrFilter = (() => { - const l = new Set() - - const qsaHook = (_fn) => { - return function (...args) { - const nodes = _fn.apply(this, args) - const results = Array.prototype.filter.call(nodes, (e) => !l.has(e)) - - results.forEach((e) => { - Object.defineProperty(e, 'querySelectorAll', { - value: qsaHook, - }) - }) - - // convert back to a NodeList/HTMLCollection instead of an Array - Object.setPrototypeOf(results, Object.getPrototypeOf(nodes)) - - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return results - } - } - hookNative(Element.prototype, 'querySelectorAll', qsaHook) - hookNative(document, 'querySelectorAll', qsaHook) - - hookNative(Element.prototype, 'getElementsByClassName', qsaHook) - hookNative(document, 'getElementsByClassName', qsaHook) - - return (item: any) => { - l.add(item) - } -})() diff --git a/src/btn.ts b/src/btn.ts index b3464ca..717c7f7 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -1,6 +1,5 @@ import { loadMscore, WebMscore } from './mscore' -import { hideFromArrFilter } from './anti-detection' import i18n from './i18n' type BtnElement = HTMLButtonElement @@ -42,11 +41,6 @@ export class BtnList { constructor (private templateBtn: BtnElement) { } private antiDetectionText = 'Download' - private firstBtn = true - - private hide (el: HTMLElement) { - hideFromArrFilter(el) - } add (options: BtnOptions): BtnElement { const btn = this.templateBtn.cloneNode(true) as HTMLButtonElement @@ -71,13 +65,6 @@ export class BtnList { }, }) }) - // hide this button from Array.prototype.filter - if (this.firstBtn) { - this.firstBtn = false - } else { - this.hide(btn) - this.hide(textNode) - } const setText = (str: string): void => { textNode.textContent = str