I'm working on a chrome extension to get some video content from a website. After some debugging of the website I've noticed that when content starts loading, an ajax request is made to a certain URL to get an m3u8
playlist file. I don't know all the chrome APIs available but in the past, I've used the webRequest API to block some specific URLs. My question is, is possible to intercept when a website is made an ajax request to a certain URL using the webRequest API and get that URL to use it later? If yes, can someone give me an example that can help me to write the code, please?
Asked
Active
Viewed 3,137 times
1
-
Does this answer your question? [Scrape / eavesdrop AJAX data using JavaScript?](https://stackoverflow.com/questions/13765031/scrape-eavesdrop-ajax-data-using-javascript) – Umair Khan Aug 05 '20 at 06:14
-
@UmairKhan not at all, I'm implementing `webRequest` api using a content script but also with the permissions declared I get this error in the extension manager `Uncaught TypeError: Cannot read property 'onCompleted' of undefined` – alfaun0 Aug 05 '20 at 06:35
-
webRequest can't be used a content script. It can be used in a background script. However, webRequest doesn't provide the response body so if you need it then don't use webRequest. Use XHR patching in [page context](/a/9517879) as explained in [that answer](https://stackoverflow.com/a/13768794). – wOxxOm Aug 05 '20 at 09:26
-
@wOxxOm I don't need the body of the response, but I've solved by using `webRequest.onCompleted`, I've made the mistake to use the webRequest inside the content script, to fix, I've moved the code into my background.js file and now I'm able to analyze the `xmlhttprequest` that are made by the page. – alfaun0 Aug 05 '20 at 10:23