This tutorial walks you through creating a simple extension. You'll add a button to Google Chrome that, when clicked, displays an automatically generated page. The button and page will look something like this:
[PENDING: rewrite the example to use a browser action instead of a toolstrip]
To develop extensions for Google Chrome, you need to subscribe to the dev channel of Google Chrome for Windows.
Note: This tutorial requires Windows. You can try it on Linux and OS X, and it might work, but the extensions support is less stable on those platforms. We're working hard to bring them up to speed.
In this section, you'll write a toolstrip — an extension that puts a bit of UI into the toolbar at the bottom of the Google Chrome window.
c:\myext
,
but it can be anywhere.
manifest.json
,
and put this in it:
{ "name": "My First Extension", "version": "1.0", "description": "The first extension that I made.", "toolstrips": [ "my_toolstrip.html" ], "permissions": [ "http://api.flickr.com/" ] }
my_toolstrip.html
,
and put this in it:
<div class="toolstrip-button"> <span>Hello, World!</span> </div>
chrome://extensions
c:\myext
, for example)
and click the OK button.
If your extension is valid, information about it appears in the Installed extensions part of the Extensions page, as the following screenshot shows.
You should see the UI for your extension at the bottom left of the browser, looking something like this:
default appearance | initial onhover appearance | final onhover appearance |
Your extension's button is automatically styled to look like it belongs in the browser. If you put the cursor over the button, the button gets a nice, rounded edge, just like the buttons in the bookmark bar. After a while, a tooltip comes up, identifying the extension.
[PENDING: troubleshooting info should go here. what are symptoms of common typos, including misnamed files? what are the symptoms if you don't have the dev channel?]
In this step, you'll make your extension do something besides just look good.
Inside your extension's folder,
create a text file called hello_world.html
,
and add the following code to it:
CSS and JavaScript code for hello_world
Edit my_toolstrip.html
, so that it has the following code:
<div class="toolstrip-button" onclick="window.open('hello_world.html')"> <span>Hello, World!</span> </div>
hello_world.html
. It should look something like this:
If you don't see that page, try the instructions again, following them exactly. Don't try loading an HTML file that isn't in the extension's folder — it won't work!
[PENDING: Summarize what we did, what it means, what else we would've done if this were a real extension (e.g. package it), and where to find more information.]
.crx
file
so you can share it with your friends