Permalink
Browse files

Working Chrome extension. Cleaned up Safari extension.

  • Loading branch information...
1 parent 1a78252 commit ec4d39938622da5bcbb9a951b14e9bf1f97b6625 @jeffrock jeffrock committed Jan 16, 2012
Showing with 26 additions and 39 deletions.
  1. +0 −7 View in Carousel.safariextension/end.js
  2. +7 −14 View in Carousel/end.js
  3. +6 −7 View in Carousel/global.html
  4. +13 −11 View in Carousel/manifest.json
@@ -32,11 +32,4 @@ safari.self.addEventListener("message", getMediaID, false);
if (window.top === window) {
// Tell global.html to start fetching Instagram data
safari.self.tab.dispatchMessage("startInstagramFetch", document.URL);
-}
-
-function wrapPhotoWithCarouselURL(mediaID) {
- if (window.top === window) {
- var currentPhotoHTML = $('body').html();
- alert(currentPhotoHTML);
- }
}
View
@@ -3,9 +3,9 @@ $.fn.outerHTML = function() {
};
function getMediaID(theMessageEvent) {
- if (theMessageEvent.name === "theInstagramData") {
- var mediaID = theMessageEvent.message.media_id;
- var authorID = theMessageEvent.message.author_id
+ if (theMessageEvent.request === "theInstagramData") {
+ var mediaID = theMessageEvent.data.media_id;
+ var authorID = theMessageEvent.data.author_id
// Link the photo with the URL scheme
var currentPhotoHTML = $('img.photo:first').outerHTML();
@@ -18,7 +18,6 @@ function getMediaID(theMessageEvent) {
var currentAuthorNameHTML = usernameElement.outerHTML();
var newAuthorNameHTML = '<a href=\"x-mobelux-carousel://openuser?userID=' + authorID + '\" title=\"View ' + usernameText + ' in Carousel\">' + currentAuthorNameHTML + '</a>';
usernameElement.replaceWith(newAuthorNameHTML);
- //alert(currentAuthorNameHTML);
// Link the author avatar with the URL scheme
var currentAuthorHTML = $('img.profile-picture:first').outerHTML();
@@ -27,18 +26,12 @@ function getMediaID(theMessageEvent) {
}
}
-safari.self.addEventListener("message", getMediaID, false);
+chrome.extension.onRequest.addListener(
+ function(request) {
+ getMediaID(request);
+ });
if (window.top === window) {
// Tell global.html to start fetching Instagram data
- //safari.self.tab.dispatchMessage("startInstagramFetch", document.URL);
- alert('in');
chrome.extension.sendRequest({request: "startInstagramFetch", documentURL: document.URL});
-}
-
-function wrapPhotoWithCarouselURL(mediaID) {
- if (window.top === window) {
- var currentPhotoHTML = $('body').html();
- alert(currentPhotoHTML);
- }
}
@@ -6,7 +6,6 @@
<script>
function respondToMessage(theMessageEvent) {
- alert('in');
if (theMessageEvent.request === "startInstagramFetch") {
var instagramURL = theMessageEvent.documentURL;
getMediaAndUserDataFromInstagram(instagramURL);
@@ -18,16 +17,16 @@
$.getJSON(apiURL,
function (data) {
// Send media id to injected script
- safari.application.activeBrowserWindow.activeTab.page.dispatchMessage("theInstagramData", data);
+ chrome.tabs.getSelected(null, function(tab) {
+ chrome.tabs.sendRequest(tab.id, {request: "theInstagramData", data: data});
+ });
});
}
-//safari.application.addEventListener("message", respondToMessage, false);
-
chrome.extension.onRequest.addListener(
- function(request) {
- respondToMessage(request);
- });
+ function(request) {
+ respondToMessage(request);
+ });
</script>
</head>
@@ -1,13 +1,15 @@
{
- "name": "View in Carousel",
- "version": "1.0",
- "description": "View photos and users on Instagram webpages in Carousel.",
- "background_page": "global.html",
- "content_scripts": [
- { "matches": ["http://instagr.am/*"], "js": ["end.js"] }
- ],
- "permissions": [
- "tabs",
- "http://instagr.am/"
- ]
+ "name": "View in Carousel",
+ "version": "1.0",
+ "description": "View photos and users on Instagram webpages in Carousel.",
+ "permissions": [
+ "tabs"
+ ],
+ "background_page": "global.html",
+ "content_scripts": [
+ {
+ "matches": ["http://instagr.am/*"],
+ "js": ["jquery-1.7.1.min.js", "end.js"]
+ }
+ ]
}

0 comments on commit ec4d399

Please sign in to comment.