Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
adding ext ex and fixing scrapee
- Loading branch information
lauren mccarthy
committed
Sep 30, 2013
1 parent
9aad1e3
commit 8894002
Showing
32 changed files
with
470 additions
and
24 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "One-click Kittens", | ||
"description": "This extension demonstrates a 'browser action' with kittens.", | ||
"version": "1.0", | ||
|
||
"browser_action": { | ||
"default_icon": "icon.png", | ||
"default_popup": "popup.html" | ||
}, | ||
"permissions": [ | ||
"https://secure.flickr.com/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Getting Started Extension's Popup</title> | ||
<style> | ||
body { | ||
min-width: 357px; | ||
overflow-x: hidden; | ||
} | ||
|
||
img { | ||
margin: 5px; | ||
border: 2px solid black; | ||
vertical-align: middle; | ||
width: 75px; | ||
height: 75px; | ||
} | ||
</style> | ||
|
||
<!-- | ||
- JavaScript and HTML must be in separate files: see our Content Security | ||
- Policy documentation[1] for details and explanation. | ||
- | ||
- [1]: http://developer.chrome.com/extensions/contentSecurityPolicy.html | ||
--> | ||
<script src="popup.js"></script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
/** | ||
* Global variable containing the query we'd like to pass to Flickr. In this | ||
* case, kittens! | ||
* | ||
* @type {string} | ||
*/ | ||
var QUERY = 'kittens'; | ||
|
||
var kittenGenerator = { | ||
/** | ||
* Flickr URL that will give us lots and lots of whatever we're looking for. | ||
* | ||
* See http://www.flickr.com/services/api/flickr.photos.search.html for | ||
* details about the construction of this URL. | ||
* | ||
* @type {string} | ||
* @private | ||
*/ | ||
searchOnFlickr_: 'https://secure.flickr.com/services/rest/?' + | ||
'method=flickr.photos.search&' + | ||
'api_key=90485e931f687a9b9c2a66bf58a3861a&' + | ||
'text=' + encodeURIComponent(QUERY) + '&' + | ||
'safe_search=1&' + | ||
'content_type=1&' + | ||
'sort=interestingness-desc&' + | ||
'per_page=20', | ||
|
||
/** | ||
* Sends an XHR GET request to grab photos of lots and lots of kittens. The | ||
* XHR's 'onload' event is hooks up to the 'showPhotos_' method. | ||
* | ||
* @public | ||
*/ | ||
requestKittens: function() { | ||
var req = new XMLHttpRequest(); | ||
req.open("GET", this.searchOnFlickr_, true); | ||
req.onload = this.showPhotos_.bind(this); | ||
req.send(null); | ||
}, | ||
|
||
/** | ||
* Handle the 'onload' event of our kitten XHR request, generated in | ||
* 'requestKittens', by generating 'img' elements, and stuffing them into | ||
* the document for display. | ||
* | ||
* @param {ProgressEvent} e The XHR ProgressEvent. | ||
* @private | ||
*/ | ||
showPhotos_: function (e) { | ||
var kittens = e.target.responseXML.querySelectorAll('photo'); | ||
for (var i = 0; i < kittens.length; i++) { | ||
var img = document.createElement('img'); | ||
img.src = this.constructKittenURL_(kittens[i]); | ||
img.setAttribute('alt', kittens[i].getAttribute('title')); | ||
document.body.appendChild(img); | ||
} | ||
}, | ||
|
||
/** | ||
* Given a photo, construct a URL using the method outlined at | ||
* http://www.flickr.com/services/api/misc.urlKittenl | ||
* | ||
* @param {DOMElement} A kitten. | ||
* @return {string} The kitten's URL. | ||
* @private | ||
*/ | ||
constructKittenURL_: function (photo) { | ||
return "http://farm" + photo.getAttribute("farm") + | ||
".static.flickr.com/" + photo.getAttribute("server") + | ||
"/" + photo.getAttribute("id") + | ||
"_" + photo.getAttribute("secret") + | ||
"_s.jpg"; | ||
} | ||
}; | ||
|
||
// Run our kitten generation script as soon as the document's DOM is ready. | ||
document.addEventListener('DOMContentLoaded', function () { | ||
kittenGenerator.requestKittens(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
1. Visit chrome://extensions in your browser (or open up the Chrome menu by clicking the icon to the far right of the Omnibox: The menu's icon is three horizontal bars.. and select Extensions under the Tools menu to get to the same place). | ||
|
||
2. Ensure that the Developer mode checkbox in the top right-hand corner is checked. | ||
|
||
3. Click Load unpacked extension… to pop up a file-selection dialog. | ||
|
||
4. Navigate to the directory in which your extension files live, and select it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
chrome.tabs.getSelected(null, function(tab) { | ||
chrome.tabs.sendMessage(tab.id, {greeting: "hello"}, function(response) { | ||
console.log(response.farewell); | ||
}); | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// add html overlay elts to page | ||
// PEND: change this to load html file | ||
var newdiv = document.createElement('div'); | ||
newdiv.setAttribute('id','sabotage'); | ||
var wordsdiv = document.createElement("div"); | ||
wordsdiv.setAttribute('id', 'words'); | ||
newdiv.appendChild(wordsdiv); | ||
document.body.appendChild(newdiv); | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "bg ext", | ||
"description": "example background extension", | ||
"version": "1.0", | ||
|
||
"permissions": ["tabs", "http://*/*", "https://*/*", "<all_urls>", "background"], | ||
"content_scripts": [ | ||
{ | ||
"matches": ["http://www.youtube.com/*"], | ||
"js": ["contentscript.js"], | ||
"css": ["style.css"] | ||
} | ||
], | ||
"background": { | ||
"persistent": false, | ||
"scripts": ["background.js"], | ||
"html": ["background.html"] | ||
}, | ||
"web_accessible_resources": [], | ||
"browser_action": { | ||
"default_title": "hi", | ||
"default_icon": "icon.png", | ||
"default_popup": "popup.html" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Getting Started Extension's Popup</title> | ||
<style> | ||
body { | ||
min-width: 357px; | ||
overflow-x: hidden; | ||
} | ||
|
||
img { | ||
margin: 5px; | ||
border: 2px solid black; | ||
vertical-align: middle; | ||
width: 75px; | ||
height: 75px; | ||
} | ||
</style> | ||
|
||
<!-- | ||
- JavaScript and HTML must be in separate files: see our Content Security | ||
- Policy documentation[1] for details and explanation. | ||
- | ||
- [1]: http://developer.chrome.com/extensions/contentSecurityPolicy.html | ||
--> | ||
<script src="popup.js"></script> | ||
</head> | ||
<body> | ||
|
||
hi hi | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
/** | ||
* Global variable containing the query we'd like to pass to Flickr. In this | ||
* case, kittens! | ||
* | ||
* @type {string} | ||
*/ | ||
var QUERY = 'kittens'; | ||
|
||
var kittenGenerator = { | ||
/** | ||
* Flickr URL that will give us lots and lots of whatever we're looking for. | ||
* | ||
* See http://www.flickr.com/services/api/flickr.photos.search.html for | ||
* details about the construction of this URL. | ||
* | ||
* @type {string} | ||
* @private | ||
*/ | ||
searchOnFlickr_: 'https://secure.flickr.com/services/rest/?' + | ||
'method=flickr.photos.search&' + | ||
'api_key=90485e931f687a9b9c2a66bf58a3861a&' + | ||
'text=' + encodeURIComponent(QUERY) + '&' + | ||
'safe_search=1&' + | ||
'content_type=1&' + | ||
'sort=interestingness-desc&' + | ||
'per_page=20', | ||
|
||
/** | ||
* Sends an XHR GET request to grab photos of lots and lots of kittens. The | ||
* XHR's 'onload' event is hooks up to the 'showPhotos_' method. | ||
* | ||
* @public | ||
*/ | ||
requestKittens: function() { | ||
var req = new XMLHttpRequest(); | ||
req.open("GET", this.searchOnFlickr_, true); | ||
req.onload = this.showPhotos_.bind(this); | ||
req.send(null); | ||
}, | ||
|
||
/** | ||
* Handle the 'onload' event of our kitten XHR request, generated in | ||
* 'requestKittens', by generating 'img' elements, and stuffing them into | ||
* the document for display. | ||
* | ||
* @param {ProgressEvent} e The XHR ProgressEvent. | ||
* @private | ||
*/ | ||
showPhotos_: function (e) { | ||
var kittens = e.target.responseXML.querySelectorAll('photo'); | ||
for (var i = 0; i < kittens.length; i++) { | ||
var img = document.createElement('img'); | ||
img.src = this.constructKittenURL_(kittens[i]); | ||
img.setAttribute('alt', kittens[i].getAttribute('title')); | ||
document.body.appendChild(img); | ||
} | ||
}, | ||
|
||
/** | ||
* Given a photo, construct a URL using the method outlined at | ||
* http://www.flickr.com/services/api/misc.urlKittenl | ||
* | ||
* @param {DOMElement} A kitten. | ||
* @return {string} The kitten's URL. | ||
* @private | ||
*/ | ||
constructKittenURL_: function (photo) { | ||
return "http://farm" + photo.getAttribute("farm") + | ||
".static.flickr.com/" + photo.getAttribute("server") + | ||
"/" + photo.getAttribute("id") + | ||
"_" + photo.getAttribute("secret") + | ||
"_s.jpg"; | ||
} | ||
}; | ||
|
||
// Run our kitten generation script as soon as the document's DOM is ready. | ||
document.addEventListener('DOMContentLoaded', function () { | ||
kittenGenerator.requestKittens(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#sabotage { | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
top:0px; | ||
left:0px; | ||
background-color: gray; | ||
} | ||
|
||
#words { | ||
font-size: 34pt; | ||
font-family: helvetica; | ||
color: white; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// 1. Go to developers.facebook.com/apps and click "Create New App". | ||
// 2. | ||
|
||
import facebook4j.Facebook; | ||
import facebook4j.FacebookFactory; | ||
|
||
import processing.net.*; | ||
|
||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpResponse; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.impl.client.DefaultHttpClient; | ||
|
||
|
||
void setup() { | ||
|
||
String client_id = "167631416773261"; | ||
String client_secret = "b9d3b8c809daeaaa07f5fcdc13de4010"; | ||
String redirect_uri = "http://lauren-mccarthy.com/"; | ||
|
||
// init empty | ||
String access_token = ""; | ||
|
||
try | ||
{ | ||
String url = "https://graph.facebook.com/oauth/access_token?client_id="+client_id+"&client_secret="+client_secret+"&grant_type=client_credentials,offline_access&redirect_uri="+redirect_uri; | ||
DefaultHttpClient httpClient = new DefaultHttpClient(); | ||
HttpPost httpPost = new HttpPost( url ); | ||
|
||
println( "executing request: " + httpPost.getRequestLine() ); | ||
|
||
HttpResponse response = httpClient.execute( httpPost ); | ||
HttpEntity entity = response.getEntity(); | ||
|
||
println("----------------------------------------"); | ||
println( response.getStatusLine() ); | ||
println("----------------------------------------"); | ||
|
||
String content = EntityUtils.toString(entity); | ||
String[] ind = content.split("access_token="); | ||
if (ind.length > 1) { | ||
access_token = ind[1]; | ||
println("got access token: "+access_token); | ||
} | ||
EntityUtils.consume(entity); | ||
httpClient.getConnectionManager().shutdown(); | ||
|
||
/* | ||
// Client client = new Client(this, "127.0.0.1", 5204); | ||
Client c = new Client(this, "https://graph.facebook.com", 80); // Connect to server on port 80 | ||
c.write("GET /oauth/access_token?client_id=2710cdbc4e2fb5dd0bb9f2c9c1d5343a&grant_type=post HTTP/1.1\n"); // Use the HTTP "GET" command to ask for a Web page | ||
if (c.available() > 0) { // If there's incoming data from the client... | ||
String data = c.readString(); // ...then grab it and print it | ||
println(data); | ||
} | ||
*/ | ||
|
||
println("using token "+access_token); | ||
|
||
Facebook facebook = new FacebookFactory().getInstance(); | ||
facebook.setOAuthAppId(client_id, client_secret); | ||
facebook.setOAuthPermissions("client_credentials"); | ||
facebook.setOAuthAccessToken(new AccessToken(access_token, null)); | ||
|
||
facebook.postStatusMessage("Hello from P5."); | ||
} | ||
catch (Exception ex) { | ||
println(ex); | ||
} | ||
} | ||
|
||
void draw() { | ||
} | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.