ajax劫持库ajaxHooker怎么取fetch得响应
{type: 'fetch', url: '/upload_json', method: 'GET', async: true}请问 ajax劫持库ajaxHooker怎么取fetch得响应,注意是fetch的响应,
request.response不能得到响应
已知xhr可以通过 modifyResponse达到修改。
{type: 'xhr', url: '/upload_json', method: 'POST', async: true}
request.response = async res => {
res.responseText = await modifyResponse(res.responseText);
}
是可以的吧
提问最好给一个自己能复现问题的样例页面和脚本代码
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script>
setTimeout(() => {
fetch("https://api.github.com/users/ruanyf")
.then((response) => response.json())
.then((json) => console.log(json))
.catch((err) => console.log("Request Failed", err));
}, 1000);
</script>
</head>
<body></body>
</html>
```
```js
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-03-31
// @descriptiontry to take over the world!
// @author You
// @match http://127.0.0.1:5500/index.html
// @icon https://www.google.com/s2/favicons?sz=64&domain=0.1
// @require https://scriptcat.org/lib/637/1.3.3/ajaxHooker.js
// @grant none
// ==/UserScript==
ajaxHooker.hook(request => {
console.log(request);
request.response = res => {
console.log(res.json);
};
});
```
页:
[1]