Skip to content

Commit

Permalink
fix: Copy Vocabulary错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon406 committed Dec 27, 2024
1 parent dac0ac6 commit 191c53e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"dompurify": "^3.1.5",
"dompurify": "^3.2.3",
"file-saver": "^2.0.5",
"lru-cache": "^10.2.2"
}
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "zh_CN",
"version": "0.10.1",
"version": "0.10.2",
"icons": {
"48": "assets/result48.png",
"128": "assets/icon_128.png"
Expand Down
16 changes: 8 additions & 8 deletions src/context_menu_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ function openUrl(url) {
}

function copy_vocabulary() {
const voca = Array.from(
new Set(
Array.from(document.querySelectorAll('wdhl[lemma]')).map((ele) =>
ele.getAttribute('lemma'),
),
),
).join('\r\n')

let vocabularies = [...new Set(
[...document.querySelectorAll('wdhl:not(.wdhl_none_none)')]
.map(ele => ele.getAttribute('lemma'))
)]
if (!vocabularies.length) return
const voca = vocabularies.join('\n');
const textArea = document.createElement('textarea')
textArea.value = voca
textArea.style.position = 'fixed'
Expand All @@ -204,7 +204,7 @@ function copy_vocabulary() {
textArea.select()
document.execCommand('copy')
document.body.removeChild(textArea)
alert('Copied')
alert(`${vocabularies.length} Copied`)
}

export function showDefinition(dictUrl, text) {
Expand Down

0 comments on commit 191c53e

Please sign in to comment.