added open-my-page example

This commit is contained in:
Will Bamberg
2015-09-17 10:30:35 -07:00
parent 9ccecbf206
commit 753b8df80c
6 changed files with 61 additions and 0 deletions

View 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

View 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")
});
}

View 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/.

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View 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"
}
}

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>It's my page!</h1>
</body>
</html>