SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Building Chrome Extensions
Building Chrome ExtensionsBuilding Chrome Extensions
Building Chrome Extensions
Ron Reiter
 
Presentation wpf
Presentation wpfPresentation wpf
Presentation wpf
danishrafiq
 
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Lucas Jellema
 

La actualidad más candente (20)

Building Chrome Extensions
Building Chrome ExtensionsBuilding Chrome Extensions
Building Chrome Extensions
 
Modern Web Development
Modern Web DevelopmentModern Web Development
Modern Web Development
 
Android studio
Android studioAndroid studio
Android studio
 
Web Development In 2018
Web Development In 2018Web Development In 2018
Web Development In 2018
 
Puppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node APIPuppeteer - Headless Chrome Node API
Puppeteer - Headless Chrome Node API
 
jQuery
jQueryjQuery
jQuery
 
HTML 5: Audio And Video
HTML 5: Audio And VideoHTML 5: Audio And Video
HTML 5: Audio And Video
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Presentation wpf
Presentation wpfPresentation wpf
Presentation wpf
 
jQuery Ajax
jQuery AjaxjQuery Ajax
jQuery Ajax
 
Introduction to Joomla
Introduction to JoomlaIntroduction to Joomla
Introduction to Joomla
 
Dom
DomDom
Dom
 
Flutter Session GDSC BPIT.pptx
Flutter Session GDSC BPIT.pptxFlutter Session GDSC BPIT.pptx
Flutter Session GDSC BPIT.pptx
 
jQuery - Chapter 1 - Introduction
 jQuery - Chapter 1 - Introduction jQuery - Chapter 1 - Introduction
jQuery - Chapter 1 - Introduction
 
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...Browser Automation with Playwright – for integration, RPA, UI testing and mor...
Browser Automation with Playwright – for integration, RPA, UI testing and mor...
 
Angular tutorial
Angular tutorialAngular tutorial
Angular tutorial
 
Introduction to MERN
Introduction to MERNIntroduction to MERN
Introduction to MERN
 
Sécurisation de vos applications web à l’aide du composant Security de Symfony
Sécurisation de vos applications web  à l’aide du composant Security de SymfonySécurisation de vos applications web  à l’aide du composant Security de Symfony
Sécurisation de vos applications web à l’aide du composant Security de Symfony
 
Top frontend web development tools
Top frontend web development toolsTop frontend web development tools
Top frontend web development tools
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 

Destacado

Chrome Extension Develop Starts
Chrome Extension Develop StartsChrome Extension Develop Starts
Chrome Extension Develop Starts
taobao.com
 

Destacado (11)

Making Chrome Extension with AngularJS
Making Chrome Extension with AngularJSMaking Chrome Extension with AngularJS
Making Chrome Extension with AngularJS
 
Build your own Chrome Extension with AngularJS
Build your own Chrome Extension with AngularJSBuild your own Chrome Extension with AngularJS
Build your own Chrome Extension with AngularJS
 
Chrome extension development
Chrome extension developmentChrome extension development
Chrome extension development
 
A Complete Guide To Chrome Extension Development
A Complete Guide  To Chrome Extension  DevelopmentA Complete Guide  To Chrome Extension  Development
A Complete Guide To Chrome Extension Development
 
Browser extension
Browser extensionBrowser extension
Browser extension
 
Introduction To Browser Extension Development
Introduction To Browser Extension DevelopmentIntroduction To Browser Extension Development
Introduction To Browser Extension Development
 
20100915 學習撰寫 Google Chrome Extension
20100915 學習撰寫 Google Chrome Extension20100915 學習撰寫 Google Chrome Extension
20100915 學習撰寫 Google Chrome Extension
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasures
 
Introduction to Web Browser Extension/Add-ons
Introduction to Web Browser Extension/Add-onsIntroduction to Web Browser Extension/Add-ons
Introduction to Web Browser Extension/Add-ons
 
El arte clásico
El arte clásicoEl arte clásico
El arte clásico
 
Chrome Extension Develop Starts
Chrome Extension Develop StartsChrome Extension Develop Starts
Chrome Extension Develop Starts
 

Similar a Chrome extension development

Building Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOSBuilding Progressive Web Apps for Android and iOS
Building Progressive Web Apps for Android and iOS
FITC
 
Cliw - extension development
Cliw -  extension developmentCliw -  extension development
Cliw - extension development
vicccuu
 
Firefox OS, the Open Web & WebAPIs - LXJS, Portugal
Firefox OS, the Open Web & WebAPIs - LXJS, PortugalFirefox OS, the Open Web & WebAPIs - LXJS, Portugal
Firefox OS, the Open Web & WebAPIs - LXJS, Portugal
Robert Nyman
 
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet VästeråsFirefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Firefox OS, the Open Web & WebAPIs - Geek Meet Västerås
Robert Nyman
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
Chang W. Doh
 
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San FranciscoFirefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Firefox OS, the Open Web & WebAPIs - HTML5DevConf, San Francisco
Robert Nyman
 
Chrome Apps & Extensions
Chrome Apps & ExtensionsChrome Apps & Extensions
Chrome Apps & Extensions
Varun Raj
 
Firefox OS workshop, Colombia
Firefox OS workshop, ColombiaFirefox OS workshop, Colombia
Firefox OS workshop, Colombia
Robert Nyman
 

Similar a Chrome extension development (20)

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

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

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"}); });