Skip to content

Instantly share code, notes, and snippets.

@dotproto
Last active July 16, 2020 14:09
Show Gist options
  • Save dotproto/1da2d4512685c8f6c7f8e2e83a2bbbae to your computer and use it in GitHub Desktop.
Save dotproto/1da2d4512685c8f6c7f8e2e83a2bbbae 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.
// Copyright 2020 Google LLC.
// SPDX-License-Identifier: Apache-2.0
chrome.webRequest.onBeforeRequest.addListener(
(details) => {
console.log('onBeforeRequest', details)
},
{urls: ["<all_urls>"]},
);
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.
{
"name": "MV3 WebRequest Demo",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"webRequest"
],
"host_permissions": [
"<all_urls>"
],
"background": {
"service_worker": "background.js"
}
}
@adityabhaskar
Copy link

Thanks for this, @dotproto.

And muchos thanks for engaging on the Google group.

Cheers!

Adi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment