AdguardTeam / AdguardTeam/Scriptlets

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

Open
#576 0 comments 0 reactions 1 assignee Claimed by @maximtop View on GitHub
Priority: P4
Dominant language
JavaScript
Stars
195
Forks
33
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.