Chrome extension
development
JavaScript Latvia meetup
08.10.2013
Me
● Mārtiņš Balodis
● studying at University of Latvia
● working at IMCS
● Wasting my spare time on:
○ Web Scraping
○ Web archiving
○ Hadoop/Disco/CouchDB
What is a chrome extension?
Extensions run inside the Chrome browser and provide
additional functionality.
Chrome extensions are built the same way web pages are
built: HTML, CSS, JavaScript.
● Installs easily
● Updates automatically
● Runs in a separate process
What does an extension do?
● Add new features:
○ RSS reader
● Extend web page functionality
○ Enhance facebook UI
● Service client
○ Mail checker
● Enhance chrome browser
○ Advanced history management
manifest.json
● Description
● Actions
● Permissions
Example:
{
"manifest_version": 2,
"name": "My Extensions",
"version": "versionString",
"description": "A plain text description",
"icons": {...},
...
}
Content Script
● Scripts run within each page
● Executed within an isolated world
manifest.json:
{
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"css": ["mystyles.css"],
"js": ["jquery.js", "myscript.js"]
}
],
}
Background page
● Common long running script
● Communication with pages
● No xhr limitations
manifest.json:
{
"background": {
"scripts": ["background.js"]
},
}
Browser action
Manifest.json:
{
"name": "My extension",
...
"browser_action": {
"default_icon":"images/icon19.png",
"default_popup": "popup.html",
"default_title": "Google Mail" // optional; shown in tooltip
},
}
Badge text:
chrome.browserAction. setBadgeText({
text:"33",
tabId:12
});
Page action
● By default it is hidden
○ Show only when needed
Manifest.json:
{
"browser_action": {
"default_icon": "images/icon19.png"
"default_title": "Google Mail",
"default_popup": "popup.html"
},
}
Show the page action:
chrome.pageAction.show(integer tabId);
Context menus
manifest.json:
{
"permissions": [
"contextMenus"
],
"icons": {
"16": "icon-bitty.png",
},
}
Background script:
chrome.contextMenus.create({
type: "normal", // "checkbox", "radio", or "separator"
title: "block this ad",
contexts: "page" //,"selection","link","editable","image","video","
audio",
onclick: function(OnClickData , tab){}
});
Desktop notifications
manifest.json:
{
"permissions": [
"notifications"
],
}
Create notification:
var notification = webkitNotifications. createNotification(
'48.png', // icon url
'Hello!', // notification title
'Lorem ipsum...' // notification body text
);
notification.show();
Options page I
Options page II
● Simple html page
● Standardized CSS in future
● Sync
manifest.json:
{
"options_page": "options.html",
}
Omnibox
● Add search suggestions
manifest.json:
{
"omnibox": { "keyword" : " omnix" },
}
Background script:
chrome.omnibox. onInputChanged.addListener(
function(text, suggest) {
suggest([
{content: text + " one", description: "the first one"},
{content: text + " number two", description: "the second entry"}
]);
});
Override Chrome pages
● Bookmark Manager (chrome://bookmarks)
● History (chrome://history)
● New Tab (chrome://newtab)
Manifest.json:
{
"chrome_url_overrides" : {
"pageToOverride": "bookmarks"
},
}
Devtools page
manifest.json:
{
"devtools_page": "devtools.html",
}
devtools.html:
chrome.devtools.panels.create("Font Picker", "icon48.png", "panel.html");
APIs
chrome.devtools.panels.*
chrome.devtools.network.*
chrome.devtools.inspectedWindow.*
Message passing
● Communication between extension pages
● Communication with other extensions
Send a message
To background script:
chrome.runtime. sendMessage({CanIHaz: "cheezbuger"}, function(response) {
console.log(response.farewell);
});
To content script:
chrome.tabs.sendMessage(tab_id, {greeting: "hello"}, function(response) {
console.log(response.farewell);
});
Receive messages
● Respond asynchronously
chrome.runtime. onMessage.addListener(
function(request, sender, sendResponse) {
console.log(request);
sendResponse({farewell: "goodbye"});
});
Website Scraper

More Related Content

PDF
Introduction of chrome extension development
PDF
Introduction to Google Chrome Extensions Development
PDF
Google Chrome Extensions - DevFest09
PPTX
Google chrome extension
PPTX
Chrome extensions
PPTX
Develop Chrome Extension
PPTX
Angular Data Binding
PDF
An introduction to Vue.js
Introduction of chrome extension development
Introduction to Google Chrome Extensions Development
Google Chrome Extensions - DevFest09
Google chrome extension
Chrome extensions
Develop Chrome Extension
Angular Data Binding
An introduction to Vue.js

What's hot (20)

PDF
Frontrunners react
PPTX
React render props
PDF
JavaScript Promises
PPTX
Vue 2 vs Vue 3.pptx
PPTX
RESTful API 제대로 만들기
PDF
Introduction to VueJS & Vuex
PPTX
React js programming concept
PDF
Introduction to React JS
PDF
Kubernetes Secrets Management on Production with Demo
PDF
Vue JS Intro
PDF
マイクロサービスアーキテクチャ とは何か
PDF
ReactJS presentation
PDF
Angular 10 course_content
PPTX
Presentation1.pptx
PPTX
Lab #2: Introduction to Javascript
PDF
An introduction to React.js
PPTX
PPTX
React JS - A quick introduction tutorial
PDF
VueJS Introduction
PDF
BEM - CSS, Seriously
Frontrunners react
React render props
JavaScript Promises
Vue 2 vs Vue 3.pptx
RESTful API 제대로 만들기
Introduction to VueJS & Vuex
React js programming concept
Introduction to React JS
Kubernetes Secrets Management on Production with Demo
Vue JS Intro
マイクロサービスアーキテクチャ とは何か
ReactJS presentation
Angular 10 course_content
Presentation1.pptx
Lab #2: Introduction to Javascript
An introduction to React.js
React JS - A quick introduction tutorial
VueJS Introduction
BEM - CSS, Seriously
Ad

Viewers also liked (11)

ODP
Making Chrome Extension with AngularJS
PPTX
Build your own Chrome Extension with AngularJS
ODP
Chrome extension development
PPT
A Complete Guide To Chrome Extension Development
POT
Browser extension
PPT
Introduction To Browser Extension Development
PDF
20100915 學習撰寫 Google Chrome Extension
PDF
Chrome extensions threat analysis and countermeasures
PDF
Introduction to Web Browser Extension/Add-ons
ODP
El arte clásico
PPT
Chrome Extension Develop Starts
Making Chrome Extension with AngularJS
Build your own Chrome Extension with AngularJS
Chrome extension development
A Complete Guide To Chrome Extension Development
Browser extension
Introduction To Browser Extension Development
20100915 學習撰寫 Google Chrome Extension
Chrome extensions threat analysis and countermeasures
Introduction to Web Browser Extension/Add-ons
El arte clásico
Chrome Extension Develop Starts
Ad

Similar to Chrome extension development (20)

PDF
Chrome Extensions for Hackers
PPTX
Creating custom chrome extensions
PDF
Building Progressive Web Apps for Android and iOS
PDF
Chrome Extensions for Web Hackers
PPTX
Cliw - extension development
PPTX
Chrome Extension Step by step Guide .pptx
PDF
Browser Extensions for Web Hackers
PDF
Progressive Web Apps
PDF
Firefox OS, the Open Web & WebAPIs - LXJS, Portugal
PDF
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
PDF
What's New with Confluence Connect
PDF
从小书签到浏览器扩展的应用
PPTX
How to integrate with GPII
PDF
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
PDF
Service Worker 201 (en)
PDF
Building Chrome Extensions
PPTX
JavaScript on the Desktop
PDF
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
PPTX
Chrome Apps & Extensions
PDF
Firefox OS workshop, Colombia
Chrome Extensions for Hackers
Creating custom chrome extensions
Building Progressive Web Apps for Android and iOS
Chrome Extensions for Web Hackers
Cliw - extension development
Chrome Extension Step by step Guide .pptx
Browser Extensions for Web Hackers
Progressive Web Apps
Firefox OS, the Open Web & WebAPIs - LXJS, Portugal
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
What's New with Confluence Connect
从小书签到浏览器扩展的应用
How to integrate with GPII
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Service Worker 201 (en)
Building Chrome Extensions
JavaScript on the Desktop
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Chrome Apps & Extensions
Firefox OS workshop, Colombia

Recently uploaded (20)

PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
Internet of Everything -Basic concepts details
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PPTX
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
Comparative analysis of machine learning models for fake news detection in so...
PDF
Advancing precision in air quality forecasting through machine learning integ...
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
LMS bot: enhanced learning management systems for improved student learning e...
Convolutional neural network based encoder-decoder for efficient real-time ob...
Internet of Everything -Basic concepts details
NewMind AI Weekly Chronicles – August ’25 Week IV
Co-training pseudo-labeling for text classification with support vector machi...
sbt 2.0: go big (Scala Days 2025 edition)
Enhancing plagiarism detection using data pre-processing and machine learning...
giants, standing on the shoulders of - by Daniel Stenberg
Data Virtualization in Action: Scaling APIs and Apps with FME
agenticai-neweraofintelligence-250529192801-1b5e6870.pptx
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
4 layer Arch & Reference Arch of IoT.pdf
Comparative analysis of machine learning models for fake news detection in so...
Advancing precision in air quality forecasting through machine learning integ...
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
SGT Report The Beast Plan and Cyberphysical Systems of Control
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Improvisation in detection of pomegranate leaf disease using transfer learni...

Chrome extension development

  • 2. Me ● Mārtiņš Balodis ● studying at University of Latvia ● working at IMCS ● Wasting my spare time on: ○ Web Scraping ○ Web archiving ○ Hadoop/Disco/CouchDB
  • 3. What is a chrome extension? Extensions run inside the Chrome browser and provide additional functionality. Chrome extensions are built the same way web pages are built: HTML, CSS, JavaScript. ● Installs easily ● Updates automatically ● Runs in a separate process
  • 4. What does an extension do? ● Add new features: ○ RSS reader ● Extend web page functionality ○ Enhance facebook UI ● Service client ○ Mail checker ● Enhance chrome browser ○ Advanced history management
  • 5. manifest.json ● Description ● Actions ● Permissions Example: { "manifest_version": 2, "name": "My Extensions", "version": "versionString", "description": "A plain text description", "icons": {...}, ... }
  • 6. Content Script ● Scripts run within each page ● Executed within an isolated world manifest.json: { "content_scripts": [ { "matches": ["http://www.google.com/*"], "css": ["mystyles.css"], "js": ["jquery.js", "myscript.js"] } ], }
  • 7. Background page ● Common long running script ● Communication with pages ● No xhr limitations manifest.json: { "background": { "scripts": ["background.js"] }, }
  • 8. Browser action Manifest.json: { "name": "My extension", ... "browser_action": { "default_icon":"images/icon19.png", "default_popup": "popup.html", "default_title": "Google Mail" // optional; shown in tooltip }, } Badge text: chrome.browserAction. setBadgeText({ text:"33", tabId:12 });
  • 9. Page action ● By default it is hidden ○ Show only when needed Manifest.json: { "browser_action": { "default_icon": "images/icon19.png" "default_title": "Google Mail", "default_popup": "popup.html" }, } Show the page action: chrome.pageAction.show(integer tabId);
  • 10. Context menus manifest.json: { "permissions": [ "contextMenus" ], "icons": { "16": "icon-bitty.png", }, } Background script: chrome.contextMenus.create({ type: "normal", // "checkbox", "radio", or "separator" title: "block this ad", contexts: "page" //,"selection","link","editable","image","video"," audio", onclick: function(OnClickData , tab){} });
  • 11. Desktop notifications manifest.json: { "permissions": [ "notifications" ], } Create notification: var notification = webkitNotifications. createNotification( '48.png', // icon url 'Hello!', // notification title 'Lorem ipsum...' // notification body text ); notification.show();
  • 13. Options page II ● Simple html page ● Standardized CSS in future ● Sync manifest.json: { "options_page": "options.html", }
  • 14. Omnibox ● Add search suggestions manifest.json: { "omnibox": { "keyword" : " omnix" }, } Background script: chrome.omnibox. onInputChanged.addListener( function(text, suggest) { suggest([ {content: text + " one", description: "the first one"}, {content: text + " number two", description: "the second entry"} ]); });
  • 15. Override Chrome pages ● Bookmark Manager (chrome://bookmarks) ● History (chrome://history) ● New Tab (chrome://newtab) Manifest.json: { "chrome_url_overrides" : { "pageToOverride": "bookmarks" }, }
  • 16. Devtools page manifest.json: { "devtools_page": "devtools.html", } devtools.html: chrome.devtools.panels.create("Font Picker", "icon48.png", "panel.html"); APIs chrome.devtools.panels.* chrome.devtools.network.* chrome.devtools.inspectedWindow.*
  • 17. Message passing ● Communication between extension pages ● Communication with other extensions
  • 18. Send a message To background script: chrome.runtime. sendMessage({CanIHaz: "cheezbuger"}, function(response) { console.log(response.farewell); }); To content script: chrome.tabs.sendMessage(tab_id, {greeting: "hello"}, function(response) { console.log(response.farewell); });
  • 19. Receive messages ● Respond asynchronously chrome.runtime. onMessage.addListener( function(request, sender, sendResponse) { console.log(request); sendResponse({farewell: "goodbye"}); });