Get source of downloaded urls through Chrome extension?

I am writing a Chrome extension that should parse the source code of a specific HTML page and all the external Javascript and CSS files that it loads without loading them again with an XHR request . - that is, he will analyze downloadable copies of the browser.

Is it possible? I know that it is possible to analyze the source of a separate open tab, but as long as these Javascript files are downloaded by the browser, they obviously will not occupy their own tab or window (only loading will be on them.) Please help

+4
source share
1 answer

There is no way out of the box to get the source of resources without resorting to the chrome.experimental.devtools.resources API.

However, when the experimental APIs are activated using the --enable-experimental-extension-apis switch, you can do the following to extract the source of each resource:

 chrome.experimental.devtools.resources.onFinished.addListener(function(resource) { resource.getContent(function(content, encoding) { if(encoding !== 'base64') { alert(content); } }); }); 
+1
source

All Articles