diff --git a/doc/description.md b/doc/description.md
index 39767fe4..62e5c4b0 100644
--- a/doc/description.md
+++ b/doc/description.md
@@ -19,6 +19,8 @@ Mouseover Translate Any Language At Once
English, Russian, Japanese, Chinese and so on
# Change Log
+- 0.1.101
+ - add source language & mouse click for tooltip (request by محمد ع. أبو الحسن)
- 0.1.100
- make hijack injection tighter for support more site (request by AstudilloMarillo)
- 0.1.99
diff --git a/public/_locales/am/messages.json b/public/_locales/am/messages.json
index e23bfd65..b12c498f 100644
--- a/public/_locales/am/messages.json
+++ b/public/_locales/am/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "የመዳፊት መሳሪያ መሳሪያ ተርጓሚ"
+ "message": "የመዳፊት መሳሪያ መሳሪያ ተርጓሚ for learning language"
},
"appDesc": {
"message": "የመዳፊት መሣሪያ መሣሪያ ተርጓሚ የጉግል ትርጉም በመጠቀም Moyyover ጽሑፍን ይተርጉሙ"
diff --git a/public/_locales/bg/messages.json b/public/_locales/bg/messages.json
index 1c410c1f..812bbd4e 100644
--- a/public/_locales/bg/messages.json
+++ b/public/_locales/bg/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Преводач на мишка with romanization"
+ "message": "Преводач на мишка : manga translator"
},
"appDesc": {
"message": "Превода"
diff --git a/public/_locales/ca/messages.json b/public/_locales/ca/messages.json
index c2769eed..db5129da 100644
--- a/public/_locales/ca/messages.json
+++ b/public/_locales/ca/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Traductor d'eines de ratolí For Google Translator"
+ "message": "Traductor d'eines de ratolí With Google Translator"
},
"appDesc": {
"message": "Traductor de Tool Tip Tra Translate Text MouseOver mitjançant Google Translate"
diff --git a/public/_locales/de/messages.json b/public/_locales/de/messages.json
index bfabbd2c..3f711edc 100644
--- a/public/_locales/de/messages.json
+++ b/public/_locales/de/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Maus -Tooltip -Übersetzer"
+ "message": "Maus -Tooltip -Übersetzer for pdf ebook"
},
"appDesc": {
"message": "Maus -Tooltip -Übersetzer übersetzen Mausover -Text mit Google Translate"
diff --git a/public/_locales/el/messages.json b/public/_locales/el/messages.json
index 57c6469c..f9837c0c 100644
--- a/public/_locales/el/messages.json
+++ b/public/_locales/el/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Μεταφραστής εργαλείων ποντικιού : Translate Image and Text"
+ "message": "Μεταφραστής εργαλείων ποντικιού : Translate Image"
},
"appDesc": {
"message": "Μεταφραστής εργαλείων ποντικιού Μεταφράστε κείμενο ποντικιού χρησιμοποιώντας το Google Translate"
diff --git a/public/_locales/es_419/messages.json b/public/_locales/es_419/messages.json
index 7bedfa75..788e8794 100644
--- a/public/_locales/es_419/messages.json
+++ b/public/_locales/es_419/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Traductor de información sobre herramientas del mouse - Translate Manga"
+ "message": "Traductor de información sobre herramientas del mouse for Education"
},
"appDesc": {
"message": "El traductor de información sobre herramientas de mouse traducir el texto de mouseover usando Google Translate"
diff --git a/public/_locales/fi/messages.json b/public/_locales/fi/messages.json
index 93107a08..1583a049 100644
--- a/public/_locales/fi/messages.json
+++ b/public/_locales/fi/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Hiiren työkaluvihje kääntäjä - Web Translate"
+ "message": "Hiiren työkaluvihje kääntäjä : TTS Translator"
},
"appDesc": {
"message": "Hiiren työkaluvihje kääntäjä Käännä hiirensiirtoteksti Google Translate -sovelluksella"
diff --git a/public/_locales/fr/messages.json b/public/_locales/fr/messages.json
index 02f6b914..45e15ee0 100644
--- a/public/_locales/fr/messages.json
+++ b/public/_locales/fr/messages.json
@@ -162,7 +162,7 @@
"message": "Titre "
},
"appName": {
- "message": "Traduction Souris Info-bulle"
+ "message": "Traduction Souris Info-bulle : Learn Language"
},
"appDesc": {
"message": "Traduire le texte pointé par la souris à l'aide de différent moteur de traduction"
diff --git a/public/_locales/gu/messages.json b/public/_locales/gu/messages.json
index d327f225..28490e20 100644
--- a/public/_locales/gu/messages.json
+++ b/public/_locales/gu/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "માઉસ ટૂલટિપ અનુવાદક for learning language"
+ "message": "માઉસ ટૂલટિપ અનુવાદક : TTS"
},
"appDesc": {
"message": "ગૂગલ ટ્રાન્સલેશનનો ઉપયોગ કરીને માઉસ ટૂલટિપ અનુવાદક માઉસઓવર ટેક્સ્ટનું ભાષાંતર કરે છે"
diff --git a/public/_locales/hi/messages.json b/public/_locales/hi/messages.json
index 6cb0ba8a..ac54246c 100644
--- a/public/_locales/hi/messages.json
+++ b/public/_locales/hi/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "माउस टूलटिप अनुवादक With TTS Voice Speech translator"
+ "message": "माउस टूलटिप अनुवादक With Voice Speech translator"
},
"appDesc": {
"message": "माउस टूलटिप ट्रांसलेटर अनुवाद करें माउसओवर पाठ Google अनुवाद का उपयोग करके"
diff --git a/public/_locales/hu/messages.json b/public/_locales/hu/messages.json
index 074e7980..edc653d1 100644
--- a/public/_locales/hu/messages.json
+++ b/public/_locales/hu/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Egér ToolTip fordító : subtitle & epub reader translator"
+ "message": "Egér ToolTip fordító : Subtitle Epub Reader Translator"
},
"appDesc": {
"message": "Egér ToolTip Translator fordítása MouseOver szöveget a Google Translate segítségével"
diff --git a/public/_locales/it/messages.json b/public/_locales/it/messages.json
index cb55be07..cbc117f1 100644
--- a/public/_locales/it/messages.json
+++ b/public/_locales/it/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Traduttore di tooltip del mouse With TTS and OCR"
+ "message": "Traduttore di tooltip del mouse With TTS OCR"
},
"appDesc": {
"message": "Traduttore di tooltip del mouse Translate Testo del mouseover usando Google Translate"
diff --git a/public/_locales/kn/messages.json b/public/_locales/kn/messages.json
index bea558d3..0121a60f 100644
--- a/public/_locales/kn/messages.json
+++ b/public/_locales/kn/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "ಮೌಸ್ ಟೂಲ್ಟಿಪ್ ಅನುವಾದಕ : Select to Translate"
+ "message": "ಮೌಸ್ ಟೂಲ್ಟಿಪ್ ಅನುವಾದಕ: Select to Translate"
},
"appDesc": {
"message": "ಮೌಸ್ ಟೂಲ್ಟಿಪ್ ಅನುವಾದಕ ಗೂಗಲ್ ಅನುವಾದವನ್ನು ಬಳಸಿಕೊಂಡು ಮೌಸೋವರ್ ಪಠ್ಯವನ್ನು ಅನುವಾದಿಸಿ"
diff --git a/public/_locales/lt/messages.json b/public/_locales/lt/messages.json
index d7dd5635..1ec40012 100644
--- a/public/_locales/lt/messages.json
+++ b/public/_locales/lt/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Pelės patarimų vertėjas : Translate Youtube and Manga "
+ "message": "Pelės patarimų vertėjas : Translate Youtube"
},
"appDesc": {
"message": "Pelės patarimo vertėjas vertėjas versti pelės viršų"
diff --git a/public/_locales/lv/messages.json b/public/_locales/lv/messages.json
index e25e270e..5cc1880e 100644
--- a/public/_locales/lv/messages.json
+++ b/public/_locales/lv/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Peles rīku padomu tulkotājs : Translate epub viewer"
+ "message": "Peles rīku padomu tulkotājs : Translate Manga, Epub Viewer"
},
"appDesc": {
"message": "Peles rīka padomu tulkotājs tulkot peles pārsniegšanas tekstu, izmantojot Google tulkojumu"
diff --git a/public/_locales/ml/messages.json b/public/_locales/ml/messages.json
index 919b64a4..796cedb3 100644
--- a/public/_locales/ml/messages.json
+++ b/public/_locales/ml/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "മൗസ് ടൂൾടിപ്പ് പരിഭാഷകൻ : translate pdf ebook subtitle"
+ "message": "മൗസ് ടൂൾടിപ്പ് പരിഭാഷകൻ : translate pdf subtitle"
},
"appDesc": {
"message": "മ mouse സ് ടൂൾടിപ്പ് ട്രാൻസ്ലേറ്റർ വിവർത്തനം ചെയ്യുക മസോവർ ടെക്സ്റ്റ് Google വിവർത്തനം ഉപയോഗിച്ച്"
diff --git a/public/_locales/ms/messages.json b/public/_locales/ms/messages.json
index 0d22f9e8..00d9a4f1 100644
--- a/public/_locales/ms/messages.json
+++ b/public/_locales/ms/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Penterjemah Tooltip Mouse for Education Learning"
+ "message": "Penterjemah Tooltip Mouse for PDF GOOGLE DOCS"
},
"appDesc": {
"message": "Penterjemah Tooltip Mouse Terjemahkan Teks Mouseover Menggunakan Google Translate"
diff --git a/public/_locales/nl/messages.json b/public/_locales/nl/messages.json
index f8d06eea..096747c3 100644
--- a/public/_locales/nl/messages.json
+++ b/public/_locales/nl/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Muise -gereedschap vertaler with translate ebook viewer"
+ "message": "Muise -gereedschap vertaler with translate chatgpt, ebook viewer"
},
"appDesc": {
"message": "Muis Toltip Translator vertaalt mouseover -tekst met behulp van Google Translate"
diff --git a/public/_locales/no/messages.json b/public/_locales/no/messages.json
index ae16fc1b..c3fe3692 100644
--- a/public/_locales/no/messages.json
+++ b/public/_locales/no/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Mus ToolTip Translator : translate writing text"
+ "message": "Mus ToolTip Translator : PDF, Manga"
},
"appDesc": {
"message": "Mus ToolTip Translator Translate Mouseover -tekst ved hjelp av Google Translate"
diff --git a/public/_locales/pt_BR/messages.json b/public/_locales/pt_BR/messages.json
index a33ff0c8..ca095fa9 100644
--- a/public/_locales/pt_BR/messages.json
+++ b/public/_locales/pt_BR/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Tradutor da dica de ferramenta do mouse"
+ "message": "Tradutor da dica de ferramenta do mouse With PDF Viewer"
},
"appDesc": {
"message": "Mouse Tooltip Tradutor Traduzir Texto do MouseOver usando o Google Translate"
diff --git a/public/_locales/ro/messages.json b/public/_locales/ro/messages.json
index 7026ca26..aa026d46 100644
--- a/public/_locales/ro/messages.json
+++ b/public/_locales/ro/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Traducător de instrumente de mouse : Learn Language"
+ "message": "Traducător de instrumente de mouse for TTS PDF"
},
"appDesc": {
"message": "Traducător de instrumente de mouse -ul traduce textul mouseover folosind Google Translate"
diff --git a/public/_locales/sk/messages.json b/public/_locales/sk/messages.json
index 8cdb34e3..fed2ee6f 100644
--- a/public/_locales/sk/messages.json
+++ b/public/_locales/sk/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Prekladateľ myši With PDF Viewer and Speech Voice Reader"
+ "message": "Prekladateľ myši : Voice Speech Reader Translator"
},
"appDesc": {
"message": "Prekladač prekladateľ myši prekladač Mouseover text pomocou prekladu Google"
diff --git a/public/_locales/sr/messages.json b/public/_locales/sr/messages.json
index bfa0e88b..5122e332 100644
--- a/public/_locales/sr/messages.json
+++ b/public/_locales/sr/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Моусе Тоолтип Транслатор : OCR Translator"
+ "message": "Моусе Тоолтип Транслатор : Manga OCR Translator"
},
"appDesc": {
"message": "Моусе Тоолтип преводилац Преведи текст миша помоћу Гоогле Транслате"
diff --git a/public/_locales/ta/messages.json b/public/_locales/ta/messages.json
index a08116a1..dfd3f68e 100644
--- a/public/_locales/ta/messages.json
+++ b/public/_locales/ta/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "சுட்டி உதவிக்குறிப்பு மொழிபெயர்ப்பாளர் With PDF Reader and ebook reader translator"
+ "message": "சுட்டி உதவிக்குறிப்பு மொழிபெயர்ப்பாளர் With PDF ebook reader"
},
"appDesc": {
"message": "மவுஸ் உதவிக்குறிப்பு மொழிபெயர்ப்பாளர் கூகிள் மொழிபெயர்ப்பைப் பயன்படுத்தி மவுஸ்ஓவர் உரையை மொழிபெயர்க்கவும்"
diff --git a/public/_locales/te/messages.json b/public/_locales/te/messages.json
index 5569eee8..85b06929 100644
--- a/public/_locales/te/messages.json
+++ b/public/_locales/te/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "మౌస్ టూల్టిప్ అనువాదకుడు : Web Translator"
+ "message": "మౌస్ టూల్టిప్ అనువాదకుడు : Translate manga"
},
"appDesc": {
"message": "మౌస్ టూల్టిప్ అనువాదకుడు గూగుల్ అనువాదం ఉపయోగించి మౌస్ఓవర్ వచనాన్ని అనువదించండి"
diff --git a/public/_locales/vi/messages.json b/public/_locales/vi/messages.json
index 42be8734..c901d3a2 100644
--- a/public/_locales/vi/messages.json
+++ b/public/_locales/vi/messages.json
@@ -162,7 +162,7 @@
"message": "Title "
},
"appName": {
- "message": "Chuột Tooltip Translator"
+ "message": "Chuột Tooltip Translator with PDF TTS"
},
"appDesc": {
"message": "Chuột Tooltip Translator Dịch văn bản Mouseover bằng Google Dịch"
diff --git a/src/contentScript.js b/src/contentScript.js
index 7c806ebf..911a4288 100644
--- a/src/contentScript.js
+++ b/src/contentScript.js
@@ -7,6 +7,7 @@ import tippy, { followCursor, hideAll } from "tippy.js";
import { encode } from "he";
import matchUrl from "match-url-wildcard";
import delay from "delay";
+import { waitUntil } from "async-wait-until";
import { debounce } from "throttle-debounce";
// import * as GoogleDocsUtils from "google-docs-utils";
@@ -24,7 +25,8 @@ var mouseTarget = null;
var activatedWord = null;
var mouseMoved = false;
var mouseMovedCount = 0;
-var keyDownList = {}; //use key down for enable translation partially
+var keyDownList = { always: true }; //use key down for enable translation partially
+var keyDownReleaseList = {};
var style;
let selectedText = "";
var destructionEvent = "destructmyextension_MouseTooltipTranslator"; // + chrome.runtime.id;
@@ -33,11 +35,13 @@ const { signal } = controller;
var mouseoverInterval;
var writingField =
'input[type="text"], input[type="search"], input:not([type]), textarea, [contenteditable="true"], [role=textbox], [spellcheck]';
-var isYoutubeDetected = false;
+var isYoutubeOn = false;
var delayTime = 700;
var isBlobPdf = false;
var prevWordParam = [];
var isGoogleDoc = false;
+var mouseKeyMap = ["ClickLeft", "ClickMiddle", "ClickRight"];
+var prevTooltipText = "";
//tooltip core======================================================================
$(async function initMouseTooltipTranslator() {
@@ -98,21 +102,25 @@ function startTextSelectDetector() {
//process detected word
async function processWord(word, actionType, range) {
prevWordParam = Array.prototype.slice.call(arguments); //record args
+ word = util.filterWord(word); //filter out one that is url,no normal char
+ var isTooltipOn = keyDownList[setting["showTooltipWhen"]];
+ var isTtsOn = keyDownList[setting["TTSWhen"]];
+ applyReleaseKeydownList();
// skip if mouse target is tooltip
+ //hide tooltip, if activated word exist and current word is none
+ //do nothing, if no new word or no word change, or if isTooltipOn isTtsOn both are down
+ //if isTooltipOn is off, hide tooltip
if (checkMouseTargetIsTooltip()) {
return;
- }
- word = util.filterWord(word); //filter out one that is url,no normal char
-
- //hide tooltip, if activated word exist and current word is none
- //do nothing, if no new word or no word change
- if (!word && activatedWord) {
+ } else if (!word && activatedWord) {
activatedWord = word;
hideTooltip();
return;
} else if (activatedWord == word || !word) {
return;
+ } else if (!isTooltipOn) {
+ hideTooltip();
}
//stage current processing word
@@ -140,16 +148,19 @@ async function processWord(word, actionType, range) {
//if tooltip is on or activation key is pressed, show tooltip
//if current word is recent activatedWord
- if (
- setting["showTooltipWhen"] == "always" ||
- keyDownList[setting["showTooltipWhen"]]
- ) {
- var tooltipText = wrapInlineHtml(
- translatedText,
- transliteration,
- targetLang
- );
- showTooltip(tooltipText);
+ if (isTooltipOn) {
+ var tooltipTransliteration =
+ setting["useTransliteration"] == "true" ? transliteration : "";
+ var tooltipLang =
+ setting["showSourceLang"] == "true"
+ ? util.langListOpposite[sourceLang]
+ : "";
+ var tooltipText = wrapRtlHtml(translatedText, targetLang);
+ tooltipText += concatTooltipText(tooltipTransliteration, tooltipLang);
+ var resetPrevTooltip = prevTooltipText != tooltipText;
+ prevTooltipText = tooltipText;
+
+ showTooltip(tooltipText, resetPrevTooltip);
requestRecordTooltipText(
word,
translatedText,
@@ -158,12 +169,10 @@ async function processWord(word, actionType, range) {
actionType
);
highlightText(range);
- } else {
- hideTooltip();
}
//if use_tts is on or activation key is pressed, do tts
- if (setting["TTSWhen"] == "always" || keyDownList[setting["TTSWhen"]]) {
+ if (isTtsOn) {
var wordWithoutEmoji = util.filterEmoji(word);
requestTTS(wordWithoutEmoji, sourceLang, translatedText, targetLang);
}
@@ -198,10 +207,12 @@ function highlightText(range) {
}
function restartWordProcess() {
- // mouseover text will be trigger when no activate word
+ //trigger mouseover text by reset activate word
//restart selected text
activatedWord = null;
- processWord(...prevWordParam);
+ if (selectedText) {
+ processWord(...prevWordParam);
+ }
}
function getDetectType() {
@@ -238,14 +249,14 @@ function checkWindowFocus() {
return mouseMoved && document.visibilityState == "visible";
}
-function showTooltip(text) {
- hideTooltip(true); //reset tooltip arrow
+function showTooltip(text, resetPrevTooltip) {
+ hideTooltip(resetPrevTooltip); //reset tooltip arrow
tooltip?.setContent(text);
tooltip?.show();
}
-function hideTooltip(immediately = false) {
- if (immediately) {
+function hideTooltip(resetPrevTooltip = false) {
+ if (resetPrevTooltip) {
hideAll({ duration: 0 }); //hide all tippy
}
tooltip?.hide();
@@ -270,26 +281,27 @@ async function translateWithReverse(word, sourceLang, targetLang, reverseLang) {
return response;
}
-function wrapInlineHtml(translatedText, transliteration, targetLang) {
- var text = ` ${encode(translatedText)} `;
+function wrapRtlHtml(translatedText, targetLang) {
+ var text = `${encode(
+ translatedText
+ )}`;
+ return text;
+}
- if (transliteration && setting["useTransliteration"] == "true") {
- text += `
-
-