refactor: remove unused anti-detection code
This commit is contained in:
parent
954d0d5e65
commit
f1a6fd81eb
2 changed files with 0 additions and 45 deletions
|
@ -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)
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
|
|
13
src/btn.ts
13
src/btn.ts
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
import { loadMscore, WebMscore } from './mscore'
|
import { loadMscore, WebMscore } from './mscore'
|
||||||
import { hideFromArrFilter } from './anti-detection'
|
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
|
|
||||||
type BtnElement = HTMLButtonElement
|
type BtnElement = HTMLButtonElement
|
||||||
|
@ -42,11 +41,6 @@ export class BtnList {
|
||||||
constructor (private templateBtn: BtnElement) { }
|
constructor (private templateBtn: BtnElement) { }
|
||||||
|
|
||||||
private antiDetectionText = 'Download'
|
private antiDetectionText = 'Download'
|
||||||
private firstBtn = true
|
|
||||||
|
|
||||||
private hide (el: HTMLElement) {
|
|
||||||
hideFromArrFilter(el)
|
|
||||||
}
|
|
||||||
|
|
||||||
add (options: BtnOptions): BtnElement {
|
add (options: BtnOptions): BtnElement {
|
||||||
const btn = this.templateBtn.cloneNode(true) as HTMLButtonElement
|
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 => {
|
const setText = (str: string): void => {
|
||||||
textNode.textContent = str
|
textNode.textContent = str
|
||||||
|
|
Loading…
Reference in a new issue