SlideShare une entreprise Scribd logo
1  sur  30
Browser Extensions




  Erwan Loisant <elo@zenexity.com>

             @erwan
Why?

• Integrate deeply with a service
• Add new features to the browser
• Implement a recent spec in a lagging
  browser
• Anything you can think of!
History

• 20th Century: plugins, native addons
• 2002: Mozilla 1.0 written in XUL and Javascript
• 2004: Firefox 1.0 with a focus on extensions
• 2007: FUEL (Firefox User Extension Library)
• 2009: Jetpack, Chrome Extensions
POWER
     vs




EASE OF DEV
local storage
                   Javascript
            JSON

CSS                     HTML
{
    "name": "Telify",
    "version": "0.1",
    "description": "Click to call",
    "background_page": "background.html",
    "page_action": {
        "default_icon": "icons/tel.gif",
        "default_popup": "popup.html"
    },
    "content_scripts" : [{
        "matches" : ["http://*/*"],
        "js" : ["contentScript.js"]
    }],
    "permissions": [
        "http://cdnjs.cloudflare.com"
    ]
}




              manifest.json
var phoneRe = /^s*((d{2}s?){5})s*$/;

var texts = document.evaluate(".//text()[normalize-space(.)!
='']", document.body, null, 6, null);

var phones = [];
for (var i = 0; i < texts.snapshotLength; i++) {
    var textNode = texts.snapshotItem(i);
    var text = textNode.textContent;
    var m = phoneRe.exec(text);
    if (m != null) {
        var newText = document.createElement("a");
        newText.setAttribute("href", "callto:" + m[1]);
        newText.appendChild(document.createTextNode(m[0]));
        textNode.parentNode.replaceChild(newText, textNode);
        phones.push(m[1]);
    }
}

if (phones.length > 0) {
    chrome.extension.sendRequest(
        {"phones": phones},
        function(response) {});
}

                     contentScript.js
<script>

// Global variable accessed by the popup
var telList;

chrome.extension.onRequest.addListener(function(request,
sender, sendResponse) {
    telList = request["phones"];
    chrome.pageAction.show(sender.tab.id);
    sendResponse({});
});

</script>




                  background.html
<!DOCTYPE html>

<html>
  <style> body { width: 200px; } </style>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/
zepto/0.7/zepto.min.js"></script>
  <script>
    $(document).ready(function(){
       var telList =
chrome.extension.getBackgroundPage().telList;
       if (telList && telList.length > 0) {
         for (i in telList)
           $("ul").append("<li><a href='callto:" +
telList[i] + "'>" + telList[i] + "</a></li>");
       }
    });
    </script>

    <body><ul></ul></body>
</html>




                     popup.html
XPCOM

      XUL
                  Javascript
            XBL

CSS                        HTML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css"
  href="chrome://custombutton/content/button.css"?>

<!DOCTYPE overlay >
<overlay id="custombutton-overlay"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">

<script type="application/javascript"
  src="chrome://custombutton/content/button.js"/>

<!-- Firefox -->
<toolbarpalette id="BrowserToolbarPalette">
  <toolbarbutton id="custom-button-1"/>
  </toolbarpalette>

<!-- button details -->
<toolbarbutton id="custom-button-1"
  label="Custom"
  tooltiptext="My custom toolbar button"
  oncommand="CustomButton()"
  class="toolbarbutton-1 chromeclass-toolbar-additional custombutton"
  />

</overlay>

                             overlay.xul
function installButton(toolbarId, id, afterId) {
    if (!document.getElementById(id)) {
        var toolbar = document.getElementById(toolbarId);

        var before = toolbar.firstChild;
        if (afterId) {
            let elem = document.getElementById(afterId);
            if (elem && elem.parentNode == toolbar)
                before = elem.nextElementSibling;
        }

        toolbar.insertItem(id, before);
        toolbar.setAttribute("currentset", toolbar.currentSet);
        document.persist(toolbar.id, "currentset");

        if (toolbarId == "addon-bar")
            toolbar.collapsed = false;
    }
}

if (firstRun) {
    installButton("nav-bar", "my-extension-navbar-button", "urlbar");
    installButton("addon-bar", "my-extension-addon-bar-button");
}



                            overlay.xul
AKA:
“The Chrome way applied to Firefox”
{
    "name": "weather-example",
    "license": "MPL 1.1/GPL 2.0/LGPL 2.1",
    "author": "Alexandre Poirot",
    "version": "1.0",
    "fullName": "Weather example",
    "id": "weather-example",
    "description": "a basic add-on that display a
weather widget"
}




                     package.json
const   data = require("self").data;
const   ss = require("simple-storage");
const   Request = require("request").Request;
const   timer = require("timer");

const panel = require("panel").Panel({
  width: 240,
  height: 180,
  contentURL: data.url("panel.html"),
  contentScriptFile: [data.url("panel.js")],
  onShow: function () {
    this.port.emit("show");
  }
});

[...]




                      lib/main.js
COM
            C#



C++                 ActiveX



      Windows API
STDMETHODIMP CExplorerBar::SetSite(IUnknown *punkSite) {
    //If a site is being held, release it.
    if(m_pSite) {
        m_pSite->Release();
        m_pSite = NULL;
    }

    //If punkSite is not NULL, a new site is being set.
    if (punkSite) {
        //Get the parent window.
        IOleWindow *pOleWindow;

        m_hwndParent = NULL;

        if(SUCCEEDED(punkSite->QueryInterface(IID_IOleWindow,
                     (LPVOID*)&pOleWindow))) {
            pOleWindow->GetWindow(&m_hwndParent);
            pOleWindow->Release();
        }

        if(!m_hwndParent) return E_FAIL;

        if(!RegisterAndCreateWindow()) return E_FAIL;

        //Get and keep the IInputObjectSite pointer.
        if(SUCCEEDED(punkSite->QueryInterface(IID_IInputObjectSite,
                     (LPVOID*)&m_pSite))) {
            return S_OK;
        }

        return E_FAIL;
    }

    return S_OK;
}
Fortunately, there’s more...
Accelerators (IE8+)
Pinning API (IE9+)
window.external.msSiteModeClearIconOverlay()
window.external.msSiteModeSetIconOverlay()
window.external.msSiteModeActivate()
window.external.msIsSiteMode()
Do we really need
  extensions?
Do we really need
  extensions?
last word: don’t abuse
      extensions!
Questions?

    @erwan
elo@zenexity.com

Contenu connexe

Tendances

MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2Takahiro Inoue
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤Takahiro Inoue
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEBHoward Lewis Ship
 
PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppet
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksBruno Rocha
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
Ember background basics
Ember background basicsEmber background basics
Ember background basicsPhilipp Fehre
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuerydeimos
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1Ke Wei Louis
 
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Jung Kim
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)MongoSF
 
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 SederhanaPraktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 SederhanaMuhammad Yusuf
 

Tendances (20)

MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
 
HTML,CSS Next
HTML,CSS NextHTML,CSS Next
HTML,CSS Next
 
Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Nubilus Perl
Nubilus PerlNubilus Perl
Nubilus Perl
 
MongoDB Oplog入門
MongoDB Oplog入門MongoDB Oplog入門
MongoDB Oplog入門
 
Php
PhpPhp
Php
 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
 
PuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbqueryPuppetDB, Puppet Explorer and puppetdbquery
PuppetDB, Puppet Explorer and puppetdbquery
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Ember background basics
Ember background basicsEmber background basics
Ember background basics
 
Web2py
Web2pyWeb2py
Web2py
 
WebXR if X = how?
WebXR if X = how?WebXR if X = how?
WebXR if X = how?
 
Remy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQueryRemy Sharp The DOM scripting toolkit jQuery
Remy Sharp The DOM scripting toolkit jQuery
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
Letswift18 워크숍#1 스위프트 클린코드와 코드리뷰
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
 
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 SederhanaPraktik Pengembangan Konten E-Learning HTML5 Sederhana
Praktik Pengembangan Konten E-Learning HTML5 Sederhana
 

Similaire à Paris js extensions

Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformRobert Nyman
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02PL dream
 
Mozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSMozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSRobert Nyman
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4DEVCON
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QAAlban Gérôme
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMichael Dawson
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天tblanlan
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajaxbaygross
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-futureyiming he
 
HTML5 APIs - Where No Man Has Gone Before! - GothamJS
HTML5 APIs - Where No Man Has Gone Before! - GothamJSHTML5 APIs - Where No Man Has Gone Before! - GothamJS
HTML5 APIs - Where No Man Has Gone Before! - GothamJSRobert Nyman
 
HTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranRobert Nyman
 

Similaire à Paris js extensions (20)

Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
mobl
moblmobl
mobl
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
 
前端概述
前端概述前端概述
前端概述
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
Mozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJSMozilla Web Apps - Super-VanJS
Mozilla Web Apps - Super-VanJS
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive Boston
 
Micro app-framework
Micro app-frameworkMicro app-framework
Micro app-framework
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
HTML5 APIs - Where No Man Has Gone Before! - GothamJS
HTML5 APIs - Where No Man Has Gone Before! - GothamJSHTML5 APIs - Where No Man Has Gone Before! - GothamJS
HTML5 APIs - Where No Man Has Gone Before! - GothamJS
 
HTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - Altran
 

Dernier

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
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 2024Victor Rentea
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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...apidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
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 challengesrafiqahmad00786416
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
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 businesspanagenda
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Dernier (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Paris js extensions

  • 1. Browser Extensions Erwan Loisant <elo@zenexity.com> @erwan
  • 2. Why? • Integrate deeply with a service • Add new features to the browser • Implement a recent spec in a lagging browser • Anything you can think of!
  • 3. History • 20th Century: plugins, native addons • 2002: Mozilla 1.0 written in XUL and Javascript • 2004: Firefox 1.0 with a focus on extensions • 2007: FUEL (Firefox User Extension Library) • 2009: Jetpack, Chrome Extensions
  • 4. POWER vs EASE OF DEV
  • 5.
  • 6. local storage Javascript JSON CSS HTML
  • 7.
  • 8. { "name": "Telify", "version": "0.1", "description": "Click to call", "background_page": "background.html", "page_action": { "default_icon": "icons/tel.gif", "default_popup": "popup.html" }, "content_scripts" : [{ "matches" : ["http://*/*"], "js" : ["contentScript.js"] }], "permissions": [ "http://cdnjs.cloudflare.com" ] } manifest.json
  • 9. var phoneRe = /^s*((d{2}s?){5})s*$/; var texts = document.evaluate(".//text()[normalize-space(.)! ='']", document.body, null, 6, null); var phones = []; for (var i = 0; i < texts.snapshotLength; i++) { var textNode = texts.snapshotItem(i); var text = textNode.textContent; var m = phoneRe.exec(text); if (m != null) { var newText = document.createElement("a"); newText.setAttribute("href", "callto:" + m[1]); newText.appendChild(document.createTextNode(m[0])); textNode.parentNode.replaceChild(newText, textNode); phones.push(m[1]); } } if (phones.length > 0) { chrome.extension.sendRequest( {"phones": phones}, function(response) {}); } contentScript.js
  • 10. <script> // Global variable accessed by the popup var telList; chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { telList = request["phones"]; chrome.pageAction.show(sender.tab.id); sendResponse({}); }); </script> background.html
  • 11. <!DOCTYPE html> <html> <style> body { width: 200px; } </style> <script src="http://cdnjs.cloudflare.com/ajax/libs/ zepto/0.7/zepto.min.js"></script> <script> $(document).ready(function(){ var telList = chrome.extension.getBackgroundPage().telList; if (telList && telList.length > 0) { for (i in telList) $("ul").append("<li><a href='callto:" + telList[i] + "'>" + telList[i] + "</a></li>"); } }); </script> <body><ul></ul></body> </html> popup.html
  • 12.
  • 13.
  • 14. XPCOM XUL Javascript XBL CSS HTML
  • 15. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="chrome://custombutton/content/button.css"?> <!DOCTYPE overlay > <overlay id="custombutton-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/ there.is.only.xul"> <script type="application/javascript" src="chrome://custombutton/content/button.js"/> <!-- Firefox --> <toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="custom-button-1"/> </toolbarpalette> <!-- button details --> <toolbarbutton id="custom-button-1" label="Custom" tooltiptext="My custom toolbar button" oncommand="CustomButton()" class="toolbarbutton-1 chromeclass-toolbar-additional custombutton" /> </overlay> overlay.xul
  • 16. function installButton(toolbarId, id, afterId) { if (!document.getElementById(id)) { var toolbar = document.getElementById(toolbarId); var before = toolbar.firstChild; if (afterId) { let elem = document.getElementById(afterId); if (elem && elem.parentNode == toolbar) before = elem.nextElementSibling; } toolbar.insertItem(id, before); toolbar.setAttribute("currentset", toolbar.currentSet); document.persist(toolbar.id, "currentset"); if (toolbarId == "addon-bar") toolbar.collapsed = false; } } if (firstRun) { installButton("nav-bar", "my-extension-navbar-button", "urlbar"); installButton("addon-bar", "my-extension-addon-bar-button"); } overlay.xul
  • 17. AKA: “The Chrome way applied to Firefox”
  • 18. { "name": "weather-example", "license": "MPL 1.1/GPL 2.0/LGPL 2.1", "author": "Alexandre Poirot", "version": "1.0", "fullName": "Weather example", "id": "weather-example", "description": "a basic add-on that display a weather widget" } package.json
  • 19. const data = require("self").data; const ss = require("simple-storage"); const Request = require("request").Request; const timer = require("timer"); const panel = require("panel").Panel({ width: 240, height: 180, contentURL: data.url("panel.html"), contentScriptFile: [data.url("panel.js")], onShow: function () { this.port.emit("show"); } }); [...] lib/main.js
  • 20.
  • 21.
  • 22. COM C# C++ ActiveX Windows API
  • 23. STDMETHODIMP CExplorerBar::SetSite(IUnknown *punkSite) { //If a site is being held, release it. if(m_pSite) { m_pSite->Release(); m_pSite = NULL; } //If punkSite is not NULL, a new site is being set. if (punkSite) { //Get the parent window. IOleWindow *pOleWindow; m_hwndParent = NULL; if(SUCCEEDED(punkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow))) { pOleWindow->GetWindow(&m_hwndParent); pOleWindow->Release(); } if(!m_hwndParent) return E_FAIL; if(!RegisterAndCreateWindow()) return E_FAIL; //Get and keep the IInputObjectSite pointer. if(SUCCEEDED(punkSite->QueryInterface(IID_IInputObjectSite, (LPVOID*)&m_pSite))) { return S_OK; } return E_FAIL; } return S_OK; }
  • 27. Do we really need extensions?
  • 28. Do we really need extensions?
  • 29. last word: don’t abuse extensions!
  • 30. Questions? @erwan elo@zenexity.com

Notes de l'éditeur

  1. * Javascript : dans les pages, dans les serveurs, mais pas seulement !\n
  2. * Etendre les fonctionalites du navigateur (Google Gears), fonctionalit&amp;#xE9;s de niche (Chrome to Phone)\n* Fonctionalit&amp;#xE9;s transversales sur toutes les pages\n* Exemple de Spellbound: correction orthographique dans Firefox\n
  3. * Mozilla 1.0 bloated =&gt; Firefox 1.0 minimaliste mais avec extensions\n* Forte influence de Mozilla - visionnaire a l&amp;#x2019;epoque du Javascript &amp;#x201C;etoiles qui suivent le curseur&amp;#x201D;\n* Extensions Chrome = Aaron Boodman de Greasemonkey\n
  4. * Firefox se base sur la meme plate-forme de d&amp;#xE9;veloppement que les extensions (Firefox lui-meme est &amp;#xE9;crit en Javascript !)\n* Google Chrome a ete developpe principalement par des gens qui viennent du monde Mozilla et ont tire profit de l&amp;#x2019;experience de Firefox\n
  5. * Chrome: points d&amp;#x2019;extension clairement definis par une API, seuls points d&amp;#x2019;int&amp;#xE9;gration\n* Empeche des developpeurs de faire n&amp;#x2019;importe quoi (stabilite, performances)\n
  6. 100% technos web - tr&amp;#xE8;s facile d&amp;#x2019;acc&amp;#xE8;s pour les d&amp;#xE9;veloppeurs web\n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. * Firefox: libert&amp;#xE9; totale !\n* API et points d&amp;#x2019;extension existent, mais pas d&amp;#x2019;obligation de se limiter a cela\n* Reecriture de pans entiers du navigateur, desactivation de fonctionalit&amp;#xE9;s\n* Problemes de compatibilite avec les nouvelles version de Firefox\n
  14. * Juste javascript, HTML, CSS pour les choses simples\n* XUL langage de balises XML pour d&amp;#xE9;crire les interfaces graphiques, n&amp;#xE9;cessaire pour &amp;#xE9;tendre l&amp;#x2019;interface graphique de Firefox\n* XPCOM pour aller encore plus loin et ajouter des composants natifs\n
  15. \n
  16. \n
  17. * Projet qui existe depuis pres de 3 ans mais reste a l&amp;#x2019;etat de prototype\n* Apporte a Firefox la simplicit&amp;#xE9; de developpement et les extensions installables sans redemarrage\n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. * API Javascript pour ajouter un lien vers un site, avec notifications\n* Positif : fait progresser l&amp;#x2019;interaction application web / desktop\n =&gt; point d&amp;#x2019;evolution majeur des navigateurs aujourd&amp;#x2019;hui\n* IE = gros progres au niveau du support des standards depuis IE8, IE9, IE10\n =&gt; ajoutez un support d&amp;#x2019;extensions en Javascript !\n
  26. \n
  27. * Les extensions sont commodes mais ont des inconv&amp;#xE9;niants: installation, mise a jour, depend du navigateur\n* Utilisez du pur web quand c&amp;#x2019;est possible, extensions seulement quand necessaire\n
  28. \n