SlideShare a Scribd company logo
Introduction to Chrome
extension development
cage@mitac.com.tw
Agenda
1. What is a Chrome extension/app?
2. Building a Chrome extension
3. How to build Chrome extension fast
What is a Chrome extension/app?
Extension - Clip to Evernote
Browse action
Extension - OmniDrive
page action
Extension - Pushbullet
popup
App - Sunrise Calendar
Build a Chrome extension
What can you do with a Chrome
extension?
use storage (local/sync)
build a dev tool
browser popup
context menu
capture tab screen
send desktop notification
get/modify tabs content
3 Kinds
https://developer.chrome.com/extensions/overview
Browser action - page action - popup
Chrome extension Layers
http://www.penguinhustle.com/blog/how-to-write-your-first-chrome-extension/
An extension logic
http://stackoverflow.com/questions/20017268/google-chrome-extension-api-diagram
content scripts
● run in tabs
● DOM access
● isolate scope
● limited chrome.* APIs
access
● access to resources via
web_accessible_resou
rces property
background pages/events pages
● run in background
● html and js
● full chrome.* APIs access
popup scripts
● active only when popup
is opened
● html and js
● Chrome.* APIs access
Chrome extension manifest
app permissions & resources
app content
app meta
https://developer.chrome.com/extensions/manifest
Chrome manifest
https://developer.chrome.com/extensions/manifest
{
"name": "__MSG_appName__",
"version": "0.0.9",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"default_locale": "en",
"background": {
"scripts": [
"scripts/chromereload.js",
"scripts/utility.js",
"scripts/background.js"
]
},
"browser_action":` {
"default_icon": {
"19": "images/icon-19.png",
"38": "images/icon-38.png"
},
"default_title": "Recally Extension",
"default_popup": "popup.html"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"options_page": "options.html",
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"css": [
"styles/contentscript.css"
],
"js": [
"bower_components/rangy/rangy-core.js",
"bower_components/rangy/rangy-serializer.js",
"scripts/utility.js",
"scripts/contentscript.js"
],
"run_at": "document_end",
"all_frames": false
}
],
"permissions": [
"tabs",
"activeTab",
"contextMenus",
"cookies",
"notifications",
"https://*/*",
"http://*/*"
],
"web_accessible_resources": [
"styles/*",
"scripts/*"
]
}
communication
http://www.penguinhustle.com/blog/how-to-write-your-first-chrome-extension/
communication: one-time requests
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response) {
console.log(response.farewell);
});
});
chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
console.log(response.farewell);
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
});
- receiving from both
- sending from content script
- sending from background script
communication: long-lived connectsion
var port = chrome.runtime.connect({name: "knockknock"});
port.postMessage({joke: "Knock knock"});
port.onMessage.addListener(function(msg) {
if (msg.question == "Who's there?")
port.postMessage({answer: "Madame"});
else if (msg.question == "Madame who?")
port.postMessage({answer: "Madame... Bovary"});
});
- opening a channel from a content script
chrome.runtime.onConnect.addListener(function(port) {
console.assert(port.name == "knockknock");
port.onMessage.addListener(function(msg) {
if (msg.joke == "Knock knock")
port.postMessage({question: "Who's there?"});
else if (msg.answer == "Madame")
port.postMessage({question: "Madame who?"});
else if (msg.answer == "Madame... Bovary")
port.postMessage({question: "I don't get it."});
});
});
- receiving on the background page
communication: others
sending messages from web pages
native messaging
cross-extension messaging
permissions/APIs
● host permissions
● background
● bookmarks
● clipboardRead
● clipboardWrite
● contentSettings
● contextMenus
● cookies
● debugger
● history
● idle
● management
● notifications
● pageCapture
● tabs
● topSites
● webNavigation
● webRequest
● webRequestBlocking
{
"name": "My extension",
...
"optional_permissions": [ "tabs", "http://www.google.com/" ],
...
}
http://www.penguinhustle.com/blog/how-to-write-your-first-chrome-extension/
How to build chrome
extension fast
Yeoman
http://yeoman.io
yo scaffolds out a new
application, writing
your Grunt
configuration and
pulling in relevant
Grunt tasks and Bower
dependencies that you
might need for your
build.
The Build System is used
to build, preview and test
your project. Grunt and
Gulp are two popular
options.
The Package Manager is
used for dependency
management, so that you no
longer have to manually
download and manage your
scripts. Bower and npm are
two popular options.
THE WEB'S
SCAFFOLDING TOOL
FOR MODERN
WEBAPPS
//https://github.com/yeoman/generator-chrome-extension
yeoman - generator chrome extension
getting started - Chrome extension
$ npm install -g yo
$ npm install -g generator-chrome-extension
$ yo chrome-extension
$ grunt build
$ grunt debug
yeoman - chromeapp
https://github.com/yeoman/generator-chromeapp
getting started - Chrome app
$ npm install -g yo
$ npm install -g generator-chromeapp
$ yo chromeapp
$ grunt build
$ grunt debug
https://github.com/GoogleChrome/chrome-app-samples

More Related Content

PDF
Introduction of chrome extension development
PPTX
Google chrome extension
PDF
Google Chrome Extensions - DevFest09
PDF
Building Chrome Extensions
PPT
Chrome Extension Develop Starts
PPTX
Build your own Chrome Extension with AngularJS
PDF
Chrome extension development
PPTX
Chrome Apps & Extensions
Introduction of chrome extension development
Google chrome extension
Google Chrome Extensions - DevFest09
Building Chrome Extensions
Chrome Extension Develop Starts
Build your own Chrome Extension with AngularJS
Chrome extension development
Chrome Apps & Extensions

What's hot (20)

PPTX
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
PDF
Chrome extensions
PDF
Discovering Chrome Extensions
PDF
Introduction to Google Chrome Extensions Development
PPTX
Orange is the new blue: How to port Chrome Extension to Firefox Extension
PPT
A Complete Guide To Chrome Extension Development
ODP
Chrome extension development
PDF
HTML5 and Google Chrome - DevFest09
PPTX
Develop Chrome Extension
ODP
Effective TDD - Less is more
PPTX
WordPress Theming
PDF
Advanced Chrome extension exploitation
PPT
Google chrome
PDF
Native apps in html5 with chrome packaged apps
PPTX
WordPress Theme & Plugin i18n & L10n
PDF
Chrome extensions dev Intro
PPTX
Web browser extensions development
PDF
Web Blogs
PPTX
An overview on Developing Chrome Extensions
PDF
WordPress REST API v2: Overview & Exploring
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
Chrome extensions
Discovering Chrome Extensions
Introduction to Google Chrome Extensions Development
Orange is the new blue: How to port Chrome Extension to Firefox Extension
A Complete Guide To Chrome Extension Development
Chrome extension development
HTML5 and Google Chrome - DevFest09
Develop Chrome Extension
Effective TDD - Less is more
WordPress Theming
Advanced Chrome extension exploitation
Google chrome
Native apps in html5 with chrome packaged apps
WordPress Theme & Plugin i18n & L10n
Chrome extensions dev Intro
Web browser extensions development
Web Blogs
An overview on Developing Chrome Extensions
WordPress REST API v2: Overview & Exploring
Ad

Viewers also liked (11)

PDF
Google app engine (gae) 演進史
PDF
Nas 也可以揀土豆
PDF
Google apps script introduction
PDF
Django oscar introduction
PDF
痞客趴趴走 Waldo
PDF
Gae managed vm introduction
PDF
Continuous Integration & Continuous Delivery with GCP
PDF
Waldo-gcp
PDF
Screenshot as a service
PDF
Google apps script introduction
PDF
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
Google app engine (gae) 演進史
Nas 也可以揀土豆
Google apps script introduction
Django oscar introduction
痞客趴趴走 Waldo
Gae managed vm introduction
Continuous Integration & Continuous Delivery with GCP
Waldo-gcp
Screenshot as a service
Google apps script introduction
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
Ad

Similar to Introduction to chrome extension development (20)

PDF
Browser Extensions for Web Hackers
PDF
Chrome Extensions for Hackers
PPTX
Spicy javascript: Create your first Chrome extension for web analytics QA
PPTX
Cliw - extension development
PDF
从小书签到浏览器扩展的应用
PDF
Going Live! with Comet
PDF
Progressive web apps
PDF
Web versus Native: round 1!
PDF
Rails missing features
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
PDF
Vapor – Swift is not only for iOS anymore
PDF
Pushing the Web: Interesting things to Know
PPTX
Docker practical solutions
PDF
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
PDF
HTTP/2 -- the future of WWW
PPT
Qtp not just for gui anymore
PDF
Mobile Device APIs
PDF
Krzysztof Kotowicz - Hacking HTML5
PDF
Building a DRYer Android App with Kotlin
PDF
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...
Browser Extensions for Web Hackers
Chrome Extensions for Hackers
Spicy javascript: Create your first Chrome extension for web analytics QA
Cliw - extension development
从小书签到浏览器扩展的应用
Going Live! with Comet
Progressive web apps
Web versus Native: round 1!
Rails missing features
JavaScript - Chapter 13 - Browser Object Model(BOM)
Vapor – Swift is not only for iOS anymore
Pushing the Web: Interesting things to Know
Docker practical solutions
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
HTTP/2 -- the future of WWW
Qtp not just for gui anymore
Mobile Device APIs
Krzysztof Kotowicz - Hacking HTML5
Building a DRYer Android App with Kotlin
"Hidden difficulties of debugger implementation for .NET WASM apps", Andrii R...

More from KAI CHU CHUNG (15)

PDF
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
PDF
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
PDF
DevFest 2022 - Cloud Workstation Introduction TaiChung
PDF
Devfest 2021' - Artifact Registry Introduction (Taipei)
PDF
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
PDF
Velero search & practice 20210609
PDF
Gdg cloud taipei ddt meetup #53 buildpack
PDF
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
PDF
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
PDF
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
PDF
Google App Engine: Basic
PDF
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
PDF
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
PDF
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
PDF
Global GDG Leaders Summit, Google I/O 2018 經驗分享
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Cloud Workstation Introduction TaiChung
Devfest 2021' - Artifact Registry Introduction (Taipei)
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Velero search & practice 20210609
Gdg cloud taipei ddt meetup #53 buildpack
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Google App Engine: Basic
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
Global GDG Leaders Summit, Google I/O 2018 經驗分享

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Introduction to Artificial Intelligence
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
System and Network Administraation Chapter 3
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
System and Network Administration Chapter 2
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms I-SECS-1021-03
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Introduction to Artificial Intelligence
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PTS Company Brochure 2025 (1).pdf.......
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Softaken Excel to vCard Converter Software.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
System and Network Administraation Chapter 3
How to Migrate SBCGlobal Email to Yahoo Easily
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
System and Network Administration Chapter 2
Odoo Companies in India – Driving Business Transformation.pdf
Understanding Forklifts - TECH EHS Solution
wealthsignaloriginal-com-DS-text-... (1).pdf
CHAPTER 2 - PM Management and IT Context
Reimagine Home Health with the Power of Agentic AI​
How to Choose the Right IT Partner for Your Business in Malaysia

Introduction to chrome extension development