I'm re-posting my question from Chromium-extensions google group here.
In my extension, I want to cancel some webRequests based on url pattern. My problem is that, if I return {cancel:true} in the onBeforeRequest event listener, the browser would redirect to a page telling me that the request is blocked by some extension. But I just want to cancel the request silently(as nothing happened).
I have also tried to return {redirectUrl:""} in the onBeforeRequest event listener, the console would log an error saying that "" was not a valid URL, and a bar appeared at the bottom of the browser, saying "Waiting for extension". To dismiss that bar, I then run content script "window.stop()" in that web page. That works sometimes, but not always. So I wonder if someone has any better solution. Thanks!!
Type the url in the main input field and choose the method to use: GET/POST/PUT/DELETE/PATCH. Click on the arrow "Send" or press Ctrl+Enter. You'll see info about the response (time, size, type) and you'll be able to see the content response in the response section.
To use the webRequest API for a given host, an extension must have the "webRequest" API permission and the host permission for that host. To use the "blocking" feature, the extension must also have the "webRequestBlocking" API permission.
# Life cycle of requests. The web request API defines a set of events that follow the life cycle of a web request. You can use these events to observe and analyze traffic. Certain synchronous events will allow you to intercept, block, or modify a request.
Needs to be called when the behavior of the webRequest handlers has changed to prevent incorrect handling due to caching. This function call is expensive. Don't call it often. Fired when an extension's proposed modification to a network request is ignored. This happens in case of conflicts with other extensions.
Starting from Chrome 72, an extension will be able to intercept a request only if it has host permissions to both the requested URL and the request initiator. As the following sections explain, events in the web request API use request IDs, and you can optionally specify filters and extra information when you register event listeners.
Use the chrome.webRequest API to observe and analyze traffic and to intercept, block, or modify requests in-flight. You must declare the "webRequest" permission in the extension manifest to use the web request API, along with the necessary host permissions.
The webRequest API let extension developers intercept all network requests, pause them while they evaluated and blocked or modify them in JavaScript, and only then begin fulfilling the requests. These are quite powerful capabilities with big privacy, security, and performance implications.
return {redirectUrl: 'javascript:void(0)'};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With