diff --git a/.gitignore b/.gitignore index 354d43b..74e1b95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .idea /thegreenweb.crx /thegreenweb.pem +thegreenweb.zip +thegreenweb/web-ext-artifacts/* diff --git a/thegreenweb/background.js b/thegreenweb/background.js index 898fb6d..82a539d 100644 --- a/thegreenweb/background.js +++ b/thegreenweb/background.js @@ -14,6 +14,7 @@ chrome.runtime.onMessage.addListener( if (request.locs){ doSearchRequest(request.locs,sender.tab); } + return true; } ); @@ -153,7 +154,7 @@ function doRequest(url,tabId) */ function showIcon(resp,tabId) { - var icon = getImagePath(getIcon(resp)); + var icon = getImagePath(getIcon(resp), true); var title = getTitle(resp); chrome.pageAction.setIcon({'tabId' : tabId, 'path' : icon}); chrome.pageAction.setTitle({'tabId' : tabId, 'title' : title}); diff --git a/thegreenweb/green-page-links.js b/thegreenweb/green-page-links.js index 840cdcc..3b61a5b 100644 --- a/thegreenweb/green-page-links.js +++ b/thegreenweb/green-page-links.js @@ -45,6 +45,7 @@ chrome.runtime.onMessage.addListener( } }); } + return true; }); /** diff --git a/thegreenweb/manifest.json b/thegreenweb/manifest.json index f9ce099..786cee5 100644 --- a/thegreenweb/manifest.json +++ b/thegreenweb/manifest.json @@ -3,7 +3,7 @@ "update_url":"http://clients2.google.com/service/update2/crx", "name": "The Green Web", "short_name": "The Green Web", - "version": "2.1.3", + "version": "2.1.4", "description": "Automatically check the sustainability of a website with The Green Web add-on.", "background": { "scripts": ["background.js","thegreenweb-utils.js","tracker.js"], diff --git a/thegreenweb/search-bing.js b/thegreenweb/search-bing.js index 3c87649..dbfa631 100644 --- a/thegreenweb/search-bing.js +++ b/thegreenweb/search-bing.js @@ -36,6 +36,7 @@ chrome.runtime.onMessage.addListener( } }); } + return true; }); /** diff --git a/thegreenweb/search-ecosia.js b/thegreenweb/search-ecosia.js index 17bad68..25e8fea 100644 --- a/thegreenweb/search-ecosia.js +++ b/thegreenweb/search-ecosia.js @@ -36,6 +36,7 @@ chrome.runtime.onMessage.addListener( } }); } + return true; }); /** diff --git a/thegreenweb/search-google.js b/thegreenweb/search-google.js index 2de01f2..372ad31 100644 --- a/thegreenweb/search-google.js +++ b/thegreenweb/search-google.js @@ -17,10 +17,11 @@ chrome.runtime.onMessage.addListener( $(links).each(function () { var loc = getUrl($(this).parent().attr('href')); if (data[loc]) { - $(this).html(getResultNode(data[loc]).append(' ')); + $(this).html(getResultNode(data[loc], 'google').append(' ')); } }); } + return true; }); /** diff --git a/thegreenweb/search-yahoo.js b/thegreenweb/search-yahoo.js index f5b64b7..dfffdfd 100644 --- a/thegreenweb/search-yahoo.js +++ b/thegreenweb/search-yahoo.js @@ -36,6 +36,7 @@ chrome.runtime.onMessage.addListener( } }); } + return true; }); /** diff --git a/thegreenweb/thegreenweb-utils.js b/thegreenweb/thegreenweb-utils.js index 256d21b..96d39fc 100644 --- a/thegreenweb/thegreenweb-utils.js +++ b/thegreenweb/thegreenweb-utils.js @@ -127,11 +127,16 @@ function getFooterElement() * @param color * @returns {void | * | jQuery} */ -function getLinkNode(color) +function getLinkNode(color, type) { + var style = 'width:16px; height:16px;border:none;'; + if(type === 'google') { + style = 'width:16px; height:16px;border:none; margin-left:-20px; margin-top:2px'; + } + var href = 'http://www.thegreenwebfoundation.org'; return $("", { href: href, class: 'TGWF-addon' }) - .append($('', { src: getImagePath(color), style: 'width:16px; height:16px;border:none;' } )); + .append($('', { src: getImagePath(color), style: style } )); } /** @@ -148,7 +153,7 @@ function getImageNode(color) /** * Get the image path based on file */ -function getImagePath(file) +function getImagePath(file, local) { var icons = {}; icons.green = chrome.runtime.getURL("/images/green20x20.gif"); @@ -162,15 +167,25 @@ function getImagePath(file) return icons[file]; } + if (local) { + return chrome.runtime.getURL("/images/green20x20.gif"); + } + + // if the file has http as it's start, it's a full url to a web icon somewhere else, so then return that. + var prot = file.substring(0,4); + if (prot === 'http') { + return file; + } + return 'https://api.thegreenwebfoundation.org/icons/' + file + "20x20.gif"; } /** * Get the resulting image from the data as jquery dom node */ -function getResultNode(data) +function getResultNode(data, type) { - return getLinkNode(getIcon(data)); + return getLinkNode(getIcon(data), type); } /**