chrome-remote-interface
chrome-remote-interface copied to clipboard
Is Request Interception supported?
For instance
page.setRequestInterception(true)
page.on('request', request => {
if (request.resourceType() === 'image' ||
request.resourceType() === 'stylesheet' ||
request.resourceType() === 'stylesheet' ||
)
request.abort();
else {
request.continue();
}
});
return page
Since this library is meant to be a thin wrapper around the RPC framework, there's quite a bit of manual effort involved in getting this to work. However, this is fully supported through Chrome's debugger protocol. This is a bit of speculation of how you would probably go about achieving this:
- Enable Network domain events through Network.enable RPC call.
- Enable request interception through Network.setRequestInterception
- Then, subscribe to the network event for Network.requestIntercepted with ChromeRemoteInterface.PageSession.subscribe
- Then call
Network.continueInterceptedRequest
with details on how you would want to continue the intercepted request, using the intercepted ID from the interception event.
In the future, I'd like to make a higher-level API that provides some niceties like the above, mimicking some of the convenience features of Puppeteer. :)
Thanks for reply. I will give it a try. 👍