Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ブラウザ拡張のクロスブラウザ対応についてどう向き合っているか #builderscon

pastak
August 04, 2017

ブラウザ拡張のクロスブラウザ対応についてどう向き合っているか #builderscon

pastak

August 04, 2017
Tweet

More Decks by pastak

Other Decks in Technology

Transcript

  1. We are hiring!! • Gyazo ݄ؒ1000ສUU 6600ສPV / month •

    Scrapbox • JavaScript (React) / Ruby on Rails / Golang • Mac / Windows / iOS / Android App • Kyoto or Everywhere • Tokyo, Yokohama, Hokkaido • USA, Australia https://www.wantedly.com/companies/nota
  2. and

  3. ࿩͞ͳ͍͜ͱ • Safari Extensionʹؔ͢Δ͜ͱ • ϒϥ΢β֦ுҠ২ʹؔ͢Δ۩ମత͔ͭࡉ΍͔ͳςΫχοΫ • ະ࣮૷ͷAPI΍࣮૷ʹόάͷ͋ΔAPIͱͷ޲͖߹͍ํ͸ҎԼͷࢿྉ ΛͲ͏ͧ •

    BrowserExtension࢛ํࢁ࿩ https://speakerdeck.com/pastak/ browserextensionsi-fang-shan-hua-number-yapc8oji • Chrome ExtensionΛ FirefoxʹΠϯετʔϧ͢Δ - WebExtensionҠ২෺ޠ https://speakerdeck.com/pastak/ chrome-extensionwo-firefoxniinsutorusuru-webextensionyi-zhi- wu-yu
  4. Firefox v57΁ͷϩʔυϚοϓ • “Firefox will only run WebExtensions.” • ͜Ε·ͰͷAPIΛར༻͍ͯ͠ΔΞυΦϯΛ৽ن

    ʹAMOʹొ࿥͢Δ͜ͱ͸ෆՄೳʹͳ͍ͬͯΔ • ެ։ࡁΈͷ΋ͷΛΞοϓσʔτ͢Δ͜ͱ͸ग़ དྷΔ͕ɺAPIͷαϙʔτ͕ԕ͘ͳ͍ະདྷʹ੾ ΒΕΔՄೳੑ͕͋ΔͷͰɺૣΊͷߋ৽Λ The Road to Firefox 57 – Compatibility Milestones | Mozilla Add-ons Blog https://blog.mozilla.org/addons/2017/02/16/the-road-to-firefox-57-compatibility-milestones/
  5. W3C Browser Extension Community Group • ϒϥ΢β֦ுͷඪ४ԽΛ໨ࢦ͍ͯ͠Δ • ݱࡏ Draft

    Community Group Report Λެ։ ͍ͯ͠Δ • https://browserext.github.io/browserext/ • APIҎ֎ʹ΋packaging΍testing΋ؚΉ
  6. ϒϥ΢β֦ுAPIυΩϡϝϯτ • Chrome • https://developer.chrome.com/extensions • Firefox • https://developer.mozilla.org/en-US/Add-ons/ WebExtensions

    • https://wiki.mozilla.org/WebExtensions • Edge • https://docs.microsoft.com/en-us/microsoft-edge/extensions
  7. Porting Chrome Extension • mozilla/web-ext • WebExtensionͷͨΊͷπʔϧ • sign, linter,

    build, debug • Microsoft Edge Extension Toolkit • manifest.jsonͳͲͷvalidateΛͯ͘͠ΕΔ
  8. WebExtension Manifest Formatter • manifest.jsonΛ৯ΘͤΔͱྑ͍ײ͡ʹม׵͠ ͯ͘ΕΔ܅ • Chrome / Firefox

    / Edge ͦΕͧΕΛλʔ ήοτʹࢦఆ͢ΔͱͦΕΒͷ؀ڥͰಈ࡞͠ ͳ͍ΩʔΛ࡟আͨ͠ΓɺඞཁͳΩʔؚ͕· Ε͍ͯΔ͔ͷνΣοΫΛͯ͘͠ΕΔ
  9. wemf usage example • Firefox͸applicationΩʔ͕ඞཁ • Firefox v48͔Βෆཁʹ • ͍ͭͷؒʹ͔EdgeͷυΩϡϝϯτ͔Β΋ফ͑ͯͨ…

    • Edge͸authorΩʔ͕ඞཁ(͜Ε͕ͳ͍ͱΠϯετʔϧͰίέ Δ) • Chrome͸sidebarΛະαϙʔτͳͲ
  10. APIΛఏڙ͢ΔObject໊ • Chrome • chrome • Edge • browser •

    Firefox • chrome / browser • Standard͸ browser ʹͳΔ͸ͣ
  11. APIΛఏڙ͢ΔObject໊ • Chrome • chrome • Edge • browser •

    Firefox • chrome / browser ← Firefox͚ͩ͸PromiseΛฦ͢ (ଞ͸PromiseΛฦ͞ͳ͍)
  12. polyfillͱ૊Έ߹ΘͤΔ • Chrome / Firefox / EdgeͷશͯͰಉ͡Α͏ʹAPIΛݺ ͼग़ͤΔΑ͏ʹͳΔ • browser.tabs.get({}).then()

    Έ͍ͨͳײ͡Ͱॻ͍͍ͯ͘ • ্ه3ϒϥ΢β͸async-awaitΛαϙʔτ͍ͯ͠Δͷ Ͱɺ • await browser.tabs.get({}) ͱ͔΋ॻ͚Δ