SlideShare a Scribd company logo
Orange is the new blue
How to port Chrome Extension to Firefox Extension
or develop cross-browser extension from scratch
Boris Mossounov
facebook.com/mossounov
linkedin.com/in/borismossounov
anotherguru.me
Major architectural differences:
Chrome Extension v.s. Firefox Addon
Developer documentation
https://developer.chrome.com/extensions https://developer.mozilla.org/en-US/Add-ons
While digging Mozilla docs you can come across:
Legacy Extensions Overlay extensions
Restartless Extensions Bootstrapped Extensions
Add-on SDK Extensions
Jetpack SDK Add-on SDK
=
=
=
Firefox Addon history digest:
Legacy Extensions / Overlay Extensions
(XUL, JSM, XPCOM)
2004.06 - Firefox 0.9
Legacy Extensions / Overlay Extensions
(XUL, JSM, XPCOM)
2004.06 - Firefox 0.9
Firefox Addon history digest:
Legacy Extensions / Overlay Extensions
(XUL, JSM, XPCOM)
2004.06 - Firefox 0.9
browser.xul:
overlay.xul:
Firefox Addon history digest:
Legacy Extensions / Overlay Extensions
(XUL, JSM, XPCOM)
2004.06 - Firefox 0.9
Mozilla starts Jetpack SDK project
2009.09
Firefox Addon history digest:
Legacy Extensions / Overlay Extensions
(XUL, JSM, XPCOM)
2004.06 - Firefox 0.9
Mozilla starts Jetpack SDK project
2009.09
Restartless Extensions / Bootstrapped Extensions
2011.03 - Firefox 4+
Jetpack SDK 0.1 release
Addon SDK extensions
cfx tool (python powered)
2011.06
jpm tool (node.js powered)
2015.05 - Firefox 38
Firefox Addon history digest:
Google announces Chrome Extensions support
2009.09
Google Chrome Store launches
(with blackjack and extensions)
2010.12
Chrome Extension history digest:
Краткая история:
2004.06 - Firefox 0.9
2009.09
2011.03 - Firefox 4+
2011.06
2015.05 - Firefox 38
2010.12
Google announces Chrome Extensions support
Legacy Extensions / Overlay Extensions
(XUL, JSM, XPCOM)
addons.mozilla.org
Mozilla starts Jetpack SDK project
Restartless Extensions / Bootstrapped Extensions
Jetpack SDK 0.1 release
Addon SDK extensions
cfx tool (python powered)
jpm tool (node.js powered)
Google Chrome Store launches (with blackjack and extensions)
While digging Mozilla docs you should read about:
Legacy Extensions Overlay extensions
Restartless Extensions Bootstrapped Extensions
Add-on SDK Extensions
Jetpack SDK Add-on SDK
=
=
=
An average browser extension
consists of the following blocks:
manifest
background script
content scripts,
styles, assets
toolbar button
popup
locales
embedded pages
(options / help)
The major difference between
Chrome Extension and Firefox Addon
is the way the following 3 blocks interact:
background.js
contentscript.js popup.js
Google Chrome possesses two APIs for message passing:
• Simple one-time requests
• Long-lived connections
https://developer.chrome.com/extensions/messaging
Simple one-time requests
chrome.runtime.sendMessage({
greeting: «hello»
}, function(response) {
console.log(response.farewell);
});
background.js
contentscript.js popup.js
chrome.tabs.sendMessage(tabs[0].id, {
greeting: «hello»
}, function(response) {
console.log(response.farewell);
});
background.js
contentscript.js
chrome.runtime.onMessage.addListener(
function(request, sender, callback) {
console.log(sender.tab ?
"from a content script:" +
sender.tab.url :
"from the extension");
if (request.greeting == "hello")
callback({farewell: "goodbye"});
});
background.js
contentscript.js popup.js
?
Long-lived connections
port.postMessage({joke: "Knock knock»});
port.onMessage.addListener(function(msg) {
if (msg.question == "Who's there?"){
port.postMessage({answer: "#4front"});
}
});
background.js
contentscript.js popup.js
Window chrome.extension.getBackgroundPage()
background.js
contentscript.js popup.js
contentscript.js & popup.js can:
Is cross-browser support on the table?
If it is, then don’t.
If not, go on.
background.js
contentscript.js popup.js
• two message passing APIs
• contentscript.js & popup.js can get
background window object and store some
objects and methods there.
• all blocks can interact using untitled messages
and setting response callbacks.
• background.js knows nothing about other
scripts till they connect to it
What about Firefox?
eloper.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/u
port.emit("myMessage", msg);
port.on("myMessage",function(msg) {
if (msg.question == "Who's there?")
port.emit("myMessage.reply", {
answer: "#4front"
});
});
background.js
contentscript.js popup.js
background.js
contentscript.js popup.js
• all blocks are run in isolated runtimes
and can interact using named
messages without response callbacks
• background.js creates contentscript.js
& popup.js and can control them
callbacks = {
«1234»:
function(payload){},
«1235»:
function(payload){}
}
message = {
action: «myMessage.reply»,
uid: 1234,
paylaod: {}
}
message = {
}
message = {
action: «myMessage»,
paylaod: {}
}
message = {
action: «myMessage»,
uid: 1234,
paylaod: {}
}
Let’s compare Mozilla Extension & Chrome Extension
by blocks:
manifest
background script
content scripts,
styles, assets
toolbar button
popup
locales
embedded pages
(options / help)
manifest
manifest.json
describes:
• title, description,
version, license,
• location of all scripts,
styles, html,
• permissions
package.json
describes:
• title, description, version,
license,
• location of background
script
and background script
loads all the content & popup
scripts, styles, html
manifest
How to develop cross-browser way:
Setup grunt task, that will synchronize manifest.json &
package.json (version, title, description…)
• Invisible html page with
it’s window js-object,
• this window js-object
shares the same
runtime context with
content scripts and
popup script
• Separate javascript
without window object.
• this javascript is run in an
isolated runtime
• Background script
initializes content scripts
and popup and can
control them.
• EcmaScript 6
background script
How to develop cross-browser way:
1. Avoid chrome.extension.getBackgroundPage() at all costs
2. For Firefox - create separate background script since firefox
addon sdk is implemented on ES6.
3. Develop a cross-browser middle layer to call browser specific
API that above all implements message passing with named
messages and response callbacks
4. Store background script and content script / popup script logic in
separate files. Even if some mechanisms require both
background and content scripts. Use message passing, Luke.
background script
• content scripts are run
in a web-page isolated
world
• can access background
window
• cross-domain request
are manifest
permission dependent
• content scripts are run
in a web-page isolated
world
• are run in context
isolated from
background script
• cross-domain requests
are forbidden
content scripts,
styles, assets
How to develop cross-browser way:
1. Avoid chrome.extension.getBackgroundPage() at all costs
2. Develop a cross-browser middle layer to call browser specific API
that above all implements message passing with named messages
and response callbacks
3. Store background script and content script / popup script logic in
separate files. Even if some mechanisms require both background
and content scripts. Use message passing, Luke.
4. For ajax requests in Firefox use Request API in background and
message passing.
content scripts,
styles, assets
• only one toolbar button
• can access background
window
• popup load on toolbar button
click and unload on hide
• javascript is loaded using
<script>
• popup size is calculated
automatically
• several toolbar buttons allowed
• popup javascript context is
isolated from background js
• popup is loaded when extension
is initialized and unloaded with
extension itself
• scripts should be loaded like
content scripts
• popup size is set manually
toolbar button
popup
How to develop cross-browser way:
1. Avoid chrome.extension.getBackgroundPage() at all costs
2. Consider that only one toolbar button allowed
3. Develop popup script assuming it is loaded once and should react to
all events that occur in content scripts and background script.
4. Keep in mind that Chrome and Firefox load popup differently
though.
5. In Firefox load popup scripts using content script mechanism and
block those loaded using <script>. (https://developer.mozilla.org/en-
US/Add-ons/SDK/Tutorials/Display_a_Popup)
toolbar button
popup
Format: .json
locale API available in:
• background script
• content script
• popup script
Format: .properties
locale API available in:
• background script only
that can pass dictionary to
rest of scripts
• in popup.html you can
use nls ids that will be
replaced by localized
strings
locales
How to develop cross-browser way:
1. Chose one of the formats as the base one (json).
2. Use firefox properties to store language identifier
only.
3. In Firefox content scripts and popup scripts should
request whole localized dictionary that background
should read from json. Or you can provide dictionary on
initialization of content and popup scripts as config.
locales
How to assemble cross-browser extension:
npm install -g yo
npm install -g generator-chrome-extension
npm install -g generator-firefox-extension
npm install -g jpm
How to assemble?
yo chrome-extension yo firefox-extension
Main difference:
background scripts - /lib
all the rest - /data
Lets make it look
more consistent
yo chrome-extension yo firefox-extension
Let’s move both
to the single project
yo chrome-extension yo firefox-extension
.gitignore
.gitignore
1. In the single project:
app-chrome
app-firefox
2. grunt copy:
app-chrome/scripts/bg-* -> app-firefox/lib
все остальное -> app-firefox/data
3. add to .gitignore
app-firefox/lib
app-firefox/data
yo chrome-extension yo firefox-extension
or…
adjust folder structure to
the Firefox standards and
update manifest.json
Let’s move both
to the single project
en-US.properties contains only one string:
lng= en
it is used to detect language and load appropriate .json
dictionary in bg-main-firefox
locales
and one last thing…
generator-firefox-extension uses cfx utility
for building and runs it using shell
cfx is deprecated by Mozilla
you should use jpm instead
but that’s easy
cfx syntax
jpm syntax
don’t forget:
cd app-firefox
How to develop cross-browser way:
• To generate prject use yeoman generators: generator-chrome-extension & generator-firefox-extension.
Replace cfx with jpm.
• Merge code base to the single project and setup grunt build.
• Setup grunt task that will synchronize manifest.json & package.json (version, title, description…).
• Develop a cross-browser middle layer to call browser specific API that above all implements message passing
with named messages and response callbacks
• Avoid chrome.extension.getBackgroundPage() at all costs
• Create two separate background scripts for Chrome & Firefox.
• Store background script and content script / popup script logic in separate files. Even if some mechanisms
require both background and content scripts. Use message passing, Luke.
• For ajax requests in Firefox use Request API in background and message passing, in Chrome - jQuery.ajax
will do.
• Consider that only one toolbar button allowed.
• Develop popup script assuming it is loaded once and should react to all events that occur in content scripts
and background script. Keep in mind that Chrome and Firefox load popup differently though.
• In Firefox load popup scripts using content script mechanism and block those loaded using <script>.
(https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Display_a_Popup).
• Chose one of the formats as the base one (json). Use firefox properties to store language identifier only. In
Firefox content scripts and popup scripts should request whole localized dictionary that background should
read from json. Or you can provide dictionary on initialization of content and popup scripts as config.
manifestbackground script
content scripts,
styles, assets
toolbar button
popup
all together
Is it worth it?
Browsers market share in Russian Federation
Overall browsers market share
To create IE extension with the same functionality like
Chrome or Firefox extension you need to implement it on
C#, so no cross-browser support here.
Google Chrome = Webkit = Opera = Yandex Browser, etc
Apple Safari is almost Webkit.
Keep in mind:
What about Safari?
So implementing browser extension the way it was
described here covers support of all the major browsers
except IE.
Questions?

More Related Content

What's hot

Chrome Apps & Extensions
Chrome Apps & ExtensionsChrome Apps & Extensions
Chrome Apps & Extensions
Varun Raj
 
Introduction of chrome extension development
Introduction of chrome extension developmentIntroduction of chrome extension development
Introduction of chrome extension development
Balduran Chang
 
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
adamhorvath
 
Chrome extension development
Chrome extension developmentChrome extension development
Chrome extension development
Michal Haták
 
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
flrent
 
Chrome extension development
Chrome extension developmentChrome extension development
Chrome extension development
Mārtiņš Balodis
 
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
Steven James
 
Introduction to Google Chrome Extensions Development
Introduction to Google Chrome Extensions DevelopmentIntroduction to Google Chrome Extensions Development
Introduction to Google Chrome Extensions Development
Jomar Tigcal
 
Develop Chrome Extension
Develop Chrome ExtensionDevelop Chrome Extension
Develop Chrome Extension
Aleksandr Golovatyi
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1
Umar Ali
 
Ajax difference faqs- 1
Ajax difference  faqs- 1Ajax difference  faqs- 1
Ajax difference faqs- 1
Umar Ali
 
Architecture of the Web browser
Architecture of the Web browserArchitecture of the Web browser
Architecture of the Web browser
Sabin Buraga
 
Architecture Best Practices
Architecture Best PracticesArchitecture Best Practices
Architecture Best Practices
AWS Germany
 
Advanced Chrome extension exploitation
Advanced Chrome extension exploitationAdvanced Chrome extension exploitation
Advanced Chrome extension exploitation
Krzysztof Kotowicz
 
Web Fundamentals
Web FundamentalsWeb Fundamentals
Web Fundamentals
arunv
 
OpenCms Days 2016: Next generation content repository
OpenCms Days 2016: Next generation content repository OpenCms Days 2016: Next generation content repository
OpenCms Days 2016: Next generation content repository
Alkacon Software GmbH & Co. KG
 
Introduction to Browser Internals
Introduction to Browser InternalsIntroduction to Browser Internals
Introduction to Browser Internals
Siva Arunachalam
 
Web Blogs
Web BlogsWeb Blogs
Web Blogs
doba2007
 
Html 5
Html 5Html 5
Html 5
Nguyen Quang
 
How Browsers Work
How Browsers Work How Browsers Work
How Browsers Work
myposter GmbH
 

What's hot (20)

Chrome Apps & Extensions
Chrome Apps & ExtensionsChrome Apps & Extensions
Chrome Apps & Extensions
 
Introduction of chrome extension development
Introduction of chrome extension developmentIntroduction of chrome extension development
Introduction of chrome extension development
 
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
Chrome Extension Development - Adam Horvath, Google Technology User Group, Sy...
 
Chrome extension development
Chrome extension developmentChrome extension development
Chrome extension development
 
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
 
Introduction to Google Chrome Extensions Development
Introduction to Google Chrome Extensions DevelopmentIntroduction to Google Chrome Extensions Development
Introduction to Google Chrome Extensions Development
 
Develop Chrome Extension
Develop Chrome ExtensionDevelop Chrome Extension
Develop Chrome Extension
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1
 
Ajax difference faqs- 1
Ajax difference  faqs- 1Ajax difference  faqs- 1
Ajax difference faqs- 1
 
Architecture of the Web browser
Architecture of the Web browserArchitecture of the Web browser
Architecture of the Web browser
 
Architecture Best Practices
Architecture Best PracticesArchitecture Best Practices
Architecture Best Practices
 
Advanced Chrome extension exploitation
Advanced Chrome extension exploitationAdvanced Chrome extension exploitation
Advanced Chrome extension exploitation
 
Web Fundamentals
Web FundamentalsWeb Fundamentals
Web Fundamentals
 
OpenCms Days 2016: Next generation content repository
OpenCms Days 2016: Next generation content repository OpenCms Days 2016: Next generation content repository
OpenCms Days 2016: Next generation content repository
 
Introduction to Browser Internals
Introduction to Browser InternalsIntroduction to Browser Internals
Introduction to Browser Internals
 
Web Blogs
Web BlogsWeb Blogs
Web Blogs
 
Html 5
Html 5Html 5
Html 5
 
How Browsers Work
How Browsers Work How Browsers Work
How Browsers Work
 

Viewers also liked

Оранжевый - новый синий: Как портировать Chrome Extension в Firefox Extension
Оранжевый - новый синий: Как портировать Chrome Extension в Firefox ExtensionОранжевый - новый синий: Как портировать Chrome Extension в Firefox Extension
Оранжевый - новый синий: Как портировать Chrome Extension в Firefox Extension
chaykaborya
 
Особенности разработки браузерных расширений для Single Page Application
Особенности разработки браузерных расширений для Single Page ApplicationОсобенности разработки браузерных расширений для Single Page Application
Особенности разработки браузерных расширений для Single Page Application
chaykaborya
 
Sotm 2010 the tyranny of place
Sotm 2010   the tyranny of placeSotm 2010   the tyranny of place
Sotm 2010 the tyranny of place
Muki Haklay
 
Keith Car CV
Keith Car  CVKeith Car  CV
Keith Car CV
Keith Carr
 
FanXuResume_2016
FanXuResume_2016FanXuResume_2016
FanXuResume_2016
Fan Xu
 
E strategy english riviera tourism company update
E strategy english riviera tourism company updateE strategy english riviera tourism company update
E strategy english riviera tourism company update
e-Strategy
 
Federico Garnier - France - Tuesday 29 - Hematopoietic Stem Cells
Federico Garnier  - France - Tuesday 29 - Hematopoietic Stem CellsFederico Garnier  - France - Tuesday 29 - Hematopoietic Stem Cells
Federico Garnier - France - Tuesday 29 - Hematopoietic Stem Cells
incucai_isodp
 
Como resolver problemas
Como resolver problemasComo resolver problemas
Como resolver problemas
Armando Torres
 
L13 ic based triggering circuit
L13 ic based triggering circuitL13 ic based triggering circuit
L13 ic based triggering circuit
Mohammad Umar Rehman
 
AngularJS2 vs VueJS2 (ru)
AngularJS2 vs VueJS2 (ru)AngularJS2 vs VueJS2 (ru)
AngularJS2 vs VueJS2 (ru)
chaykaborya
 
Be away from Conflict
Be away from ConflictBe away from Conflict
Be away from Conflict
Yaswanth Ravella
 
AgRiDOC: A New Breed of Agricultural Development of Extension Officers
AgRiDOC: A New Breed of Agricultural Development of Extension OfficersAgRiDOC: A New Breed of Agricultural Development of Extension Officers
AgRiDOC: A New Breed of Agricultural Development of Extension Officers
Agricultural Training Institute
 
Coriander update Nov2016
Coriander update Nov2016Coriander update Nov2016
Coriander update Nov2016
Ritesh Kumar Sahu
 
Aspectos dermatologicos de Candidiosis
Aspectos dermatologicos de CandidiosisAspectos dermatologicos de Candidiosis
Aspectos dermatologicos de Candidiosis
Novatikatj
 
Early recognition of meningitis
Early recognition of meningitisEarly recognition of meningitis
Early recognition of meningitis
Meningitis Research Foundation
 
3 Essential Steps to Deliver Information Governance Success Through Strategy ...
3 Essential Steps to Deliver Information Governance Success Through Strategy ...3 Essential Steps to Deliver Information Governance Success Through Strategy ...
3 Essential Steps to Deliver Information Governance Success Through Strategy ...
DATUM LLC
 
"Angular 2: Всех переиграл" Евгений Жарков
"Angular 2: Всех переиграл" Евгений Жарков"Angular 2: Всех переиграл" Евгений Жарков
"Angular 2: Всех переиграл" Евгений Жарков
Fwdays
 
Therapeutic drug monitoring
Therapeutic  drug monitoringTherapeutic  drug monitoring
Therapeutic drug monitoring
Ramakanth Gadepalli
 
Vitulano OKB Eğitimi, 3 Kasım 2015
Vitulano OKB Eğitimi, 3 Kasım 2015Vitulano OKB Eğitimi, 3 Kasım 2015
Vitulano OKB Eğitimi, 3 Kasım 2015
YDY Eğitim Araştırma Danışmanlık
 
Conditioning regimen for haplo transplant
Conditioning regimen for haplo transplantConditioning regimen for haplo transplant
Conditioning regimen for haplo transplant
spa718
 

Viewers also liked (20)

Оранжевый - новый синий: Как портировать Chrome Extension в Firefox Extension
Оранжевый - новый синий: Как портировать Chrome Extension в Firefox ExtensionОранжевый - новый синий: Как портировать Chrome Extension в Firefox Extension
Оранжевый - новый синий: Как портировать Chrome Extension в Firefox Extension
 
Особенности разработки браузерных расширений для Single Page Application
Особенности разработки браузерных расширений для Single Page ApplicationОсобенности разработки браузерных расширений для Single Page Application
Особенности разработки браузерных расширений для Single Page Application
 
Sotm 2010 the tyranny of place
Sotm 2010   the tyranny of placeSotm 2010   the tyranny of place
Sotm 2010 the tyranny of place
 
Keith Car CV
Keith Car  CVKeith Car  CV
Keith Car CV
 
FanXuResume_2016
FanXuResume_2016FanXuResume_2016
FanXuResume_2016
 
E strategy english riviera tourism company update
E strategy english riviera tourism company updateE strategy english riviera tourism company update
E strategy english riviera tourism company update
 
Federico Garnier - France - Tuesday 29 - Hematopoietic Stem Cells
Federico Garnier  - France - Tuesday 29 - Hematopoietic Stem CellsFederico Garnier  - France - Tuesday 29 - Hematopoietic Stem Cells
Federico Garnier - France - Tuesday 29 - Hematopoietic Stem Cells
 
Como resolver problemas
Como resolver problemasComo resolver problemas
Como resolver problemas
 
L13 ic based triggering circuit
L13 ic based triggering circuitL13 ic based triggering circuit
L13 ic based triggering circuit
 
AngularJS2 vs VueJS2 (ru)
AngularJS2 vs VueJS2 (ru)AngularJS2 vs VueJS2 (ru)
AngularJS2 vs VueJS2 (ru)
 
Be away from Conflict
Be away from ConflictBe away from Conflict
Be away from Conflict
 
AgRiDOC: A New Breed of Agricultural Development of Extension Officers
AgRiDOC: A New Breed of Agricultural Development of Extension OfficersAgRiDOC: A New Breed of Agricultural Development of Extension Officers
AgRiDOC: A New Breed of Agricultural Development of Extension Officers
 
Coriander update Nov2016
Coriander update Nov2016Coriander update Nov2016
Coriander update Nov2016
 
Aspectos dermatologicos de Candidiosis
Aspectos dermatologicos de CandidiosisAspectos dermatologicos de Candidiosis
Aspectos dermatologicos de Candidiosis
 
Early recognition of meningitis
Early recognition of meningitisEarly recognition of meningitis
Early recognition of meningitis
 
3 Essential Steps to Deliver Information Governance Success Through Strategy ...
3 Essential Steps to Deliver Information Governance Success Through Strategy ...3 Essential Steps to Deliver Information Governance Success Through Strategy ...
3 Essential Steps to Deliver Information Governance Success Through Strategy ...
 
"Angular 2: Всех переиграл" Евгений Жарков
"Angular 2: Всех переиграл" Евгений Жарков"Angular 2: Всех переиграл" Евгений Жарков
"Angular 2: Всех переиграл" Евгений Жарков
 
Therapeutic drug monitoring
Therapeutic  drug monitoringTherapeutic  drug monitoring
Therapeutic drug monitoring
 
Vitulano OKB Eğitimi, 3 Kasım 2015
Vitulano OKB Eğitimi, 3 Kasım 2015Vitulano OKB Eğitimi, 3 Kasım 2015
Vitulano OKB Eğitimi, 3 Kasım 2015
 
Conditioning regimen for haplo transplant
Conditioning regimen for haplo transplantConditioning regimen for haplo transplant
Conditioning regimen for haplo transplant
 

Similar to Orange is the new blue: How to port Chrome Extension to Firefox Extension

Cliw - extension development
Cliw -  extension developmentCliw -  extension development
Cliw - extension development
vicccuu
 
Browser Extensions for Web Hackers
Browser Extensions for Web HackersBrowser Extensions for Web Hackers
Browser Extensions for Web Hackers
Mark Wubben
 
Cross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitationCross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitation
Roberto Suggi Liverani
 
Browser Security
Browser SecurityBrowser Security
Browser Security
Roberto Suggi Liverani
 
Composer namespacing
Composer namespacingComposer namespacing
Composer namespacing
Deepak Chandani
 
Getting started with add ons
Getting started with add onsGetting started with add ons
Getting started with add ons
CS Simple education
 
Adobe Flex Resources 6439
Adobe Flex Resources 6439Adobe Flex Resources 6439
Adobe Flex Resources 6439
Mohanraj Nagasamy
 
Adobe Flex Resources
Adobe Flex ResourcesAdobe Flex Resources
Adobe Flex Resources
Prayank Swaroop
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3
Asher Martin
 
Composer
ComposerComposer
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
Adam Englander
 
Window Shopping Browser - Bug Hunting in 2012
Window Shopping Browser - Bug Hunting in 2012Window Shopping Browser - Bug Hunting in 2012
Window Shopping Browser - Bug Hunting in 2012
Roberto Suggi Liverani
 
Firefox (in)Security
Firefox (in)SecurityFirefox (in)Security
Firefox (in)Security
Prasanna Kanagasabai
 
Chrome Extensions for Web Hackers
Chrome Extensions for Web HackersChrome Extensions for Web Hackers
Chrome Extensions for Web Hackers
Mark Wubben
 
How and Why to extend Firefox
How and Why to extend FirefoxHow and Why to extend Firefox
How and Why to extend Firefox
Graham King
 
DevOPS training - Day 1/2
DevOPS training - Day 1/2DevOPS training - Day 1/2
DevOPS training - Day 1/2
Vincent Mercier
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
Francois Zaninotto
 
Enyo Hackathon Presentation
Enyo Hackathon PresentationEnyo Hackathon Presentation
Enyo Hackathon Presentation
Ben Combee
 
Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku
Rapid Prototyping Chatter with a PHP/Hack Canvas App on HerokuRapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku
Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku
Salesforce Developers
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
Manuele Menozzi
 

Similar to Orange is the new blue: How to port Chrome Extension to Firefox Extension (20)

Cliw - extension development
Cliw -  extension developmentCliw -  extension development
Cliw - extension development
 
Browser Extensions for Web Hackers
Browser Extensions for Web HackersBrowser Extensions for Web Hackers
Browser Extensions for Web Hackers
 
Cross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitationCross Context Scripting attacks & exploitation
Cross Context Scripting attacks & exploitation
 
Browser Security
Browser SecurityBrowser Security
Browser Security
 
Composer namespacing
Composer namespacingComposer namespacing
Composer namespacing
 
Getting started with add ons
Getting started with add onsGetting started with add ons
Getting started with add ons
 
Adobe Flex Resources 6439
Adobe Flex Resources 6439Adobe Flex Resources 6439
Adobe Flex Resources 6439
 
Adobe Flex Resources
Adobe Flex ResourcesAdobe Flex Resources
Adobe Flex Resources
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3
 
Composer
ComposerComposer
Composer
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
 
Window Shopping Browser - Bug Hunting in 2012
Window Shopping Browser - Bug Hunting in 2012Window Shopping Browser - Bug Hunting in 2012
Window Shopping Browser - Bug Hunting in 2012
 
Firefox (in)Security
Firefox (in)SecurityFirefox (in)Security
Firefox (in)Security
 
Chrome Extensions for Web Hackers
Chrome Extensions for Web HackersChrome Extensions for Web Hackers
Chrome Extensions for Web Hackers
 
How and Why to extend Firefox
How and Why to extend FirefoxHow and Why to extend Firefox
How and Why to extend Firefox
 
DevOPS training - Day 1/2
DevOPS training - Day 1/2DevOPS training - Day 1/2
DevOPS training - Day 1/2
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Enyo Hackathon Presentation
Enyo Hackathon PresentationEnyo Hackathon Presentation
Enyo Hackathon Presentation
 
Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku
Rapid Prototyping Chatter with a PHP/Hack Canvas App on HerokuRapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku
Rapid Prototyping Chatter with a PHP/Hack Canvas App on Heroku
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
 

Recently uploaded

一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
Rakesh Kumar R
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
AnkitaPandya11
 

Recently uploaded (20)

一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
What next after learning python programming basics
What next after learning python programming basicsWhat next after learning python programming basics
What next after learning python programming basics
 
fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.fiscal year variant fiscal year variant.
fiscal year variant fiscal year variant.
 

Orange is the new blue: How to port Chrome Extension to Firefox Extension

  • 1. Orange is the new blue How to port Chrome Extension to Firefox Extension or develop cross-browser extension from scratch Boris Mossounov facebook.com/mossounov linkedin.com/in/borismossounov anotherguru.me
  • 2. Major architectural differences: Chrome Extension v.s. Firefox Addon
  • 4. While digging Mozilla docs you can come across: Legacy Extensions Overlay extensions Restartless Extensions Bootstrapped Extensions Add-on SDK Extensions Jetpack SDK Add-on SDK = = =
  • 5. Firefox Addon history digest: Legacy Extensions / Overlay Extensions (XUL, JSM, XPCOM) 2004.06 - Firefox 0.9
  • 6. Legacy Extensions / Overlay Extensions (XUL, JSM, XPCOM) 2004.06 - Firefox 0.9 Firefox Addon history digest:
  • 7. Legacy Extensions / Overlay Extensions (XUL, JSM, XPCOM) 2004.06 - Firefox 0.9 browser.xul: overlay.xul: Firefox Addon history digest:
  • 8. Legacy Extensions / Overlay Extensions (XUL, JSM, XPCOM) 2004.06 - Firefox 0.9 Mozilla starts Jetpack SDK project 2009.09 Firefox Addon history digest:
  • 9.
  • 10. Legacy Extensions / Overlay Extensions (XUL, JSM, XPCOM) 2004.06 - Firefox 0.9 Mozilla starts Jetpack SDK project 2009.09 Restartless Extensions / Bootstrapped Extensions 2011.03 - Firefox 4+ Jetpack SDK 0.1 release Addon SDK extensions cfx tool (python powered) 2011.06 jpm tool (node.js powered) 2015.05 - Firefox 38 Firefox Addon history digest:
  • 11. Google announces Chrome Extensions support 2009.09 Google Chrome Store launches (with blackjack and extensions) 2010.12 Chrome Extension history digest:
  • 12. Краткая история: 2004.06 - Firefox 0.9 2009.09 2011.03 - Firefox 4+ 2011.06 2015.05 - Firefox 38 2010.12 Google announces Chrome Extensions support Legacy Extensions / Overlay Extensions (XUL, JSM, XPCOM) addons.mozilla.org Mozilla starts Jetpack SDK project Restartless Extensions / Bootstrapped Extensions Jetpack SDK 0.1 release Addon SDK extensions cfx tool (python powered) jpm tool (node.js powered) Google Chrome Store launches (with blackjack and extensions)
  • 13. While digging Mozilla docs you should read about: Legacy Extensions Overlay extensions Restartless Extensions Bootstrapped Extensions Add-on SDK Extensions Jetpack SDK Add-on SDK = = =
  • 14. An average browser extension consists of the following blocks: manifest background script content scripts, styles, assets toolbar button popup locales embedded pages (options / help)
  • 15. The major difference between Chrome Extension and Firefox Addon is the way the following 3 blocks interact: background.js contentscript.js popup.js
  • 16. Google Chrome possesses two APIs for message passing: • Simple one-time requests • Long-lived connections https://developer.chrome.com/extensions/messaging
  • 18. chrome.runtime.sendMessage({ greeting: «hello» }, function(response) { console.log(response.farewell); }); background.js contentscript.js popup.js
  • 19. chrome.tabs.sendMessage(tabs[0].id, { greeting: «hello» }, function(response) { console.log(response.farewell); }); background.js contentscript.js
  • 20. chrome.runtime.onMessage.addListener( function(request, sender, callback) { console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension"); if (request.greeting == "hello") callback({farewell: "goodbye"}); }); background.js contentscript.js popup.js ?
  • 22. port.postMessage({joke: "Knock knock»}); port.onMessage.addListener(function(msg) { if (msg.question == "Who's there?"){ port.postMessage({answer: "#4front"}); } }); background.js contentscript.js popup.js
  • 23. Window chrome.extension.getBackgroundPage() background.js contentscript.js popup.js contentscript.js & popup.js can: Is cross-browser support on the table? If it is, then don’t. If not, go on.
  • 24. background.js contentscript.js popup.js • two message passing APIs • contentscript.js & popup.js can get background window object and store some objects and methods there. • all blocks can interact using untitled messages and setting response callbacks. • background.js knows nothing about other scripts till they connect to it
  • 26. port.emit("myMessage", msg); port.on("myMessage",function(msg) { if (msg.question == "Who's there?") port.emit("myMessage.reply", { answer: "#4front" }); }); background.js contentscript.js popup.js
  • 27.
  • 28. background.js contentscript.js popup.js • all blocks are run in isolated runtimes and can interact using named messages without response callbacks • background.js creates contentscript.js & popup.js and can control them
  • 29. callbacks = { «1234»: function(payload){}, «1235»: function(payload){} } message = { action: «myMessage.reply», uid: 1234, paylaod: {} } message = { } message = { action: «myMessage», paylaod: {} } message = { action: «myMessage», uid: 1234, paylaod: {} }
  • 30. Let’s compare Mozilla Extension & Chrome Extension by blocks: manifest background script content scripts, styles, assets toolbar button popup locales embedded pages (options / help)
  • 31. manifest manifest.json describes: • title, description, version, license, • location of all scripts, styles, html, • permissions package.json describes: • title, description, version, license, • location of background script and background script loads all the content & popup scripts, styles, html
  • 32. manifest How to develop cross-browser way: Setup grunt task, that will synchronize manifest.json & package.json (version, title, description…)
  • 33. • Invisible html page with it’s window js-object, • this window js-object shares the same runtime context with content scripts and popup script • Separate javascript without window object. • this javascript is run in an isolated runtime • Background script initializes content scripts and popup and can control them. • EcmaScript 6 background script
  • 34. How to develop cross-browser way: 1. Avoid chrome.extension.getBackgroundPage() at all costs 2. For Firefox - create separate background script since firefox addon sdk is implemented on ES6. 3. Develop a cross-browser middle layer to call browser specific API that above all implements message passing with named messages and response callbacks 4. Store background script and content script / popup script logic in separate files. Even if some mechanisms require both background and content scripts. Use message passing, Luke. background script
  • 35. • content scripts are run in a web-page isolated world • can access background window • cross-domain request are manifest permission dependent • content scripts are run in a web-page isolated world • are run in context isolated from background script • cross-domain requests are forbidden content scripts, styles, assets
  • 36. How to develop cross-browser way: 1. Avoid chrome.extension.getBackgroundPage() at all costs 2. Develop a cross-browser middle layer to call browser specific API that above all implements message passing with named messages and response callbacks 3. Store background script and content script / popup script logic in separate files. Even if some mechanisms require both background and content scripts. Use message passing, Luke. 4. For ajax requests in Firefox use Request API in background and message passing. content scripts, styles, assets
  • 37. • only one toolbar button • can access background window • popup load on toolbar button click and unload on hide • javascript is loaded using <script> • popup size is calculated automatically • several toolbar buttons allowed • popup javascript context is isolated from background js • popup is loaded when extension is initialized and unloaded with extension itself • scripts should be loaded like content scripts • popup size is set manually toolbar button popup
  • 38. How to develop cross-browser way: 1. Avoid chrome.extension.getBackgroundPage() at all costs 2. Consider that only one toolbar button allowed 3. Develop popup script assuming it is loaded once and should react to all events that occur in content scripts and background script. 4. Keep in mind that Chrome and Firefox load popup differently though. 5. In Firefox load popup scripts using content script mechanism and block those loaded using <script>. (https://developer.mozilla.org/en- US/Add-ons/SDK/Tutorials/Display_a_Popup) toolbar button popup
  • 39. Format: .json locale API available in: • background script • content script • popup script Format: .properties locale API available in: • background script only that can pass dictionary to rest of scripts • in popup.html you can use nls ids that will be replaced by localized strings locales
  • 40. How to develop cross-browser way: 1. Chose one of the formats as the base one (json). 2. Use firefox properties to store language identifier only. 3. In Firefox content scripts and popup scripts should request whole localized dictionary that background should read from json. Or you can provide dictionary on initialization of content and popup scripts as config. locales
  • 41. How to assemble cross-browser extension: npm install -g yo npm install -g generator-chrome-extension npm install -g generator-firefox-extension npm install -g jpm
  • 42. How to assemble? yo chrome-extension yo firefox-extension Main difference: background scripts - /lib all the rest - /data
  • 43. Lets make it look more consistent yo chrome-extension yo firefox-extension
  • 44. Let’s move both to the single project yo chrome-extension yo firefox-extension .gitignore .gitignore 1. In the single project: app-chrome app-firefox 2. grunt copy: app-chrome/scripts/bg-* -> app-firefox/lib все остальное -> app-firefox/data 3. add to .gitignore app-firefox/lib app-firefox/data
  • 45. yo chrome-extension yo firefox-extension or… adjust folder structure to the Firefox standards and update manifest.json Let’s move both to the single project
  • 46. en-US.properties contains only one string: lng= en it is used to detect language and load appropriate .json dictionary in bg-main-firefox locales
  • 47. and one last thing… generator-firefox-extension uses cfx utility for building and runs it using shell cfx is deprecated by Mozilla you should use jpm instead but that’s easy
  • 50. How to develop cross-browser way: • To generate prject use yeoman generators: generator-chrome-extension & generator-firefox-extension. Replace cfx with jpm. • Merge code base to the single project and setup grunt build. • Setup grunt task that will synchronize manifest.json & package.json (version, title, description…). • Develop a cross-browser middle layer to call browser specific API that above all implements message passing with named messages and response callbacks • Avoid chrome.extension.getBackgroundPage() at all costs • Create two separate background scripts for Chrome & Firefox. • Store background script and content script / popup script logic in separate files. Even if some mechanisms require both background and content scripts. Use message passing, Luke. • For ajax requests in Firefox use Request API in background and message passing, in Chrome - jQuery.ajax will do. • Consider that only one toolbar button allowed. • Develop popup script assuming it is loaded once and should react to all events that occur in content scripts and background script. Keep in mind that Chrome and Firefox load popup differently though. • In Firefox load popup scripts using content script mechanism and block those loaded using <script>. (https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Display_a_Popup). • Chose one of the formats as the base one (json). Use firefox properties to store language identifier only. In Firefox content scripts and popup scripts should request whole localized dictionary that background should read from json. Or you can provide dictionary on initialization of content and popup scripts as config. manifestbackground script content scripts, styles, assets toolbar button popup all together
  • 51. Is it worth it?
  • 52. Browsers market share in Russian Federation
  • 54. To create IE extension with the same functionality like Chrome or Firefox extension you need to implement it on C#, so no cross-browser support here. Google Chrome = Webkit = Opera = Yandex Browser, etc Apple Safari is almost Webkit. Keep in mind:
  • 56. So implementing browser extension the way it was described here covers support of all the major browsers except IE.