Last active
October 22, 2025 16:43
-
-
Save kzar/01ea05e4758f5edbeebf9d09766ce456 to your computer and use it in GitHub Desktop.
Log chrome webRequest and webNavigation events for blob URLs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function logEvent(type, details) | |
| { | |
| if (details.url.startsWith("blob")) | |
| console.log(type, details); | |
| } | |
| /* WebNavigation */ | |
| chrome.webNavigation.onBeforeNavigate.addListener(details => | |
| { | |
| logEvent("onBeforeNavigate", details); | |
| }); | |
| chrome.webNavigation.onCommitted.addListener(details => | |
| { | |
| logEvent("onCommitted", details); | |
| }); | |
| chrome.webNavigation.onDOMContentLoaded.addListener(details => | |
| { | |
| logEvent("onDOMContentLoaded", details); | |
| }); | |
| chrome.webNavigation.onCompleted.addListener(details => | |
| { | |
| logEvent("onCompleted", details); | |
| }); | |
| /* WebRequest */ | |
| chrome.webRequest.onBeforeRequest.addListener(details => | |
| { | |
| logEvent("onBeforeRequest", details); | |
| }, {urls: ["<all_urls>"]}, ["blocking", "requestBody"]); | |
| chrome.webRequest.onBeforeSendHeaders.addListener(details => | |
| { | |
| logEvent("onBeforeSendHeaders", details); | |
| }, {urls: ["<all_urls>"]}, ["blocking", "requestHeaders"]); | |
| chrome.webRequest.onSendHeaders.addListener(details => | |
| { | |
| logEvent("onSendHeaders", details); | |
| }, {urls: ["<all_urls>"]}, ["requestHeaders"]); | |
| chrome.webRequest.onHeadersReceived.addListener(details => | |
| { | |
| logEvent("onHeadersReceived", details); | |
| }, {urls: ["<all_urls>"]}, ["blocking", "responseHeaders"]); | |
| chrome.webRequest.onResponseStarted.addListener(details => | |
| { | |
| logEvent("onResponseStarted", details); | |
| }, {urls: ["<all_urls>"]}, ["responseHeaders"]); | |
| chrome.webRequest.onBeforeRedirect.addListener(details => | |
| { | |
| logEvent("onBeforeRedirect", details); | |
| }, {urls: ["<all_urls>"]}, ["responseHeaders"]); | |
| chrome.webRequest.onCompleted.addListener(details => | |
| { | |
| logEvent("onCompleted", details); | |
| }, {urls: ["<all_urls>"]}, ["responseHeaders"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TL;DR - Sorry, doesn't work. Theoretically possible, but only with the
scriptingAPI, as far as I can tell.As per Chromium issue 41406885,
blob:URIs cannot be intercepted bywebRequest. Having been trying to do the same thing in my own extension,webRequest,declarativeNetRequest, evendebuggerdoesn't seem to be able to intercept them. Thus, I don't believe it's possible without injecting a script into every tab and overriding every method of producing a blob, which I will also be attempting. It's worth noting that I haven't tried usingwebNavigation, but I highly doubt it would have much success, either.