You can create and develop extensions using any release of Google Chrome, on Windows, Mac, or Linux.
Create and load an extension
First i will write an extension that adds a browser action to the toolbar of Google Chrome.
- Create a folder on your computer to contain your extension's code.
- Inside your extension's folder, create a text file called
manifest.json
, and put this code in it:
{ "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/" ] }
- Copy this icon to the same folder:
- Load the extension.
- Bring up the extensions management page by clicking the Tools menu
(or the Window menu on Mac) and choosing Extensions. (If you're using version 6 or later, choose Tools > Extensions.) - If Developer mode has a + by it, click the + to add developer information to the page. The + changes to a -, and more buttons and information appear.
- Click on Load unpacked extension button. A file dialog appears.
- In the file dialog, navigate to your extension's folder and click OK.
- Bring up the extensions management page by clicking the Tools menu
Add code to the extension
Second step, you'll make your extension do something besides just look good.
- Edit
manifest.json
to add the following line:
... "browser_action": { "default_icon": "icon.png", "popup": "popup.html" }, ...
Inside your extension's folder, create a text file calledpopup.html
, and download this file add the code to it
- Return to the extensions management page, and click the Reload button to load the new version of the extension.
- Click the extension's icon. A popup should appear that displays the contents of
popup.html
.
comments
0 Responses to "How to Write a Chrome Extension in Two Easy Steps"Post a Comment