0

I am trying to create a chrome extension that checks if a person is trying to upload image from a webpage, this image is copied and uploaded by chrome extension.

I am trying to achieve this using chrome.webRequest - monitor the requests and try to find the image payload in base64. So far all of my efforts have failed.

The website I am playing with is using using plupload.Uploader to upload images so I really don't have a choice to play with the DOM and see how it works.

Here is what I am trying to do with my code

chrome.webRequest.onBeforeRequest.addListener(function (details){

    console.log(details)
}, {
    urls: ["http://*/*", "https://*/*"],
    types: [ "xmlhttprequest"]
},
["requestBody"])

And the website is sending POST requests whenever I upload an image (screenshot attached) enter image description here

So my questions are 1. Is this approach of mine to monitor outgoing requests for payload OK? 2. Does extension support what I am trying to do in here?

Talha Masood
  • 993
  • 1
  • 7
  • 22
  • As you can see in the [documentation](https://developer.chrome.com/extensions/webRequest#event-onBeforeRequest) there's no such thing as `details.uploadData`. Also, I think it'd simply spoof XHR or fetch in a [page script](https://stackoverflow.com/a/9517879) injected from a content script. – wOxxOm Jun 05 '17 at 06:58
  • @wOxxOm sorry about the `details.uploadData` in the code. That was just meant for testing. So you are suggesting that I inject a content script in the code that monitors every xhr request that is going out of the page? I know we can inject a content script but how can we act from there? – Talha Masood Jun 05 '17 at 07:56
  • Yes, see the link in my comment, and use it to insert a page script that spoofs XHR or fetch (examples can be easily googled). – wOxxOm Jun 05 '17 at 07:58

0 Answers0