-
-
Save adityabhaskar/a51ec0f92019a80aa0e1b2899533d796 to your computer and use it in GitHub Desktop.
MV3 webRequest demo. To view the console, you may need to manually open devtools for the service worker. On Chrome, visit chrome://serviceworker-internals and search for the service worker registered to `chrome-extension://<extension-id>/` where extension-id is the ID of your extension.
This file contains 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
// Copyright 2020 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
chrome.webRequest.onBeforeRequest.addListener( | |
(details) => { | |
console.log('onBeforeRequest', details) | |
}, | |
{urls: ["<all_urls>"]}, | |
); |
This file contains 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
Copyright 2020 Google LLC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
https://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. |
This file contains 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
{ | |
"name": "MV3 WebRequest Demo", | |
"version": "1.0", | |
"manifest_version": 3, | |
"permissions": [ | |
"webRequest" | |
], | |
"host_permissions": [ | |
"<all_urls>" | |
], | |
"background": { | |
"service_worker": "background.js" | |
} | |
} |
Thanks man, This was really helpful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was having a problem using this API, in the end, comparing my code to yours I found out that the problem has that I was defining the handler function after adding the listener.
I am still a little confused about when the order of the code matters in javascript, but from now on, I'll always add listeners at the end of the code hahaha
Thank you a lot, S2