How to get the request initiator script in a Chrome web extension?

57 Views Asked by At

I'm working a Chrome extension in manifest V3. I would like to see what script is the initiator of a request. In the Chrome developer tools, under the network tab, you can see this in the "initiator" column. However, when I log the initiator in my extension, only the url shows up.

chrome.webRequest.onBeforeRequest.addListener(manageRequestList, { urls: ["<all_urls>"] }, ["requestBody"]);

function manageRequestList(request) {
    console.log(request.initiator);
    // logs: "https://www.google.com"
}

Current outcome: https://www.google.com. Preferred outcome: scriptname.js

Is this possible and if yes, how?

0

There are 0 best solutions below