Lecture 9 Chrome Extensions

Similar documents
Example. Represent this as XML

jquery Tutorial for Beginners: Nothing But the Goods

12Planet Chat end-user manual

MASTERTAG DEVELOPER GUIDE

Recommended Browser Setting for MySBU Portal

Overview: Logging into the portal:

Traitware Authentication Service Integration Document

XML Processing and Web Services. Chapter 17

Step 1: How to Create Links / Hyperlinks

WebIOPi. Installation Walk-through Macros

How to start with 3DHOP

Jive Connects for Openfire

WP Popup Magic User Guide

Performance Testing for Ajax Applications

Team Members: Christopher Copper Philip Eittreim Jeremiah Jekich Andrew Reisdorph. Client: Brian Krzys

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

The information in this document belongs to Digibilly. It may not be used, reproduced or disclosed without written approval.

Treemap Visualisations

Shipbeat Magento Module. Installation and user guide

Visualizing MongoDB Objects in Concept and Practice

WP Popup Magic User Guide

Movie Instructions: Downloading, Saving, & Watching

Up and Running with LabVIEW Web Services

Web Application Development

"Breakthrough New Software Automates The Optimization Process To Get You A #1 Ranking - All With The Single Click Of A Button!"

Reading an sent with Voltage Secur . Using the Voltage Secur Zero Download Messenger (ZDM)

Reference Guide for WebCDM Application 2013 CEICData. All rights reserved.

Introduction to Open Atrium s workflow

Client-side Development using HTML, Javascript and CSS

Getting Started Guide

Debugging JavaScript and CSS Using Firebug. Harman Goei CSCI 571 1/27/13

Homework 3: Component & Interface Design

Operational Decision Manager Worklight Integration

Step One Check for Internet Connection

Chromebook Reference Document

4/25/2016 C. M. Boyd, Practical Data Visualization with JavaScript Talk Handout

FormAPI, AJAX and Node.js

Simple Document Management Using VFP, Part 1 Russell Campbell russcampbell@interthink.com

CDyWeb Content Management System (CCMS) V3.3. User Manual

GeoInt 2015 Watson Workshop

User Guide to the Content Analysis Tool

Configuring browser settings (Internet Explorer and Google Chrome) for Bug Club via a Group Policy

This Quick Reference Sheet covers the most common technical issues that may be encountered.

TATJA: A Test Automation Tool for Java Applets

This guide will walk you through the process of disabling pop-up blockers found in three popular web browsers.

Alerts. Some Alerts give you unique options for customizing the messages you receive. Calendar events, for instance, allow you to set how far in

Installing Java 5.0 and Eclipse on Mac OS X

Chapter 14: Links. Types of Links. 1 Chapter 14: Links

1. Right click using your mouse on the desktop and select New Shortcut.

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

Portal Recipient Guide

Webucator Free Online Technology Training Courses

Advantage of Jquery: T his file is downloaded from

Building Web Applications

Barcodes in the Classroom

Jenesis Software - Podcast Episode 3

IBM Script Portlet for WebSphere Portal Release 1.1

Eucalyptus User Console Guide

English. Asema.com Portlets Programmers' Manual

BROWSER-BASED DEVELOPMENT & NETWORK MONITORING UTILITIES

Brief Description of project: This project will be an interactive Javascript. 1. What do you want to accomplish by doing this project?

Building Responsive Websites with the Bootstrap 3 Framework

Unity web- player issues in browsers & in client system

4 Understanding. Web Applications IN THIS CHAPTER. 4.1 Understand Web page development. 4.2 Understand Microsoft ASP.NET Web application development

ICON UK 2015 node.js for Domino developers. Presenter: Matt White Company: LDC Via

Marketing Features

How to Add Social Media Icons to Your Website

White Paper On. Single Page Application. Presented by: Yatin Patel

MindGenius SharePoint Integration

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

1. What are popups? What if I have a problem with viewing popups? 1

Project 2: Web Security Pitfalls

AUTOMATED CONFERENCE CD-ROM BUILDER AN OPEN SOURCE APPROACH Stefan Karastanev

HTML5. Turn this page to see Quick Guide of CTTC

WA2262 Applied Data Science and Big Data Analytics Boot Camp for Business Analysts. Classroom Setup Guide. Web Age Solutions Inc.

Technical Guide for Remote access

Installing and Sending with DocuSign for NetSuite v2.2

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

Enable Your Automated Web App Testing by WebDriver. Yugang Fan Intel

JavaScript: Client-Side Scripting. Chapter 6

Google Apps for Education: The Basics

An Newsletter Using ASP Smart Mailer and Advanced HTML Editor

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

Google Drive Create, Share and Edit Documents Online

Web Development Recipes

Introduction to Python

Lawson Portal User s Manual

TDAQ Analytics Dashboard

Marketing Features

Visualizing Software Projects in JavaScript

Web App Development Session 1 - Getting Started. Presented by Charles Armour and Ryan Knee for Coder Dojo Pensacola

Populating Your Domino Directory (Or ANY Domino Database) With Tivoli Directory Integrator. Marie Scott Thomas Duffbert Duff

Transcription:

Lecture 9 Chrome Extensions 1 / 22

Agenda 1. Chrome Extensions 1. Manifest files 2. Content Scripts 3. Background Pages 4. Page Actions 5. Browser Actions 2 / 22

Chrome Extensions 3 / 22

What are browser extensions? Most of the code we've looked at so far runs on a page in the browser But a browser extension augments the functionality of the browser itself Switching tabs, managing downloads, creating quick-access buttons, etc. Browser extensions could be written in any language......but it's much easier to write them in JavaScript, since they'll need to inject JS onto pages anyway 4 / 22

The Manifest File 5 / 22

Why do we need a manifest file, anyway? The manifest file tells the browser what permissions your extension will need, and where to look for its scripts Basically a road map for your application In Chrome, the manifest file is called manifest.json. 6 / 22

Quick Refresher: JSON JSON is JavaScript Object Notation. A JSON file basically consists of a single JS object, with three exceptions: 1. Functions are not allowed. 2. All strings must use double quotes. 3. Property names must be strings. 7 / 22

Quick Example JSON: { "foo": 1, "bar": ["a", "b", "c"] } Not JSON: { foo: 1, bar: ['a', 'b', 'c'] } 8 / 22

Manifest.json An example manifest.json file. 9 / 22

Content Scripts 10 / 22

Content Scripts Content scripts are JavaScript files that are injected into HTML pages in the browser. They can manipulate the DOM and do everything that you'd expect to be able to do in the browser environment. In fact, content scripts can actually do MORE than a regular browser script. They can hook into all of the Chrome APIs (although indirectly) by passing messages to the extension itself. Normally, that's impossible for a webpage to do! 11 / 22

Loading Content Scripts Loading content scripts is easy. All that's required is a few lines in manifest.json : "content_scripts": [ { "matches": ["http://www.google.com/*"], "css": ["mystyles.css"], "js": ["jquery.js", "myscript.js"] } ] matches is an array of strings that tells Chrome which pages to inject your script on. css and js are the actual scripts to inject. They are injected in order, which lets you depend on libraries like jquery. 12 / 22

Content Scripts We now have enough knowledge to start working on a simple extension. You may have heard of the popular extension "Cloud2Butt", which replaces the word "cloud" with "butt" for hilarious results. We'll be building a similar extension that replaces the word "Internet" with "series of tubes." 13 / 22

Target Page This is a test. You're viewing this page on the Internet. The Internet, as you know, is a series of tubes. I'm very excited about the "Internet of Things." 14 / 22

Good stuff. But let's say we want to add a button that displays a popup that lets you add your OWN replacements. That way you can make your browser behave like this XKCD comic! To get there, let's move on to the next topic: background pages. 15 / 22

Background Pages Background pages are also known as event pages. They wait in the background for events, then run event handlers when the events are triggered. Background pages will also run when the extension is first installed (this is how they register for events in the first place). 16 / 22

Adding a Background Page, pt. 1 First, we add the appropriate lines to manifest.json : "background": { "scripts": ["background.js"], "persistent": false }, 17 / 22

Adding a Background Page, pt. 2 Then, we add whatever we want to background.js. In this case we want to add a page action, which is Chrome's fancy name for the little button that we'll want users to press. Here's how we'd do that (unfortunately, Chrome's API is too verbose to fit on these slides!). 18 / 22

We should be able to try this out. I've set up a background script in the page-action-start branch of the example repository. Let's see what happens when I load the extension. It should print a console message, which will only be viewable if we "inspect views" from the chrome://extensions page. 19 / 22

The Page Action Finally, let's set up the page action. As you've probably guessed, this will first require us to add something to manifest.json: "page_action": { "default_icon": "popup/icon.png", "default_title": "Series of Tubes", "default_popup": "popup/popup.html" }, 20 / 22

Actually writing the page action is pretty straightforward. Let's do it now! We'll use the chrome.storage API as well, so that the user's preferences are saved on every device where they log in to Chrome. As you'll see, it takes surprisingly little code to achieve that functionality. 21 / 22

Final Note: Browser Actions The very-observant might notice that I had one more thing to cover today: browser actions. Luckily, a browser action is nothing but a page action that always shows up! It's also known as a browser button, and you can see one if you install Google Hangouts, for example. So since you know what a page action looks like, you'll easily be able to translate it to a browser action if you ever need to. 22 / 22