title: Electron Manipulate/Intercept WebView Requests and Responses
body: <p>I want to create an Electron app that will use <a href="https://electronjs.org/docs/api/webview-tag" rel="noreferrer">webview</a> to display 3rd party content.</p>
  
  <p>I would like to be able to intercept all requests and responses from this webview. Sometimes I would like to manipulate this content, other times I would like to log it, and other times I’d like to do nothing.</p>
  
  <p>As one example for the responses, maybe a web server will respond with TypeScript code, maybe I want to take that response, and compile it to standard JavaScript.</p>
  
  <p>I have looked into <a href="https://discuss.atom.io/t/electron-intercept-http-request-response-on-browserwindow/21868/6?u=fishcharlie" rel="noreferrer">this page</a> but it looks like it is only possible to cancel requests, and manipulate the headers. The <a href="https://electronjs.org/docs/api/web-request" rel="noreferrer">WebRequest API</a> doesn't look to fit the needs of my use case since it only allows very minor manipulations of requests and responses.</p>
  
  <p>I have also considered setting up some time of web server that can act as a proxy, but I have concerns about that. I want to maintain user privacy, and I want to ensure that to the web servers that host the 3rd party content it looks like the request is coming from a browser like environment (ex. Electron webview) instead of a server. I know I can manipulate requests with the headers I send and such, but this whole solution is getting to be a lot more complicated, then I would like, but might be the only option.</p>
  
  <p>Any better ways to achieve this, and have more control over the Electron webview?</p>