mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
added open-my-page example
This commit is contained in:
14
open-my-page-button/README.md
Normal file
14
open-my-page-button/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# open-my-page
|
||||
|
||||
This extension includes:
|
||||
|
||||
* a background script, "background.js"
|
||||
* a browser action
|
||||
* a page "my-page.html"
|
||||
|
||||
All it does is: when the user clicks the button, open "my-page.html" in a new tab.
|
||||
|
||||
It shows:
|
||||
|
||||
* how to listen for browser action clicks in a background script
|
||||
* how to open a page packaged with your extension
|
||||
9
open-my-page-button/background.js
Normal file
9
open-my-page-button/background.js
Normal file
@@ -0,0 +1,9 @@
|
||||
chrome.browserAction.onClicked.addListener(openMyPage);
|
||||
|
||||
function openMyPage() {
|
||||
console.log("injecting");
|
||||
chrome.tabs.create({
|
||||
"url": chrome.extension.getURL("my-page.html")
|
||||
});
|
||||
}
|
||||
|
||||
1
open-my-page-button/button/LICENSE
Normal file
1
open-my-page-button/button/LICENSE
Normal file
@@ -0,0 +1 @@
|
||||
The icon "beasts.png" is taken from the IconBeast Lite iconset, and used under the terms of its license (http://www.iconbeast.com/faq/), with a link back to the website: http://www.iconbeast.com/free/.
|
||||
BIN
open-my-page-button/button/beasts.png
Normal file
BIN
open-my-page-button/button/beasts.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 550 B |
25
open-my-page-button/manifest.json
Normal file
25
open-my-page-button/manifest.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "open-my-page",
|
||||
"version": "1.0",
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "open-my-page-button@mozilla.org"
|
||||
}
|
||||
},
|
||||
|
||||
"permissions": [
|
||||
"tabs"
|
||||
],
|
||||
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
},
|
||||
|
||||
"browser_action": {
|
||||
"default_icon": "button/beasts.png"
|
||||
}
|
||||
|
||||
}
|
||||
12
open-my-page-button/my-page.html
Normal file
12
open-my-page-button/my-page.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>It's my page!</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user