Skip to content

Commit 46508b3

Browse files
committed
2 parents 33bd9f3 + 6efdda3 commit 46508b3

File tree

5 files changed

+45
-27
lines changed

5 files changed

+45
-27
lines changed

doc/intro.md

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,63 @@
11
# How to use
22

3-
- Basic uses : Hover or select (highlight) on text to translate.
3+
- Basic Uses: Hover over or select (highlight) text to translate.
44
- Test hover with example text:
55
```console
66
Proletarier aller Länder, vereinigt euch!
77
```
8-
- If not working, check current target language
8+
- If the translation isn't working, verify that the correct target language is selected.
99
- Check [how to change language](https://github.com/ttop32/MouseTooltipTranslator/blob/main/doc/intro.md#change-language)
10-
- This translator will skip text if source text language and target language are same.
10+
- This translator will omit text if the source and target languages are identical.
1111

1212
![Alt Text](/doc/result_0.gif)
13-
- Hold <kbd>left ctrl</kbd> to listen tts pronunciation when tooltip is shown(Press <kbd>esc</kbd> to stop voice)
13+
14+
- Hold the <kbd>left-ctrl</kbd> key (default) key to hear the TTS pronunciation when a tooltip appears. Press <kbd>Esc</kbd> to stop the voice.
15+
1416
![result](/doc/20.gif)
15-
- Use <kbd>right alt</kbd> to translate writing text (or highlighted text) in input box. (Do undo, press <kbd>ctrl</kbd> +<kbd>z</kbd>)
16-
- If not working, check current target language and writing language.
17+
18+
- Press the <kbd>right-alt</kbd> key (default) key to translate the text you're writing (or any highlighted text) in the input box. If needed, you can undo the action by pressing <kbd>ctrl</kbd> + <kbd>z</kbd>.
19+
- If the translation isn't working, ensure that your current target language matches your writing language.
20+
1721
![result](/doc/11.gif)
18-
- Translate url search box text by <kbd>/</kbd>+<kbd>space</kbd> before typing.
22+
23+
- Translate url search box text by <kbd>/</kbd>+<kbd>space</kbd> before typing.
24+
1925
![result](/doc/21.gif)
26+
2027
- Support online pdf to display translated tooltip using PDF.js (local computer pdf file need additional permission, see [exception](https://github.com/ttop32/MouseTooltipTranslator/blob/main/doc/intro.md#exception))
28+
2129
![result](/doc/12.gif)
22-
- Support dual subtitles for youtube video.
30+
31+
- Support dual subtitles for YouTube videos.
32+
2333
![result](/doc/16.gif)
24-
- Process OCR when hold <kbd>left shift</kbd> + <kbd>mouse over</kbd> on image (ex manga)
34+
35+
- Process OCR when holding <kbd>left-shift</kbd> key (default) + mouse over on an image (e.g., manga)
36+
2537
![result](/doc/15.gif)
26-
- Activate speech recognition translator with holding <kbd>right ctrl</kbd>
27-
- Default speech recognition language is english
28-
- If speech recognition language and target language are same, it will skip
38+
39+
- Activate the speech recognition translator by holding down the <kbd>right-ctrl</kbd> key (default).
40+
- Default speech recognition language is English.
41+
- If the speech recognition language and target language are the same, it skips.
2942
- Audio permission is required
30-
- Only works on chrome and edge
43+
- Only compatible with Chromium-based browsers, such as Google Chrome, MS-Edge, Vivaldi, Opera, Brave, Arc, and Yandex.
3144
- Customize shortcut key
32-
- From chrome://extensions/shortcuts
45+
- From chrome://extensions/shortcuts or the equivalent browser internal configuration page, accessible by replacing chrome:// with your browser's internal URL (e.g., edge://, browser://, or brave:// etc).
3346
# Change Language
3447
- Change current language in setting page
35-
- Setting page can be found in browser top right puzzle button
48+
- The Settings page can be accessed by clicking the puzzle (extension) button located at the top right of your browser.
49+
3650
![result](/doc/14.gif)
3751

3852

3953
# Exception
4054

4155
- If source text language and translate language are same, it will skip.
42-
- If web status is offline, it will not work.
56+
- The application will not function if the web status is offline.
4357
- If site is <https://chrome.google.com/extensions>, it does not work because Chrome security reason.
4458
- If no local file permission given, local pdf cannot be handled.
45-
- If not working, darg and drop file on tab
46-
- It will give no permission warning and it redirect to permission page
47-
- In the redirecetd page, make sure to check "allow access to file urls" for accessing file
59+
- If the file doesn't open, try dragging and dropping it onto the tab.
60+
- It will not display a permission warning and instead redirect to the permission page.
61+
- On the redirected page, ensure that you select "allow access to file URLs" to access files.
62+
4863
![result](/doc/10.gif)

src/event/mouseover.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// 4. range to text
66

77
import * as util from "/src/util";
8+
import {debounce} from "lodash";
89

910
var clientX = 0;
1011
var clientY = 0;
@@ -15,16 +16,15 @@ const PARENT_TAGS_TO_EXCLUDE = ["STYLE", "SCRIPT", "TITLE"];
1516

1617
export function enableMouseoverTextEvent(
1718
_window = window,
18-
textDetectTime = 0.7
19+
textDetectTime = 0.1
1920
) {
2021
_win = _window;
2122
textDetectTime = Number(textDetectTime) * 1000;
22-
23-
setInterval(async () => {
23+
const triggerMouseoverTextWithDelay = debounce(async() => {
2424
triggerMouseoverText(await getMouseoverText(clientX, clientY));
2525
}, textDetectTime);
2626

27-
window.addEventListener("mousemove", (e) => {
27+
window.addEventListener("mousemove", async (e) => {
2828
//if is ebook viewer event, take ebook window
2929
if (e.ebookWindow) {
3030
_win = e.ebookWindow;
@@ -38,6 +38,8 @@ export function enableMouseoverTextEvent(
3838
//else record mouse xy
3939
clientX = e.clientX;
4040
clientY = e.clientY;
41+
42+
triggerMouseoverTextWithDelay();
4143
});
4244
}
4345

@@ -66,6 +68,7 @@ async function getMouseoverText(x, y) {
6668
//get text from range
6769
var mouseoverText = await getTextFromRange(range);
6870
textElement?.remove();
71+
6972
return mouseoverText;
7073
}
7174
async function getTextFromRange(range) {

src/event/selection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
* Selection related functions
33
*/
44
import $ from "jquery";
5-
import { debounce, throttle } from "lodash";
5+
import { debounce } from "lodash";
66
import * as util from "/src/util";
77

88
var _win;
99
var prevNoneSelect = false;
1010
export function enableSelectionEndEvent(
1111
_window = window,
12-
textDetectTime = 0.7
12+
textDetectTime = 0.1
1313
) {
1414
_win = _window;
1515
textDetectTime = Number(textDetectTime) * 1000;

src/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ var voiceRateList = util.getRangeOption(0.5, 2.1, 0.1, 1);
182182
var voiceRepeatList = util.getRangeOption(1, 11);
183183
var tooltipBackgroundBlurList = util.getRangeOption(0, 21);
184184
var distanceList = util.getRangeOption(0, 41);
185-
var tooltipIntervalTimeList = util.getRangeOption(0.5, 2.1, 0.1, 1);
185+
var tooltipIntervalTimeList = util.getRangeOption(0.1, 2.1, 0.1, 1);
186186
187187
var tooltipPositionList = {
188188
Follow: "follow",

src/util/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export var defaultData = {
8989
ignoreCallbackOptionList: ["historyList"],
9090
popupCount: "0",
9191
langPriority: { auto: 9999999, null: 9999999 },
92-
tooltipIntervalTime: "0.7",
92+
tooltipIntervalTime: "0.1",
9393

9494
cardPlayMeta: ["image"],
9595
cardTagSelected: [],

0 commit comments

Comments
 (0)