SlideShare a Scribd company logo
1 of 28
Chrome Extensions:
How to Build
2018
Becky Peltz
peltzr@seattleu.edu
WATS April Meetup
1
2
XKCD
Bio
BA, MBA University of Washington
Coding professionally since 1982
Application Developer
Many languages, Many architectures, Much technology
Solving problems!
Focus on fundamentals and standards
Companies include: Boeing, REI, Regence, Microsoft, go2Net, Expeditors, UW,
Seattle Public Schools, Seattle Children’s Hospital, F5 Networks, zulily, Globys,
Schweitzer Engineering Labs, North Seattle College, City University, Seattle
University
3
Agenda
What are Chrome Extensions?
Why spend time learning this?
Look at examples
Architecture of a Chrome Extension
Build them
Host them
Debugging & Performance
4
What are chrome extensions
Extensions are made from languages familiar to web
developers: HTML, CSS, JavaScript
5
What are chrome extensions
Use Chrome’s API to control inside and outside browser
window
https://developer.chrome.com/extensions/api_index
6
What are chrome extensions
Anchored to the Chrome Browser but not constrained to it -
no CORS
7
What are chrome extensions
API’s that give access to what’s inside a web page and
browser
8
Why Spend Time Learning This?
The web is a great place to solve problems
Use your web skills to solve problems
9
Why Spend Time Learning This?
Modular solutions to focused problems
You spend a lot of time in a browser so this is a good place to
implement a solution
10
Why Spend Time Learning This?
Web application without cross browser design concerns
11
Why Spend Time Learning This?
Experience working on an extension/plugin for a major
application
12
Why Spend Time Learning This?
Can make money from these $$
Cheap to host your solution
13
What can we do with Extensions?
Make an easily accessible tool
Add features and functionality to the Chrome browser
Access and modify content in web pages
Integrate with other apps
Host up to 20 web apps for $5/year (did I mention it was cheap?)
14
“Tip of the Iceberg”
15
Will it work?
16
Chrome Web Store
(> 8500 extensions in 2010)
Vist the Chrome web store:
https://chrome.google.com/webstore/category/extensions
17
Nothing is impossible, the word itself says ‘I’m possible’.
Audrey Hepburn
Examples
Google Earth View
Pablo https://photos.app.goo.gl/K6Uw2R2443ehK8HB3
Distill https://www.sitepoint.com/create-chrome-extension-10-minutes-flat/
Honey
XKCD
Screen Castify
Link Cat
18
Honey
19
Architecture and Terminology
20
Let’s Build and Host
Hello World
Link Cat
HTML Validator
https://docs.google.com/presentation/d/1HgrjKJLu0SeHbOEY_GGabe4YpNWYOWwpr-VlZ9LZqMo/edit?usp=sharing
Language Translator
https://docs.google.com/presentation/d/1LpntvWw-wFOVtw1JnSZLnUpw5iSwnnR2ktfoHfb_MFs/edit#slide=id.p
21
Debugging
Click on extension icon
Right click and inspect
Set a breakpoint in popup.js
In the console enter “location.reload()” to reload the code for debugging
Debugging Background pages
Also chrome://inspect/#extensions
22
Quick look: Selecting the container when user
selected text
Use this if you want to take action on user selection to help find container.
let select = window.getSelection();
if (select.rangeCount > 0) {
let node = select.getRangeAt(0).startContainer.parentNode;
console.log (node.id, node.name);
}
23
Quick look: Messaging using API’s
Send from Content:
chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
console.log(response.farewell);
});
Send from Extension:
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response) {
console.log(response.farewell);
});
});
Receive @ Content or Extension:
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"});
});
24
Quick look: Receiving message from content or
extension using API’s
Receive @ Content or Extension:
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"});
});
25
Performance
Use extensions task manager to analyze memory usage
26
Resources
27
Extension github Chrome store
Hello https://github.com/rebeccapeltz/hello-
chrome-ext
HTML Validator https://github.com/rebeccapeltz/html-
validate-ext
https://chrome.google.com/webstore/de
tail/html-
validator/bocbjjpebcmehmadhaiefilfieah
hcmo
Language Translator https://github.com/rebeccapeltz/chrome
-ext-translator
https://chrome.google.com/webstore/de
tail/language-
translator/fknddeibkpckpklmdjhpfiaikhfg
ddnb?hl=en
Email Link Category https://github.com/rebeccapeltz/link-cat https://chrome.google.com/webstore/de
tail/email-cat-
link/jomlhocpjgkjikblbginecclpgdkhobm
Google Resources
Google Video
https://developer.chrome.com/apps/about_apps
Google Examples
https://developer.chrome.com/apps/samples
28

More Related Content

Similar to Intro chrome extensions

Chrome Developer Tools - Pro Tips & Tricks
Chrome Developer Tools - Pro Tips & TricksChrome Developer Tools - Pro Tips & Tricks
Chrome Developer Tools - Pro Tips & TricksMars Devs
 
Smart Browsers and HTML5 Web Apps for the Chrome Web Store
Smart Browsers and HTML5 Web Apps for the Chrome Web StoreSmart Browsers and HTML5 Web Apps for the Chrome Web Store
Smart Browsers and HTML5 Web Apps for the Chrome Web StoreSeth Ladd
 
Building Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsTroy Miles
 
Ultimate guide on how to hire full stack web developer in 2022
Ultimate guide on how to hire full stack web developer in 2022Ultimate guide on how to hire full stack web developer in 2022
Ultimate guide on how to hire full stack web developer in 2022Katy Slemon
 
Web Technology and Standards Tutorial
Web Technology and Standards Tutorial Web Technology and Standards Tutorial
Web Technology and Standards Tutorial Jonathan Jeon
 
Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Bin Chen
 
Rails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSSRails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSSTimo Herttua
 
10 Best Front-end Frameworks for Web Development
10 Best Front-end Frameworks for Web Development10 Best Front-end Frameworks for Web Development
10 Best Front-end Frameworks for Web DevelopmentMars Devs
 
etech11_12_q2mod7_basic_webpage_creation_v3.pdf
etech11_12_q2mod7_basic_webpage_creation_v3.pdfetech11_12_q2mod7_basic_webpage_creation_v3.pdf
etech11_12_q2mod7_basic_webpage_creation_v3.pdfRhudelAndallo
 
Fast & Furious Responsive Design in Chrome DevTools
Fast & Furious Responsive Design in Chrome  DevToolsFast & Furious Responsive Design in Chrome  DevTools
Fast & Furious Responsive Design in Chrome DevToolsTony Jessup
 
Web Design & Development - Session 1
Web Design & Development - Session 1Web Design & Development - Session 1
Web Design & Development - Session 1Shahrzad Peyman
 
HTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm SoftwareHTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm SoftwareRomin Irani
 
CMS driven Globalized WebSite Project
CMS driven Globalized WebSite ProjectCMS driven Globalized WebSite Project
CMS driven Globalized WebSite Projectmaxwellhoffmann
 
WYSIWYG online editor allow you to design websites without coding skills
WYSIWYG online editor allow you to design websites without coding skillsWYSIWYG online editor allow you to design websites without coding skills
WYSIWYG online editor allow you to design websites without coding skillsAngelicaCarbonquillo
 
Ch10 Hacking Web Servers http://ouo.io/2Bt7X
Ch10 Hacking Web Servers http://ouo.io/2Bt7XCh10 Hacking Web Servers http://ouo.io/2Bt7X
Ch10 Hacking Web Servers http://ouo.io/2Bt7Xphanleson
 

Similar to Intro chrome extensions (20)

Chrome Developer Tools - Pro Tips & Tricks
Chrome Developer Tools - Pro Tips & TricksChrome Developer Tools - Pro Tips & Tricks
Chrome Developer Tools - Pro Tips & Tricks
 
Smart Browsers and HTML5 Web Apps for the Chrome Web Store
Smart Browsers and HTML5 Web Apps for the Chrome Web StoreSmart Browsers and HTML5 Web Apps for the Chrome Web Store
Smart Browsers and HTML5 Web Apps for the Chrome Web Store
 
Building Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile Apps
 
Ultimate guide on how to hire full stack web developer in 2022
Ultimate guide on how to hire full stack web developer in 2022Ultimate guide on how to hire full stack web developer in 2022
Ultimate guide on how to hire full stack web developer in 2022
 
Web Technology and Standards Tutorial
Web Technology and Standards Tutorial Web Technology and Standards Tutorial
Web Technology and Standards Tutorial
 
Swf search final
Swf search finalSwf search final
Swf search final
 
Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)
 
Rails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSSRails Girls - Introduction to HTML & CSS
Rails Girls - Introduction to HTML & CSS
 
10 Best Front-end Frameworks for Web Development
10 Best Front-end Frameworks for Web Development10 Best Front-end Frameworks for Web Development
10 Best Front-end Frameworks for Web Development
 
etech11_12_q2mod7_basic_webpage_creation_v3.pdf
etech11_12_q2mod7_basic_webpage_creation_v3.pdfetech11_12_q2mod7_basic_webpage_creation_v3.pdf
etech11_12_q2mod7_basic_webpage_creation_v3.pdf
 
mini-project.pptx
mini-project.pptxmini-project.pptx
mini-project.pptx
 
Fast & Furious Responsive Design in Chrome DevTools
Fast & Furious Responsive Design in Chrome  DevToolsFast & Furious Responsive Design in Chrome  DevTools
Fast & Furious Responsive Design in Chrome DevTools
 
Real solutions, no tricks
Real solutions, no tricksReal solutions, no tricks
Real solutions, no tricks
 
Web Design & Development - Session 1
Web Design & Development - Session 1Web Design & Development - Session 1
Web Design & Development - Session 1
 
UI Web Development.pptx
UI Web Development.pptxUI Web Development.pptx
UI Web Development.pptx
 
HTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm SoftwareHTML5 Webinar - Mind Storm Software
HTML5 Webinar - Mind Storm Software
 
Sbwire 525914
Sbwire 525914Sbwire 525914
Sbwire 525914
 
CMS driven Globalized WebSite Project
CMS driven Globalized WebSite ProjectCMS driven Globalized WebSite Project
CMS driven Globalized WebSite Project
 
WYSIWYG online editor allow you to design websites without coding skills
WYSIWYG online editor allow you to design websites without coding skillsWYSIWYG online editor allow you to design websites without coding skills
WYSIWYG online editor allow you to design websites without coding skills
 
Ch10 Hacking Web Servers http://ouo.io/2Bt7X
Ch10 Hacking Web Servers http://ouo.io/2Bt7XCh10 Hacking Web Servers http://ouo.io/2Bt7X
Ch10 Hacking Web Servers http://ouo.io/2Bt7X
 

More from Rebecca Peltz

Hosting video js friends (2)
Hosting video js friends (2)Hosting video js friends (2)
Hosting video js friends (2)Rebecca Peltz
 
Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extensionRebecca Peltz
 
Make an language translator with voice extension
Make an language translator with voice extensionMake an language translator with voice extension
Make an language translator with voice extensionRebecca Peltz
 

More from Rebecca Peltz (7)

Hosting video js friends (2)
Hosting video js friends (2)Hosting video js friends (2)
Hosting video js friends (2)
 
Gitbook FAQs
Gitbook FAQsGitbook FAQs
Gitbook FAQs
 
Gitbook Publish FAQ
Gitbook Publish FAQGitbook Publish FAQ
Gitbook Publish FAQ
 
Meetup gitbook
Meetup gitbookMeetup gitbook
Meetup gitbook
 
Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extension
 
Make an language translator with voice extension
Make an language translator with voice extensionMake an language translator with voice extension
Make an language translator with voice extension
 
Ado Presentation
Ado PresentationAdo Presentation
Ado Presentation
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 

Intro chrome extensions

  • 1. Chrome Extensions: How to Build 2018 Becky Peltz peltzr@seattleu.edu WATS April Meetup 1
  • 3. Bio BA, MBA University of Washington Coding professionally since 1982 Application Developer Many languages, Many architectures, Much technology Solving problems! Focus on fundamentals and standards Companies include: Boeing, REI, Regence, Microsoft, go2Net, Expeditors, UW, Seattle Public Schools, Seattle Children’s Hospital, F5 Networks, zulily, Globys, Schweitzer Engineering Labs, North Seattle College, City University, Seattle University 3
  • 4. Agenda What are Chrome Extensions? Why spend time learning this? Look at examples Architecture of a Chrome Extension Build them Host them Debugging & Performance 4
  • 5. What are chrome extensions Extensions are made from languages familiar to web developers: HTML, CSS, JavaScript 5
  • 6. What are chrome extensions Use Chrome’s API to control inside and outside browser window https://developer.chrome.com/extensions/api_index 6
  • 7. What are chrome extensions Anchored to the Chrome Browser but not constrained to it - no CORS 7
  • 8. What are chrome extensions API’s that give access to what’s inside a web page and browser 8
  • 9. Why Spend Time Learning This? The web is a great place to solve problems Use your web skills to solve problems 9
  • 10. Why Spend Time Learning This? Modular solutions to focused problems You spend a lot of time in a browser so this is a good place to implement a solution 10
  • 11. Why Spend Time Learning This? Web application without cross browser design concerns 11
  • 12. Why Spend Time Learning This? Experience working on an extension/plugin for a major application 12
  • 13. Why Spend Time Learning This? Can make money from these $$ Cheap to host your solution 13
  • 14. What can we do with Extensions? Make an easily accessible tool Add features and functionality to the Chrome browser Access and modify content in web pages Integrate with other apps Host up to 20 web apps for $5/year (did I mention it was cheap?) 14
  • 15. “Tip of the Iceberg” 15
  • 17. Chrome Web Store (> 8500 extensions in 2010) Vist the Chrome web store: https://chrome.google.com/webstore/category/extensions 17 Nothing is impossible, the word itself says ‘I’m possible’. Audrey Hepburn
  • 18. Examples Google Earth View Pablo https://photos.app.goo.gl/K6Uw2R2443ehK8HB3 Distill https://www.sitepoint.com/create-chrome-extension-10-minutes-flat/ Honey XKCD Screen Castify Link Cat 18
  • 21. Let’s Build and Host Hello World Link Cat HTML Validator https://docs.google.com/presentation/d/1HgrjKJLu0SeHbOEY_GGabe4YpNWYOWwpr-VlZ9LZqMo/edit?usp=sharing Language Translator https://docs.google.com/presentation/d/1LpntvWw-wFOVtw1JnSZLnUpw5iSwnnR2ktfoHfb_MFs/edit#slide=id.p 21
  • 22. Debugging Click on extension icon Right click and inspect Set a breakpoint in popup.js In the console enter “location.reload()” to reload the code for debugging Debugging Background pages Also chrome://inspect/#extensions 22
  • 23. Quick look: Selecting the container when user selected text Use this if you want to take action on user selection to help find container. let select = window.getSelection(); if (select.rangeCount > 0) { let node = select.getRangeAt(0).startContainer.parentNode; console.log (node.id, node.name); } 23
  • 24. Quick look: Messaging using API’s Send from Content: chrome.runtime.sendMessage({greeting: "hello"}, function(response) { console.log(response.farewell); }); Send from Extension: chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response) { console.log(response.farewell); }); }); Receive @ Content or Extension: 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"}); }); 24
  • 25. Quick look: Receiving message from content or extension using API’s Receive @ Content or Extension: 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"}); }); 25
  • 26. Performance Use extensions task manager to analyze memory usage 26
  • 27. Resources 27 Extension github Chrome store Hello https://github.com/rebeccapeltz/hello- chrome-ext HTML Validator https://github.com/rebeccapeltz/html- validate-ext https://chrome.google.com/webstore/de tail/html- validator/bocbjjpebcmehmadhaiefilfieah hcmo Language Translator https://github.com/rebeccapeltz/chrome -ext-translator https://chrome.google.com/webstore/de tail/language- translator/fknddeibkpckpklmdjhpfiaikhfg ddnb?hl=en Email Link Category https://github.com/rebeccapeltz/link-cat https://chrome.google.com/webstore/de tail/email-cat- link/jomlhocpjgkjikblbginecclpgdkhobm
  • 28. Google Resources Google Video https://developer.chrome.com/apps/about_apps Google Examples https://developer.chrome.com/apps/samples 28

Editor's Notes

  1. Web apps that take advantage of the fact that they are not running inside the browser container: no CORS restriction Cross origin resource sharing
  2. Can be ported to Firefox browser
  3. History: Before the Internet, we just argued about which language to write an app in. All apps were native. If you ran on Windows you had to have an app that compiled down to windows machine code and if it ran on unix it had to compile to that. If it was a IBM 3070 app it had to run in OS/VS. Once app devs realized that the web was a great place to deliver applications as well as documents, it became a question as to what kind of architecture and languages best supported that. We’ve gone through many mutations. You can look up things like Apache CGI, Tomcat, ASP, ASP.Net, and now we have JavaScript Frameworks talking to Rest interfaces. As you look for ways to encode your solutions, it seems to me that the closer your solution is to be based on Standards the longer life it will have. Chrome Extensions can be written in standard based HTML, CSS and JavaScript. They can also be converted to native mobile apps using Cordova.
  4. History: Before the Internet, we just argued about which language to write an app in. All apps were native. If you ran on Windows you had to have an app that compiled down to windows machine code and if it ran on unix it had to compile to that. If it was a IBM 3070 app it had to run in OS/VS. Once app devs realized that the web was a great place to deliver applications as well as documents, it became a question as to what kind of architecture and languages best supported that. We’ve gone through many mutations. You can look up things like Apache CGI, Tomcat, ASP, ASP.Net, and now we have JavaScript Frameworks talking to Rest interfaces. As you look for ways to encode your solutions, it seems to me that the closer your solution is to be based on Standards the longer life it will have. Chrome Extensions can be written in standard based HTML, CSS and JavaScript. They can also be converted to native mobile apps using Cordova.
  5. History: Before the Internet, we just argued about which language to write an app in. All apps were native. If you ran on Windows you had to have an app that compiled down to windows machine code and if it ran on unix it had to compile to that. If it was a IBM 3070 app it had to run in OS/VS. Once app devs realized that the web was a great place to deliver applications as well as documents, it became a question as to what kind of architecture and languages best supported that. We’ve gone through many mutations. You can look up things like Apache CGI, Tomcat, ASP, ASP.Net, and now we have JavaScript Frameworks talking to Rest interfaces. As you look for ways to encode your solutions, it seems to me that the closer your solution is to be based on Standards the longer life it will have. Chrome Extensions can be written in standard based HTML, CSS and JavaScript. They can also be converted to native mobile apps using Cordova.
  6. History: Before the Internet, we just argued about which language to write an app in. All apps were native. If you ran on Windows you had to have an app that compiled down to windows machine code and if it ran on unix it had to compile to that. If it was a IBM 3070 app it had to run in OS/VS. Once app devs realized that the web was a great place to deliver applications as well as documents, it became a question as to what kind of architecture and languages best supported that. We’ve gone through many mutations. You can look up things like Apache CGI, Tomcat, ASP, ASP.Net, and now we have JavaScript Frameworks talking to Rest interfaces. As you look for ways to encode your solutions, it seems to me that the closer your solution is to be based on Standards the longer life it will have. Chrome Extensions can be written in standard based HTML, CSS and JavaScript. They can also be converted to native mobile apps using Cordova.
  7. History: Before the Internet, we just argued about which language to write an app in. All apps were native. If you ran on Windows you had to have an app that compiled down to windows machine code and if it ran on unix it had to compile to that. If it was a IBM 3070 app it had to run in OS/VS. Once app devs realized that the web was a great place to deliver applications as well as documents, it became a question as to what kind of architecture and languages best supported that. We’ve gone through many mutations. You can look up things like Apache CGI, Tomcat, ASP, ASP.Net, and now we have JavaScript Frameworks talking to Rest interfaces. As you look for ways to encode your solutions, it seems to me that the closer your solution is to be based on Standards the longer life it will have. Chrome Extensions can be written in standard based HTML, CSS and JavaScript. They can also be converted to native mobile apps using Cordova.
  8. Browser Action: icon in google chrome toolbar (can also have a tooltip, a badge and a popup) for all pages Page Action: icon will not be enabled unless the page has meets some criteria Note that tooltip will show whether or not the icon is enabled
  9. https://developer.chrome.com/extensions/messaging