refactor: remove unused anti-detection code

This commit is contained in:
Xmader 2020-11-07 20:53:31 -05:00
parent 954d0d5e65
commit f1a6fd81eb
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
2 changed files with 0 additions and 45 deletions

View File

@ -47,35 +47,3 @@ export function hookNative<T extends object, M extends (keyof T)> (
})
}
}
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)
}
})()

View File

@ -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