Skip to content

Commit

Permalink
Updated manifest to v2 and more
Browse files Browse the repository at this point in the history
  • Loading branch information
ibagrak committed Sep 23, 2012
1 parent a8d6857 commit 3992fa3
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 248 deletions.
119 changes: 0 additions & 119 deletions chrome_extension/background.html

This file was deleted.

75 changes: 75 additions & 0 deletions chrome_extension/background.js
@@ -0,0 +1,75 @@

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18747503-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

var version = getVersion();

function getVersion() {
var xhr = new XMLHttpRequest();
xhr.open('GET', chrome.extension.getURL('manifest.json'), false);
xhr.send(null);
var manifest = JSON.parse(xhr.responseText);
return manifest.version;
}

function peel_all(request, callback) {
var xhr = new XMLHttpRequest();

xhr.onreadystatechange = function(data) {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var data = JSON.parse(xhr.responseText);
var error_code = data[0];
var ellipses = "";

/* got a redirect -> set field value to new URL */
if (error_code == 301 || error_code == 302) {
if (data[1].length > 50) {
ellipses = "...";
}

callback("<a href='" + data[1] + "'>" + data[1].substr(0,50) + ellipses + "</a>");
/* got a direct link (e.g. 200) or error code (e.g. 404) doesn't matter)
* -> disable "Peel" button
**/
} else {
if (request.url.length > 50) {
ellipses = "...";
}
/* make link in tooltip clickable */
callback("<a href='" + request.url + "'>" + request.url.substr(0,50) + ellipses + "</a>");
}
} else {
callback("Oops! Something is wrong..");
}
}
}

// Note that any URL fetched here must be matched by a permission in
// the manifest.json file!
var url = 'http://linkpeelr.appspot.com/api?action=' + request.action + '&url=' + request.url + '&where=' + request.where + '&version=' + version;
xhr.open('GET', url, true);
xhr.send();
};

/**
* Handles data sent via chrome.extension.sendRequest().
* @param request Object Data sent in the request.
* @param sender Object Origin of the request.
* @param callback Function The method to call when the request completes.
*/
function onRequest(request, sender, callback) {
if (request.action == 'peel_all') {
peel_all(request, callback);
}
};

// Wire up the listener.
chrome.extension.onRequest.addListener(onRequest);
11 changes: 2 additions & 9 deletions chrome_extension/hover_script.js
Expand Up @@ -209,11 +209,7 @@ $(document).ready(function() {
var control = $(this);
var href = control.attr('href');

if (typeof(href) == "undefined") {
return;
}

if (href == '') {
if (typeof(href) == "undefined" || href === '') {
return;
}

Expand Down Expand Up @@ -298,7 +294,4 @@ $(document).ready(function() {
deactive_tiptip();
}
});
});



});
22 changes: 15 additions & 7 deletions chrome_extension/manifest.json
@@ -1,16 +1,27 @@
{
"name": "LinkPeelr",
"version": "1.7.7",
"description": "Know Where Link Is Going Before You Click",
"version": "2.0.0",
"manifest_version": 2,

"description": "Know Where Link Is Going Before You Click",
"icons": {
"16": "linkpeelr16.png",
"48": "linkpeelr48.png",
"128": "linkpeelr128.png"
},

"background_page" : "background.html",
"background" : {
"scripts" : ["background.js"]
},

"content_security_policy" : "script-src 'self' https://ssl.google-analytics.com/; object-src 'self'",

"web_accessible_resources": [
"manifest.json",
"ajax-loader.gif",
"jquery.min.js"
],

"content_scripts": [
{
"matches": ["http://*/*"],
Expand All @@ -21,9 +32,6 @@

"permissions": [
"cookies",
"http://linkpeelr.appspot.com/*",
"http://platform.twitter.com/*",
"https://ssl.google-analytics.com/*",
"http://ajax.googleapis.com/ajax/libs/jquery/*"
"http://linkpeelr.appspot.com/*"
]
}
113 changes: 0 additions & 113 deletions chrome_extension/popup.html

This file was deleted.

0 comments on commit 3992fa3

Please sign in to comment.