新增网络请求拦截功能:在浏览器命令中添加请求和响应拦截选项,支持自定义拦截规则和内容替换

This commit is contained in:
fofolee
2025-01-24 18:19:18 +08:00
parent 9257faf132
commit e097678c93
4 changed files with 373 additions and 3 deletions

View File

@@ -9,8 +9,13 @@ const initCDP = async (targetId) => {
port,
});
const { Page, Runtime, Target, Network, Emulation, DOM } = client;
await Promise.all([Page.enable(), Runtime.enable(), DOM.enable()]);
const { Page, Runtime, Target, Network, Emulation, DOM, Fetch } = client;
await Promise.all([
Page.enable(),
Runtime.enable(),
DOM.enable(),
Fetch.enable(),
]);
return {
client,
@@ -20,6 +25,7 @@ const initCDP = async (targetId) => {
Network,
Emulation,
DOM,
Fetch,
};
} catch (err) {
console.log(err);