Skip to content

Commit

Permalink
For #10 enable back for ftp
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Cristian Petcu committed Aug 21, 2019
1 parent 240bd4f commit 498e550
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions scripts/StorageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class StorageService {
});
}

static async getAlwaysTranslateStatus(url) {
const domainData = await getDomainDataOrDefaults(domain);
return domainData.shouldAlwaysTranslate;
}

static async shouldAlwaysTranslate(domain) {
const domainData = await getDomainDataOrDefaults(domain);
return domainData.shouldAlwaysTranslate;
Expand Down
10 changes: 8 additions & 2 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,15 @@ function getDomain(url) {
return new URL(url).host;
}

function isBasedOnHttp(url) {
return new URL(url).protocol.indexOf("http") > -1;
}

function translateTab(tabId) {
browser.tabs.get(tabId).then(async function (tabInfo) {
await StorageService.setLangCookie(tabInfo.url, tabInfo.cookieStoreId);
if (isBasedOnHttp(tabInfo.url)) {
await StorageService.setLangCookie(tabInfo.url, tabInfo.cookieStoreId);
}
setTimeout(function () {
return browser.tabs.executeScript(tabId, {
file: 'scripts/inject_google_translate_content.js'
Expand All @@ -198,7 +204,7 @@ async function updateMenuForDomain() {
const alwaysOrNever = await StorageService.shouldAlwaysTranslate(domain);
const title = browser.i18n.getMessage("alwaysTranslate-" + !alwaysOrNever) + " " + domain;
const visible = domain.length > 0;
if (NOT_ANDROID) {
if (NOT_ANDROID && isBasedOnHttp(foundTabs[0].url)) {
browser.contextMenus.update("translate-current-page", {
visible, title
});
Expand Down

0 comments on commit 498e550

Please sign in to comment.