AdguardTeam / AdguardTeam/Scriptlets

Enhance stealth about `Object.prototype.hasOwnProperty.call` of `XMLHttpRequest` related scriptlets

Offen
#576 0 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @maximtop Auf GitHub ansehen
Priority: P4
Vorherrschende Sprache
JavaScript
Sterne
195
Forks
33
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

```typescript
const Req = new XMLHttpRequest()
Req.open('OPTIONS', 'https://example.com')
Req.send()

const CleanReq = new XMLHttpRequest()

const Properties = ['status', 'statusText', 'readyState', 'response', 'responseURL', 'responseXML', 'setRequestHeader'] as const
Properties.forEach(Key => {
// 'call' indicates Function.prototype.call
console.log(`Object.prototype.hasOwnProperty.call(Req, ${Key})`, Object.prototype.hasOwnProperty.call(Req, Key))
console.log(`Compares XMLHttpReqeust.prototype with clean one ${Key}`, Req[Key] === CleanReq[Key])
})
```

```typescript
const Properties = ['status', 'statusText', 'readyState', 'response', 'responseURL', 'responseXML', 'setRequestHeader'] as const

const Req = new XMLHttpRequest()
Req.timeout = 1000
Req.onerror = () => { Func() }
Req.onabort = () => {}
Req.onload = () => { Func() }
Req.ontimeout = () => {}
Req.open('OPTIONS', 'https://example.com/', true)
Req.send()

const CleanReq = new XMLHttpRequest()

function Func() {
Properties.forEach(Key => {
// 'call' indicates Function.prototype.call
console.log(`Object.prototype.hasOwnProperty.call(Req, ${Key})`, Object.prototype.hasOwnProperty.call(Req, Key))
console.log(`Compares XMLHttpReqeust.prototype with clean one ${Key}`, Req[Key] === CleanReq[Key])
})
}
```

Compares execution result in DevTool of the above Typescript code snippet with and without `example.com#%#//scriptlet('prevent-xhr', 'example.com method:OPTIONS')`.

Related to https://github.com/uBlockOrigin/uAssets/issues/34177

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.