AdguardTeam / AdguardTeam/Scriptlets

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

未关闭
#576 0 条评论 0 个 reaction 已指派 1 人 已被 @maximtop 认领 在 GitHub 查看
Priority: P4
主要语言
JavaScript
星标
195
派生
33
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。