1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
<div id="pageData-name" class="pageData">Tutorial: Getting Started (Hello, World!)</div>
<div id="pageData-showTOC" class="pageData">true</div>
<p>
This tutorial walks you through creating a simple extension.
You'll add an icon to Google Chrome
that, when clicked, displays an automatically generated page.
The icon and page will look something like this:
</p>
<img src="images/hello-world-small.png"
width="300" height="221"
alt="a window with a grid of images related to HELLO WORLD" />
<p>
You can develop extensions using any release of Google Chrome,
on Windows, Mac, or Linux.
</p>
<h2 id="load">Create and load an extension</h2>
<p>
In this section, you'll write an extension
that adds a <em>browser action</em>
to the toolbar of Google Chrome.
</p>
<ol>
<li>
Create a folder somewhere on your computer to contain your extension's code.
</li>
<li>
Inside your extension's folder,
create a text file called <strong><code>manifest.json</code></strong>,
and put this in it:
<pre>{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"http://api.flickr.com/"
]
}</pre>
</li>
<li>
Copy this icon to the same folder:<br>
<table cellpadding="0" cellspacing="0" style="border:0">
<tr>
<td style="text-align:center; border:0;"><a
href="examples/tutorials/getstarted/icon.png"
><img src="examples/tutorials/getstarted/icon.png"
width="19" height="19" border="0"></a><br>
<a href="examples/tutorials/getstarted/icon.png"
>Download icon.png</a></td>
</tr>
</table>
</li>
<li id="load-ext"> Load the extension.
<ol type="a">
<li>
Bring up the extensions management page
by clicking the Tools menu
<img src="images/toolsmenu.gif" width="43" height="34" alt=""
align="absmiddle" style="margin:0; padding:0">
(or the Window menu on Mac)
and choosing <b>Extensions</b>.
</li>
<li>
If <b>Developer mode</b> has a + by it,
click the + to add developer information to the page.
The + changes to a -,
and more buttons and information appear.
</li>
<li>
Click the <b>Load unpacked extension</b> button.
A file dialog appears.
</li>
<li>
In the file dialog,
navigate to your extension's folder
and click <b>OK</b>.
</li>
</ol> </li>
</ol>
<p>
If your extension is valid,
its icon appears next to the address bar,
and information about the extension
appears in the extensions page,
as the following screenshot shows.
</p>
<p>
<a href="images/load_after.png"><img
src="images/load_after_small.png"
width="300" height="132" /></a>
</p>
<h2 id="code">Add code to the extension</h2>
<p> In this step, you'll make your extension <em>do</em> something besides just look good. </p>
<ol>
<li>
<p> Edit <code>manifest.json</code> to add the following line:</p>
<pre>
...
"browser_action": {
"default_icon": "icon.png"<b>,
"popup": "popup.html"</b>
},
...
</pre>
<p> Inside your extension's folder,
create a text file called <strong><code>popup.html</code></strong>,
and add the following code to it:</p>
<blockquote> <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/tutorials/getstarted/popup.html?content-type=text/plain"
target="_blank">CSS
and JavaScript code for hello_world</a></blockquote>
</li>
<li>
Return to the extensions management page,
and click the <b>Reload</b> button
to load the new version of the extension.</li>
<li>Click the extension's icon.
A popup should appear that displays the contents of
<code>popup.html</code>. </li>
</ol>
<p> It should look something like this:</p>
<img src="images/hello-world.png"
width="500" height="369"
alt="a popup with a grid of images related to HELLO WORLD" />
<p> If you don't see the popup,
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! </p>
<h2 id="summary">Now what?</h2>
<!-- [PENDING: Summarize what we did, what it means, what else we would've done if this were a real extension (e.g. package/zip it), and where to find more information.] -->
<p>
Here are some suggestions for what to do next:
</p>
<ul>
<li>
Read the <a href="overview.html">Overview</a>
</li>
<li>
Learn how to debug extensions by following the
<a href="tut_debugging.html">debugging tutorial</a>
</li>
<li>
Keep up to date with the latest news:
<a href="http://groups.google.com/a/chromium.org/group/chromium-extensions/subscribe">subscribe to chromium-extensions</a>
</li>
<li>
Look at some
<a href="samples.html">sample extensions</a>
</li>
<li>
Watch some
<a href="http://www.youtube.com/view_play_list?p=CA101D6A85FE9D4B">videos</a>, such as
<a href="http://www.youtube.com/watch?v=e3McMaHvlBY&feature=PlayList&p=CA101D6A85FE9D4B&index=3">How to build an extension</a>
</li>
</ul>
|