From 8282959ac2aaeb9343d20361cd0b40c1e45c37f8 Mon Sep 17 00:00:00 2001 From: Andre Natal Date: Sat, 1 Sep 2018 19:38:40 -0700 Subject: [PATCH] Multi-language support and google fix --- extension/background.js | 2 +- extension/content.js | 15 +++++++++------ extension/manifest.json | 2 +- package.json | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/extension/background.js b/extension/background.js index af52a38..fd97da7 100644 --- a/extension/background.js +++ b/extension/background.js @@ -9,7 +9,7 @@ const analytics = new TestPilotGA({ ds: 'addon', an: 'Voice Fill', aid: 'voicefill@mozilla.com', - av: '1.3.8' + av: '1.4.0' }); browser.runtime.onMessage.addListener(event => { diff --git a/extension/content.js b/extension/content.js index 3b04843..999981d 100644 --- a/extension/content.js +++ b/extension/content.js @@ -21,7 +21,7 @@ const SPINNING_ANIMATION = browser.extension.getURL("Spinning.json"); const START_ANIMATION = browser.extension.getURL("Start.json"); const ERROR_ANIMATION = browser.extension.getURL("Error.json"); - + const LANGUAGE = navigator.language; const escapeHTML = (str) => { // Note: string cast using String; may throw if `str` is non-serializable, e.g. a Symbol. // Most often this is not the case though. @@ -228,8 +228,8 @@ case "www.google.co.uk": case "encrypted.google.com": return { - input: "lst-ib", - anchor: "sfdiv" + input: "q", + anchor: "RNNXgb" } case "duckduckgo.com": case "start.duckduckgo.com": @@ -529,8 +529,8 @@ this.icon.classList.add("stm-hidden"); this.icon.disabled = true; this.hasAnchor = false; - this.input = document.getElementById(register.input); - this.anchor = document.getElementById(register.anchor); + this.input = document.getElementById(register.input) || document.getElementsByName(register.input)[0]; + this.anchor = document.getElementById(register.anchor) || document.getElementsByClassName(register.anchor)[0]; if (this.input.ownerDocument !== document) { return null; @@ -668,7 +668,10 @@ metrics.start_stt(); fetch(STT_SERVER_URL, { method: "POST", - body: blob + body: blob, + headers: { + "Language": LANGUAGE + } }) .then(response => { if (!response.ok) { diff --git a/extension/manifest.json b/extension/manifest.json index 8930a26..525aac9 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Voice Fill", - "version": "1.3.8", + "version": "1.4.0", "description": "Adds voice input to popular search pages in Firefox. Learn more about Voice Fill at https://testpilot.firefox.com", "developer": { "name": "Emerging Technologies Advanced Dev Team", diff --git a/package.json b/package.json index 8ad6f04..a93dc91 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "voicefill", "id": "voicefill@mozilla.com", "description": "This is a simple WebExtension that adds support to use Speech To Text as an input method in web pages.", - "version": "1.3.8", + "version": "1.4.0", "author": { "name": "Andre Natal & Fabrice Desré", "url": "https://github.com/mozilla/speaktome"