diff --git a/src/assets/javascripts/helpers/translate.js b/src/assets/javascripts/helpers/translate.js index 1f92bb7..43da9ef 100644 --- a/src/assets/javascripts/helpers/translate.js +++ b/src/assets/javascripts/helpers/translate.js @@ -176,6 +176,14 @@ function setTo(val) { console.log("to: ", to) } +let simplyTranslateEngine; +const getSimplyTranslateEngine = () => simplyTranslateEngine; +function setSimplyTranslateEngine(val) { + simplyTranslateEngine = val; + browser.storage.local.set({ simplyTranslateEngine: val }) + console.log("simplyTranslateEngine: ", val) +} + function isTranslate(url, initiator) { if (disable) return false; return targets.includes(url.host) @@ -201,6 +209,7 @@ function redirect(url) { else { if (from != "DEFAULT") url.searchParams.append("sl", from); if (to != "DEFAULT") url.searchParams.append("tl", to); + if (simplyTranslateEngine != "DEFAULT") url.searchParams.append("engine", simplyTranslateEngine); return `${randomInstance}/${url.search}` } @@ -283,6 +292,7 @@ async function init() { "translateFrom", "translateTo", + "simplyTranslateEngine", ], (result) => { disable = result.translateDisable ?? false; @@ -291,6 +301,7 @@ async function init() { from = result.translateFrom ?? "DEFAULT"; to = result.translateTo ?? 'DEFAULT'; + simplyTranslateEngine = result.simplyTranslateEngine ?? 'DEFAULT'; redirects.simplyTranslate = dataJson.simplyTranslate; redirects.lingva = dataJson.lingva; @@ -336,6 +347,9 @@ export default { getTo, setTo, + getSimplyTranslateEngine, + setSimplyTranslateEngine, + getSimplyTranslateNormalRedirectsChecks, setSimplyTranslateNormalRedirectsChecks, getSimplyTranslateTorRedirectsChecks, diff --git a/src/pages/options/general/general.js b/src/pages/options/general/general.js index 2796bba..0a0d41c 100644 --- a/src/pages/options/general/general.js +++ b/src/pages/options/general/general.js @@ -32,9 +32,9 @@ document.querySelector("#update-instances").addEventListener("click", () => { document.querySelector("#update-instances").innerHTML = 'Failed Miserabely'; }); -document.querySelector("#export-settings").addEventListener("click", () => { - browser.storage.local.get(null, result => console.log(result)) -}); +// document.querySelector("#export-settings").addEventListener("click", () => { +// browser.storage.local.get(null, result => console.log(result)) +// }); let nameCustomInstanceInput = document.getElementById("exceptions-custom-instance"); let instanceTypeElement = document.getElementById("exceptions-custom-instance-type"); diff --git a/src/pages/options/translate/translate.html b/src/pages/options/translate/translate.html index a51b459..0438098 100644 --- a/src/pages/options/translate/translate.html +++ b/src/pages/options/translate/translate.html @@ -134,7 +134,7 @@
-
+

From

-
-
+
+

Engine

+ +

Default Instances

diff --git a/src/pages/options/translate/translate.js b/src/pages/options/translate/translate.js index 7626f34..215fc71 100644 --- a/src/pages/options/translate/translate.js +++ b/src/pages/options/translate/translate.js @@ -6,19 +6,16 @@ disableElement.addEventListener("change", (event) => translateHelper.setDisable(!event.target.checked) ); -let simplyTranslateLingvaDivElement = document.getElementById("simplyTranslate-lingva") let simplyTranslateDivElement = document.getElementById("simplyTranslate") let lingvaDivElement = document.getElementById("lingva") function changeFrontendsSettings(frontend) { if (frontend == 'simplyTranslate') { - simplyTranslateLingvaDivElement.style.display = 'block'; simplyTranslateDivElement.style.display = 'block'; lingvaDivElement.style.display = 'none'; } else if (frontend == 'lingva') { - simplyTranslateLingvaDivElement.style.display = 'block'; simplyTranslateDivElement.style.display = 'none'; lingvaDivElement.style.display = 'block'; } @@ -71,6 +68,11 @@ toElement.addEventListener("change", event => translateHelper.setTo(event.target.options[toElement.selectedIndex].value) ); +let simplyTranslateEngineElement = document.getElementById("simplyTranslate-engine"); +simplyTranslateEngineElement.addEventListener("change", + event => translateHelper.setSimplyTranslateEngine(event.target.options[simplyTranslateEngineElement.selectedIndex].value) +); + translateHelper.init().then(() => { disableElement.checked = !translateHelper.getDisable(); @@ -84,6 +86,7 @@ translateHelper.init().then(() => { fromElement.value = translateHelper.getFrom(); toElement.value = translateHelper.getTo(); + simplyTranslateEngineElement.value = translateHelper.getSimplyTranslateEngine(); commonHelper.processDefaultCustomInstances( 'simplyTranslate',