Building extension to capture http get response?

147 views
Skip to first unread message

densch123

unread,
Sep 18, 2022, 6:26:43 AM9/18/22
to Chromium Extensions
Hi, I am super new here.
I was wondering isnt there a proper forum for developing chrome extensions?
firefox has it.
has chrome only those weird "groups"?

Anyways what I am hoping to get some help with:
I wanna capture the network traffic going on on a certain website.
by manually looking in the network tab in the dev tools, I can see that a certain get request gets sent to the server of that site. (other requests are there too but I dont care about those)
and in it's response (which is jsut a super long string)
there is a section "&winnumber=X&" where x is a specific number.

I basically wanna find that request and extract that number from the response string.

Preferrably I want some popup to happen, so each time this kind of request happens, I want a popup to open and display that specific number from the requests response.

from some googling it seems to be quite hard to even capture network traffic in the first place.
But I hope you have a good idea nonetheless :-)

Thank you in advance to anyone willing to help :-)


PS: I read somewhere about a way where however I would have to have the devtools open in order to catch requests.
This kind of is no option for me since among other things I also do clicking on the website, so having the devtools open would "shrink" the actual screen and totally mess up any coordinates I had prepared for clicking.
so it would be preffered if it was a way that didnt change the screen in any way and jsut display that winnumber popup for example in the top left corner.

wOxxOm

unread,
Sep 18, 2022, 9:47:58 AM9/18/22
to Chromium Extensions, schue...@gmail.com
It can be done using a page script i.e. the code that runs in MAIN world. This page script will override/spoof/hook the function used by the site e.g. XMLHttpRequest.prototype.send or window.fetch and wait for the response, check it, and show the popup as a standard DOM element or a standard notification or it can send a message to the extension that will show a separate window using chrome.windows.create.

Running in MAIN world: I suggest using chrome.scripting.registerContentScripts (example)
Hooking XMLHttpRequest: see injected.js in this example or use xhook.js library or write a similar one yourself
Hooking window.fetch: see this short example and a blog article

densch123

unread,
Sep 19, 2022, 7:59:12 AM9/19/22
to Chromium Extensions, wOxxOm, densch123
Hm, I am not sure what I am doing but I got the code to this point where it can print the interesting parts to the console for me
https://pastebin.com/rRd23wAN

Now that I can at least connsole log the important things (like the winnumber) now In just need to figure out a way to communicate this to the outside world, maybe a popup that shows red black or green based on the drawn number.
Or something like that :-)
Reply all
Reply to author
Forward
0 new messages