diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..325138fa --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish Extension + +on: + workflow_dispatch: + +jobs: + publish: + name: Publish Extension to Store + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download Extension + uses: robinraju/release-downloader@v1.8 + with: + latest: true + fileName: "*.zip" + + - name: Get Release File Name + run: echo "EDGE_RELEASE_FILE=$(ls | grep *.zip)" >> $GITHUB_ENV + - name: Test + run: echo ${{env.EDGE_RELEASE_FILE}} + + - name: Publish to store + uses: PlasmoHQ/bpp@v3 + with: + keys: ${{ secrets.BPP_KEYS }} + edge-file: "${{env.EDGE_RELEASE_FILE}}" diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index cc1dbdd0..e30fff32 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -26,9 +26,9 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm ci - - run: npm run build-zip-en + - run: npm run build-zip - uses: ncipollo/release-action@v1 with: - artifacts: "mouse_tooltip_translator_*.zip" + artifacts: "*.zip" body: "[Change Log](https://github.com/ttop32/MouseTooltipTranslator/blob/main/doc/description.md#change-log)" diff --git a/.gitignore b/.gitignore index 0eaef8c0..e4322ada 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /build mouse_tooltip_translator_*.zip +mouse_tooltip_translator.zip build.zip size-plugin.json .vscode/ diff --git a/doc/description.md b/doc/description.md index 9bd07074..282ee664 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.110 + - fix tooltip sticky position (request by serega) - 0.1.109 - rollback opencv library - 0.1.108 diff --git a/package-lock.json b/package-lock.json index 979a4bdb..6fb89fbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "del-cli": "^5.0.0", "file-loader": "^6.2.0", "mini-css-extract-plugin": "^0.10.1", - "npm-build-zip": "^1.0.3", + "npm-build-zip": "^1.0.4", "sass": "^1.32.7", "sass-loader": "^11.0.1", "size-plugin": "^2.0.2", @@ -1642,9 +1642,9 @@ } }, "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true }, "node_modules/crc": { @@ -3248,7 +3248,7 @@ "node_modules/is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", "dev": true, "engines": { "node": ">=4" @@ -3459,7 +3459,7 @@ "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "node_modules/isexe": { @@ -4119,9 +4119,9 @@ } }, "node_modules/npm-build-zip": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/npm-build-zip/-/npm-build-zip-1.0.3.tgz", - "integrity": "sha512-+/Oe7Z4fvYsShFnmwC0QmR6ny4SU3YYVleTOBmFtGalPCkAywV+L9Yo9hwRUIR4OXN89k60Lu7lQa/zt+O63VA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/npm-build-zip/-/npm-build-zip-1.0.4.tgz", + "integrity": "sha512-mn4IPDkB+LlJiIaXMJ+vFa1yFrWhT4MGo0AeNN3Blyc+pIdqJzL1mQBvk+qnVT6tP+FbohnYvWFyNaTYEHtpZg==", "dev": true, "dependencies": { "archiver-promise": "1.0.0", @@ -4133,85 +4133,6 @@ "npm-build-zip": "bin/npm-build-zip.js" } }, - "node_modules/npm-build-zip/node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "dependencies": { - "locate-path": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/npm-build-zip/node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/npm-build-zip/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/npm-build-zip/node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "dependencies": { - "p-limit": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/npm-build-zip/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/npm-build-zip/node_modules/yargs": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", - "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", - "dev": true, - "dependencies": { - "cliui": "^5.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^13.1.1" - } - }, "node_modules/npm-bundled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.2.tgz", @@ -4960,9 +4881,9 @@ } }, "node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", "dev": true, "dependencies": { "core-util-is": "~1.0.0", @@ -5063,7 +4984,7 @@ "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -5291,7 +5212,7 @@ "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, "node_modules/sha.js": { @@ -6472,9 +6393,9 @@ } }, "node_modules/which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", "dev": true }, "node_modules/wildcard": { @@ -6542,9 +6463,9 @@ } }, "node_modules/y18n": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", - "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", "dev": true }, "node_modules/yallist": { @@ -6553,6 +6474,24 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "dependencies": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + } + }, "node_modules/yargs-parser": { "version": "13.1.2", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", @@ -6572,6 +6511,67 @@ "node": ">=6" } }, + "node_modules/yargs/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -7901,9 +7901,9 @@ } }, "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true }, "crc": { @@ -9106,7 +9106,7 @@ "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", "dev": true }, "is-glob": { @@ -9250,7 +9250,7 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "isexe": { @@ -9744,78 +9744,15 @@ } }, "npm-build-zip": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/npm-build-zip/-/npm-build-zip-1.0.3.tgz", - "integrity": "sha512-+/Oe7Z4fvYsShFnmwC0QmR6ny4SU3YYVleTOBmFtGalPCkAywV+L9Yo9hwRUIR4OXN89k60Lu7lQa/zt+O63VA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/npm-build-zip/-/npm-build-zip-1.0.4.tgz", + "integrity": "sha512-mn4IPDkB+LlJiIaXMJ+vFa1yFrWhT4MGo0AeNN3Blyc+pIdqJzL1mQBvk+qnVT6tP+FbohnYvWFyNaTYEHtpZg==", "dev": true, "requires": { "archiver-promise": "1.0.0", "npm-packlist": "1.4.4", "sanitize-filename": "1.6.3", "yargs": "13.3.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", - "dev": true - }, - "yargs": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", - "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", - "dev": true, - "requires": { - "cliui": "^5.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^13.1.1" - } - } } }, "npm-bundled": { @@ -10363,9 +10300,9 @@ } }, "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", "dev": true, "requires": { "core-util-is": "~1.0.0", @@ -10446,7 +10383,7 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, "require-main-filename": { @@ -10581,7 +10518,7 @@ "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, "sha.js": { @@ -11474,9 +11411,9 @@ } }, "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", "dev": true }, "wildcard": { @@ -11524,9 +11461,9 @@ "dev": true }, "y18n": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", - "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", "dev": true }, "yallist": { @@ -11535,6 +11472,69 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true + } + } + }, "yargs-parser": { "version": "13.1.2", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", diff --git a/package.json b/package.json index cf8c4aca..dfa3cd70 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,8 @@ "watch": "webpack --mode=development --watch --config config/webpack.config.js", "build": "webpack --mode=production --config config/webpack.config.js", "delete": "del-cli --force ./build", - "delete-en": "del-cli --force ./build/_locales/* !./build/_locales/en", "zip": "npm-build-zip", - "zip-en": "npm-build-zip --name _en", - "build-zip": "npm run delete && npm run build && npm run zip", - "build-zip-en": "npm run build-zip && npm run delete-en && npm run zip-en" + "build-zip": "npm run delete && npm run build && npm run zip" }, "devDependencies": { "@mdi/font": "^5.9.55", @@ -23,7 +20,7 @@ "del-cli": "^5.0.0", "file-loader": "^6.2.0", "mini-css-extract-plugin": "^0.10.1", - "npm-build-zip": "^1.0.3", + "npm-build-zip": "^1.0.4", "sass": "^1.32.7", "sass-loader": "^11.0.1", "size-plugin": "^2.0.2", diff --git a/src/background.js b/src/background.js index 084ed6e0..5075c59c 100644 --- a/src/background.js +++ b/src/background.js @@ -243,8 +243,8 @@ async function playTts(text, lang, startTimeStamp) { if (startTimeStamp < stopTtsTimestamp) { return; } - var volume = Number(setting["voiceVolume"]); - var rate = Number(setting["voiceRate"]); + var volume = setting["voiceVolume"]; + var rate = setting["voiceRate"]; var voiceFullName = setting?.["ttsVoice_" + lang]; var isExternalTts = /^(BingTTS|GoogleTranslateTTS).*/.test(voiceFullName); var voice = isExternalTts ? voiceFullName.split("_")[1] : voiceFullName; diff --git a/src/contentScript.js b/src/contentScript.js index 1d59e870..8e8cd471 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -3,7 +3,7 @@ //intercept pdf url import $ from "jquery"; -import tippy, { followCursor, hideAll } from "tippy.js"; +import tippy, { sticky, hideAll } from "tippy.js"; import { encode } from "he"; import matchUrl from "match-url-wildcard"; import { debounce } from "throttle-debounce"; @@ -27,7 +27,6 @@ var activatedWord = null; var mouseMoved = false; var mouseMovedCount = 0; var keyDownList = { always: true }; //use key down for enable translation partially -var keyDownReleaseList = {}; var style; let selectedText = ""; var destructionEvent = "destructmyextension_MouseTooltipTranslator"; // + chrome.runtime.id; @@ -39,6 +38,8 @@ var isBlobPdf = false; var prevWordParam = []; var mouseKeyMap = ["ClickLeft", "ClickMiddle", "ClickRight"]; var prevTooltipText = ""; +var tooltipContainer; +var tooltipContainerEle; //tooltip core====================================================================== $(async function initMouseTooltipTranslator() { @@ -66,13 +67,8 @@ $(async function initMouseTooltipTranslator() { function startMouseoverDetector() { enableMouseoverTextEvent(); addEventHandler("mouseoverText", async function (event) { - // only work when tab is activated and when mousemove and no selected text - if ( - checkWindowFocus() && - !selectedText && - setting["translateWhen"].includes("mouseover") && - event?.mouseoverText != null - ) { + // if no selected text + if (setting["translateWhen"].includes("mouseover") && !selectedText) { var mouseoverText = event?.mouseoverText?.[getDetectType()]; var mouseoverRange = event?.mouseoverText?.[getDetectType() + "_range"]; await processWord(mouseoverText, "mouseover", mouseoverRange); @@ -85,11 +81,7 @@ function startTextSelectDetector() { enableSelectionEndEvent(window); //set mouse drag text selection event addEventHandler("selectionEnd", async function (event) { // if translate on selection is enabled - if ( - checkWindowFocus() && - setting["translateWhen"].includes("select") && - ((selectedText && event.selectedText == "") || event.selectedText) - ) { + if (setting["translateWhen"].includes("select")) { selectedText = event?.selectedText; await processWord(selectedText, "select"); } @@ -102,12 +94,15 @@ async function processWord(word, actionType, range) { 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 or no text, if no new word + // skip if mouse target is tooltip or no text, if no new word or tab is not activated // hide tooltip, if no text // if tooltip is off, hide tooltip - if (checkMouseTargetIsTooltip() || activatedWord == word) { + if ( + !checkWindowFocus() || + checkMouseTargetIsTooltip() || + activatedWord == word + ) { return; } else if (!word) { activatedWord = word; @@ -191,6 +186,7 @@ function highlightText(range) { $("
", { class: "mtt-highlight", css: { + position: "absolute", left: rect.left + adjustX, top: rect.top + adjustY, width: rect.width, @@ -380,6 +376,7 @@ function handleMousemove(e) { return; } setMouseStatus(e); + setTooltipPosition(e.clientX, e.clientY); ocrView.checkImage(mouseTarget, setting, keyDownList); checkWritingBox(); } @@ -423,20 +420,7 @@ function holdKeydownList(key) { } function releaseKeydownList(key) { - if (keyDownList[key]) { - keyDownReleaseList[key] = false; - // keyDownList[key] = false; - } - if (selectedText) { - applyReleaseKeydownList(); - } -} - -function applyReleaseKeydownList() { - for (var key in keyDownReleaseList) { - keyDownList[key] = keyDownReleaseList[key]; - } - keyDownReleaseList = {}; + keyDownList[key] = false; } function handleBlur(e) { @@ -454,6 +438,9 @@ function setMouseStatus(e) { clientY = e.clientY; mouseTarget = e.target; } +function setTooltipPosition(x, y) { + tooltipContainer?.css("transform", `translate(${x}px,${y}px)`); +} const checkWritingBox = debounce(delayTime, () => { // if mouse target is not writing box or already bound, return @@ -545,14 +532,27 @@ async function getSetting() { } function applyStyleSetting() { + var isSticky = setting["tooltipPosition"] == "follow"; tooltip.setProps({ offset: [0, setting["tooltipDistance"]], - followCursor: setting["tooltipPosition"] == "follow" ? true : "initial", - interactive: setting["tooltipPosition"] == "follow" ? false : true, + sticky: isSticky ? "reference" : "popper", + appendTo: isSticky ? tooltipContainerEle : document.body, animation: setting["tooltipAnimation"], }); var cssText = ` + #mttContainer { + left: 0 !important; + top: 0 !important; + width: 1000px !important; + margin-left: -500px !important; + position: fixed !important; + z-index: 100000200 !important; + background: none !important; + pointer-events: none !important; + display: inline-block !important; + visibility: visible !important; + } .tippy-box[data-theme~="custom"] { font-size: ${setting["tooltipFontSize"]}px !important; max-width: ${setting["tooltipWidth"]}px !important; @@ -682,8 +682,17 @@ function checkExcludeUrl() { return matchUrl(url, setting["websiteExcludeList"]); } -function addElementEnv() { - tooltip = tippy(document.body, { +async function addElementEnv() { + tooltipContainer = $("", { + id: "mttContainer", + }).appendTo(document.body); + tooltipContainerEle = tooltipContainer.get(0); + + style = $("", { + id: "mttstyle", + }).appendTo("head"); + + tooltip = tippy(tooltipContainerEle, { content: "", trigger: "manual", allowHTML: true, @@ -691,13 +700,9 @@ function addElementEnv() { zIndex: 100000200, hideOnClick: false, role: "mtttooltip", - followCursor: true, - plugins: [followCursor], + interactive: true, + plugins: [sticky], }); - - style = $("", { - id: "mttstyle", - }).appendTo("head"); } async function checkGoogleDocs() { diff --git a/src/tts/baseTTS.js b/src/tts/baseTTS.js index 46c31f6d..326b9a6d 100644 --- a/src/tts/baseTTS.js +++ b/src/tts/baseTTS.js @@ -5,21 +5,17 @@ import * as util from "/src/util"; export default class BaseTTS { static async playTTS(text, voice, lang, rate, volume) { try { + var volume = Number(volume); + var rate = Number(rate); + this.stopTTS(); await this.playTTSEngine(text, voice, lang, rate, volume); } catch (error) { console.log(error); } } - static async playSound(source, rate, volume) { - await this.createOffscreen(); - await util.sendMessage({ - play: { - source, - rate, - volume, - }, - }); + static async playTTSEngine(text, voice, lang, rate, volume) { + throw new Error("Not implemented"); } static stopTTS() { @@ -27,9 +23,19 @@ export default class BaseTTS { this.stopTtsOffscreen(); } + static async playSound(source, rate, volume) { + await this.createOffscreen(); + await util.sendMessage({ + type: "playTTSOffscreen", + source, + rate, + volume, + }); + } + static async stopTtsOffscreen() { await this.createOffscreen(); - util.sendMessage({ stop: {} }); + util.sendMessage({ type: "stopTTSOffscreen" }); } // Create the offscreen document @@ -50,8 +56,4 @@ export default class BaseTTS { browser.offscreen.closeDocument(() => resolve()); }); } - - static async playTTSEngine(text, voice, lang, rate, volume) { - throw new Error("Not implemented"); - } } diff --git a/src/tts/offscreen.js b/src/tts/offscreen.js index 2895ac0b..8b3b2fc8 100644 --- a/src/tts/offscreen.js +++ b/src/tts/offscreen.js @@ -3,19 +3,13 @@ var audio; // Listen for messages from the extension chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { (async () => { - if ("play" in request) { - // await playAudio(request.play); + if (request.type === "playTTSOffscreen") { stopAudio(); - await play( - request?.play?.source, - request?.play?.rate, - request?.play?.volume - ); - sendResponse(); - } - if ("stop" in request) { + await play(request?.source, request?.rate, request?.volume); + sendResponse({}); + } else if (request.type === "stopTTSOffscreen") { stopAudio(); - sendResponse(); + sendResponse({}); } })(); diff --git a/src/util/index.js b/src/util/index.js index a4030e64..43b786b3 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -3,9 +3,7 @@ import { parse } from "bcp-47"; import isUrl from "is-url"; import browser from "webextension-polyfill"; import _ from "lodash"; -import matchUrl from "match-url-wildcard"; import { waitUntil, WAIT_FOREVER } from "async-wait-until"; - import { Setting } from "./setting.js"; var defaultData = {