Skip to content

Commit

Permalink
fix copy key conflict with tts
Browse files Browse the repository at this point in the history
  • Loading branch information
ttop32 committed Mar 20, 2024
1 parent abb93e6 commit 83deebe
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 102 deletions.
7 changes: 1 addition & 6 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,7 @@ const common = {
/\.vue$/,
/\.vue\?vue/, // .vue
],
// global imports to register
imports: [
// presets
"vue",
"vue-router",
],
imports: ["vue", "vue-router"],
}),
require("unplugin-vue-router/webpack")({}),
],
Expand Down
4 changes: 0 additions & 4 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ module.exports = (env, argv) => {
alias: {
vue$: "vue/dist/vue.esm-bundler.js",
},
fallback: {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
},
},
plugins: [
argv.mode == "development"
Expand Down
2 changes: 2 additions & 0 deletions doc/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Mouseover Translate Any Language At Once
English, Russian, Japanese, Chinese and so on

# Change Log
- 0.1.132
- fix copy key conflict with tts voice(request by ldrahnik)
- 0.1.131
- fix tts voice overlap(request by Nebras)
- 0.1.130
Expand Down
120 changes: 76 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"bootstrap": "^4.5.3",
"cheerio": "^1.0.0-rc.12",
"crypto-browserify": "^3.12.0",
"crypto-js": "^4.2.0",
"delay": "^6.0.0",
"franc": "^6.2.0",
"he": "^1.2.0",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


"web_accessible_resources": [{
"resources": ["pdfjs/web/viewer.html", "ocr.html", "opencvHandler.html", "videoHandler.js","googleDocInject.js","subtitle.js"],
"resources": ["pdfjs/web/viewer.html", "ocr.html", "opencvHandler.html", "googleDocInject.js","subtitle.js"],
"matches": ["<all_urls>"],
"use_dynamic_url": true
}],
Expand Down
12 changes: 7 additions & 5 deletions public/ocr.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!DOCTYPE html>
<html>
<head> </head>
<body>
<script type="text/javascript" src="/ocrIframe.js"></script>
</body>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Mouse Tooltip Translator</title>
<script type="module" src="ocrIframe.js"></script>
</head>
<body></body>
</html>
12 changes: 7 additions & 5 deletions public/offscreen.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!DOCTYPE html>
<html>
<head> </head>
<body>
<script src="offscreen.js"></script>
</body>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Mouse Tooltip Translator</title>
<script type="module" src="offscreen.js"></script>
</head>
<body></body>
</html>
10 changes: 6 additions & 4 deletions public/opencvHandler.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<!DOCTYPE html>
<html>
<head> </head>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Mouse Tooltip Translator OpenCV</title>
</head>
<body>
<script>
var Module = {
Expand All @@ -15,8 +18,7 @@
console.log(mat.data8S);
}
</script>
<script type="text/javascript" src="/opencvHandler.js"></script>

<script type="module" src="opencvHandler.js"></script>
<script async src="/opencv/opencv.js"></script>
</body>
</html>
3 changes: 1 addition & 2 deletions public/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
<title>Mouse Tooltip Translator</title>
<!-- vuetify and its font will be loaded(it comes from popup.js css import) -->
<link rel="stylesheet" href="popup.css" />
<style></style>
<script type="module" src="popup.js"></script>
</head>
<body>
<div id="app"></div>
<script src="popup.js"></script>
</body>
</html>
23 changes: 19 additions & 4 deletions src/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { enableMouseoverTextEvent } from "/src/event/mouseover";
import * as util from "/src/util";
import * as ocrView from "/src/ocr/ocrView.js";
import video from "./subtitle/subtitle.js";
import subtitle from "/src/subtitle";
import { langListOpposite } from "/src/util/lang.js";

//init environment var======================================================================\
Expand Down Expand Up @@ -500,11 +500,26 @@ function handleMouseKeyUp(e) {

function holdKeydownList(key) {
// skip text key
if (key && !keyDownList[key] && !/Key|Digit|Numpad/.test(key)) {
if (key && !keyDownList[key] && !isCharKey(key)) {
keyDownList[key] = true;
restartWordProcess();
translateWriting();
}
stopTTSbyCombKey(key);
}

async function stopTTSbyCombKey(key) {
if (!isCharKey(key) || !keyDownList[setting["TTSWhen"]]) {
return;
}
// stop tts if combination key ex crtl+c
for (var i in [1, 2, 3]) {
await delay(250);
util.requestStopTTS();
}
}
function isCharKey(key) {
return /Key|Digit|Numpad/.test(key);
}

function releaseKeydownList(key) {
Expand Down Expand Up @@ -823,8 +838,8 @@ function injectGoogleDocAnnotation() {

// youtube================================
async function checkVideo() {
video["Youtube"].handleVideo(setting);
video["YoutubeNoCookie"].handleVideo(setting);
subtitle["Youtube"].handleVideo(setting);
subtitle["YoutubeNoCookie"].handleVideo(setting);
}

//destruction ===================================
Expand Down
Loading

0 comments on commit 83deebe

Please sign in to comment.