To obtain all the webpage resources using a Chrome extension, you can use the Chrome developer tools API. Here's how:
Here's a sample code snippet that shows how to get the resource URLs:
chrome.devtools.network.onRequestFinished.addListener(
function(request) {
var har = chrome.devtools.network.getHAR(function(result) {
var entries = result.entries;
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var url = entry.request.url;
// Store the URL in an array or object
}
// Send the array or object to the popup or content script
chrome.runtime.sendMessage({resources: resources});
});
}
);
Asked: 2021-07-08 11:00:00 +0000
Seen: 19 times
Last updated: Jun 26 '22