SlideShare a Scribd company logo
Introduction of chrome
extension development
balduran@
Agenda
What’s chrome extension
Types of chrome extension
development/testing
Deploying
Q&A
Chrome Extension
Small downloaded plugin that allow you adding new functionality to the chrome
browser
Types of extension
Browser action
Page action
Context menu
Background script
Content script
Dev tools
UI
Browser action for most pages
UI
Page action, active or inactive depending on the page
Context menu
Context menu items can appear in any document
Context Menu
Data flow between UI and background
Architecture
Background task
A single long-running script to manage some task or state
Only one instance is active per extension
Background page or event page??
Persistent: true // it’s background page
Persistent: false // it’s event page
Content script
Run in the context of web pages
Can read details of the web pages the browser visits, or make changes to them
Multiple instance(1 per tab) per extension
Cannot call some chrome.* API
Cannot access variables/functions defined by web pages
Dev tool
Option + command + I
Development/testing
1. Create project
2. Write codes
3. Load extension
4. test/debug feature
5. Upload to chrome web store
Development/testing
Project structure
Manifest file (manifest.json)
Generator http://extensionizr.com
Background script/content script
Resource files (UI implementation)
i18n
Manifest.json
Version
Name
Permissions
Browser_action
Content_scripts
Background
icons
Permission
Host permission
Match Patterns
Schema
http
file
Permission and chrome.* API
API document
https://developer.chrome.com/extensions/api_index
Some API need extra permission
Chrome.management need management permission
chrome.* API
Three groups
User interface
Browser action, page action
Control browser
Windows, tabs, bookmakrs, history, cookies
Communicate with server
Content script, XHR
Chrome.runtime API
retrieve the background page, return details about
the manifest, and listen for and respond to events in
the app or extension lifecycle
Chrome.activeTab API
interact with the browser's tab system
executeScript
Injects JavaScript code into a page
insertCSS
Injects CSS into a page
Resource files
Two main resource files
Icon.png
popup.html
Load expension
chrome://extensions/
Debugging
Deploy
signup fee: 5 USD
Upload extension
provisioning
Chrome web store dashboard
https://chrome.google.com/webstore/developer/dashboard
Appendix
https://developer.chrome.com/webstore/using_webstore_api
Provisioning by API

More Related Content

Introduction of chrome extension development