Building a chrome extension with meteor

  • 1,824 views
Uploaded on

Slides for a talk I did at Meteor Devshop 7 about building a chrome extension with Meteor.

Slides for a talk I did at Meteor Devshop 7 about building a chrome extension with Meteor.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,824
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
11
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • then have some time for questions
  • Why build a chrome extension?Add functionality to the browser, or to add functionality to specific sites or all sites.Here are some examples…
  • LastPass. Stores your login credentials in the cloud, then auto-populates the input values
  • PageReload. Auto-reloads the page based on a user configured timer.This is for non-meteor pages of course.
  • Code Bounty. Extended GitHub to allow you to post bounties on issues
  • - Extensions are all built with html / javascript / cssAccess to all the javascript APIs + chrome functionality through javascriptapis under the chrome namespace
  • Quickly run through some of these…Some api’s that get into shady use case land, like the ability to keep’s the users computer awake or to intercept web traffic.You have a lot of control over the browser, so use it wisely.
  • The main chrome ui elements you would probably work with would be the- popup when a user clicks on your extension icon- the context menu when a user right clicks- you can override the bookmark manager, history, or new tab pages, or add to the add to developer tools if you want to get really advanced
  • Let’s break apart one of the extensionsInspect extensions with chrome developer toolsto see how they are builtto debug themPageReload is a form with a bunch of radio buttonsClick item or submit form it triggers setReloader()
  • This is the code for the popup menu.It walks through the radio buttons. Chooses the value in milliseconds.Then here it calls the chrome.tabs.update chrome extension api, setting the url which reloads the page
  • There are two ways (that I know of) that you can connect the chrome extension to meteor.https://github.com/eddflrs/meteor-ddp a client side DDP implementation in javascriptInjecting a meteor page as an iframeLet’s go over the first one, using meteor-ddp
  • Icons48px used on extensions management page (chrome://extensions)19px default_icon is used as the extension browser action iconMust choose between:browser action: permanently visiblepage action: conditionally show on certain pagesBackground scripts run in the backgroundCan also have content scripts which are injected and run as part of the page
  • Run / demo meteor parties https://github.com/jperl/meteor-chrome-extension
  • meteor-ddp supports oauth can use access methods and subscriptions which require authorizationWorks for content scripts, background script complicated because of the need to postMessages back and forth from the content script to the background script - Didn’t have time to implement that, but happy to help anyone who needs it
  • For the extension we use both ddp and an iframe to integrate meteorDdp is used to fetch all of the data the extension uses (total bounty amount, if the current user can reward this bounty, if this issue can have a bounty placed on it)
  • Iframe is used for our reward screen ui. Built with out of the box meteor templates

Transcript

  • 1. Building a Chrome Extension with Meteor Jon Perl jon at codebounty.co @jon_perl
  • 2. Why build an extension + examples What are the parts Build one with Meteor Complex use cases (w Code Bounty) Today
  • 3. Why?
  • 4. How? HTML / CSS Javascript + chrome APIs Chrome UI elements
  • 5. chrome.* APIs • bookmarks • events • history • power • webRequest + 48 more
  • 6. UI Elements Browser Action Page Action
  • 7. UI Elements Popup Context Menu
  • 8. Get reload value from menu in milliseconds Trigger chrome.tabs.update({url:..}) to reload page
  • 9. But what about Meteor?
  • 10. bloggeek.me 1: meteor-ddp Meteor 2: iframe
  • 11. Meteor Parties 10 0
  • 12. Manifest
  • 13. Backgroun d
  • 14. OAuth
  • 15. DDP vs IFrame
  • 16. DDP vs IFrame
  • 17. And More Testing w Selenium and CucumberJS RequireJS for organizing code Grunt for filling in config values
  • 18. Why build an extension + examples What are the parts Build one with Meteor Complex use cases (w Code Bounty) Recap
  • 19. github.com/jperl/meteor-chrome-extension developer.chrome.com/extensions/api_index.ht ml github.com/eddflrs/meteor-ddp youtube.com/watch?v=pT-b2SpFIWo github.com/codebounty/codebounty @jon_perl Resources
  • 20. Questions?