Minimal working Manifest V3 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 2019 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
chrome.browserAction.onClicked.addListener(handleBrowserActionClicked) | |
function handleBrowserActionClicked(tab) { | |
const opts = { | |
url: chrome.runtime.getURL('popup.html') | |
}; | |
chrome.windows.create(opts, handleWindowCreated); | |
} | |
function handleWindowCreated(window) { | |
console.log('done'); | |
} |
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 2019 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": "Basic MV3 Demo", | |
"version": "0.1.0", | |
"manifest_version": 3, | |
"background": { | |
"service_worker": "background.js" | |
}, | |
"browser_action": { | |
"default_title": "Click me to open a new window" | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<!-- | |
Copyright 2019 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 | |
--> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h2>Hello, world!</h2> | |
</body> | |
</html> |
Thank both of you for this example, it really helped!
If anybody needs a minimal template of such an extension to start development, I made this repo. It also gives some information the official documentation is currently lacking.
I hope this can help as well!
Hi, thank you for this example!
Changes I made to make this work:
background.js
3 chrome.action.onClicked.addListener(handleBrowserActionClicked)manifest
8 "action": {Hope this helps the next person :)
Thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thank you for this example!
Changes I made to make this work:
background.js
3 chrome.action.onClicked.addListener(handleBrowserActionClicked)
manifest
8 "action": {
Hope this helps the next person :)