andrewvy / chrome-remote-interface

Elixir Client for the Chrome Debugger Protocol
https://hexdocs.pm/chrome_remote_interface
66 stars 31 forks source link

Is Request Interception supported? #33

Open jackalcooper opened 5 years ago

jackalcooper commented 5 years ago

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
andrewvy commented 5 years ago

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:

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. :)

jackalcooper commented 5 years ago

Thanks for reply. I will give it a try. 👍