Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
• Added support for internationalization
• Added European and Brazilian Portuguese locales
  • Loading branch information
Sukigu committed May 7, 2017
1 parent 996ba7b commit 8da9abd
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 17 deletions.
17 changes: 17 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extensionName": {
"message": "Search by Image on Google"
},

"extensionDescription": {
"message": "Search for related images or in different sizes on Google by right clicking on an image."
},

"searchImage": {
"message": "Search Image on Google"
},

"openInBackground": {
"message": "Open search tab in background"
}
}
17 changes: 17 additions & 0 deletions _locales/pt_BR/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extensionName": {
"message": "Pesquisa por imagem no Google"
},

"extensionDescription": {
"message": "Pesquise imagens relacionadas ou em diferentes tamanhos no Google clicando com o botão direito em uma imagem."
},

"searchImage": {
"message": "Pesquisar imagem no Google"
},

"openInBackground": {
"message": "Abrir aba de pesquisa em segundo plano"
}
}
17 changes: 17 additions & 0 deletions _locales/pt_PT/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extensionName": {
"message": "Pesquisa por imagem no Google"
},

"extensionDescription": {
"message": "Pesquise imagens relacionadas ou em diferentes tamanhos no Google clicando com o botão direito numa imagem."
},

"searchImage": {
"message": "Pesquisar imagem no Google"
},

"openInBackground": {
"message": "Abrir separador de pesquisa em segundo plano"
}
}
18 changes: 10 additions & 8 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
'use strict';

browser.contextMenus.create({
id: "googleimagesearch-action",
title: "Search Image on Google",
contexts: ["image"]
id: 'googleimagesearch-action',
title: browser.i18n.getMessage('searchImage'),
contexts: ['image']
});

browser.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId === "googleimagesearch-action") {
if (info.menuItemId === 'googleimagesearch-action') {
var getPreference = browser.storage.sync.get({
openinbackground: true
openInBackground: true
});

getPreference.then(function(result) {
browser.tabs.create({
"url": "https://www.google.com/searchbyimage?image_url=" + info.srcUrl,
"active": !result.openinbackground,
"index": tab.index + 1
url: 'https://www.google.com/searchbyimage?image_url=' + info.srcUrl,
active: !result.openInBackground,
index: tab.index + 1
});
});
}
Expand Down
8 changes: 5 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"manifest_version": 2,
"name": "Search by Image on Google",
"version": "1.1",
"name": "__MSG_extensionName__",
"version": "1.2",

"description": "Allows reverse image searching on Google by right clicking on an image.",
"description": "__MSG_extensionDescription__",

"background": {
"scripts": ["background.js"]
Expand All @@ -23,6 +23,8 @@
"page": "options.html"
},

"default_locale": "en",

"applications": {
"gecko": {
"id": "{1d6267dd-4b37-459a-84da-a5d2580daa6a}"
Expand Down
4 changes: 2 additions & 2 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</head>

<body>
<input type="checkbox" id="openinbackground" />
<label for="openinbackground">Open search in background</label>
<input type="checkbox" id="openInBackground" />
<label for="openInBackground" id="openInBackgroundLabel"></label>

<script src="options.js"></script>
</body>
Expand Down
12 changes: 8 additions & 4 deletions options.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
'use strict';

function saveOptions(e) {
browser.storage.sync.set({
openinbackground: document.getElementById('openinbackground').checked
openInBackground: document.getElementById('openInBackground').checked
});
}

function restoreOptions() {
function setCurrentChoice(result) {
document.getElementById('openinbackground').checked = result.openinbackground;
document.getElementById('openInBackground').checked = result.openInBackground;
}

document.getElementById('openInBackgroundLabel').textContent = browser.i18n.getMessage('openInBackground');

var getPreference = browser.storage.sync.get({
openinbackground: true
openInBackground: true
});
getPreference.then(setCurrentChoice);
}

document.addEventListener('DOMContentLoaded', restoreOptions);
document.getElementById('openinbackground').addEventListener('click', saveOptions);
document.getElementById('openInBackground').addEventListener('click', saveOptions);

0 comments on commit 8da9abd

Please sign in to comment.