Skip to content

Commit

Permalink
Bugfix for copy to clipboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
cschiller committed Jul 31, 2024
1 parent 22c346a commit de8d9d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
14 changes: 0 additions & 14 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,6 @@ function createTab(url, tabType) {
});
}

chrome.runtime.onMessage.addListener(function (message) {

if (message.type === 'copy') {
let txt = document.createElement('textarea');
txt.style.position = "absolute";
txt.style.left = "-100%";
txt.value = message.data;
document.body.appendChild(txt);
txt.select();
document.execCommand('copy');
document.body.removeChild(txt);
}
});

chrome.runtime.onMessage.addListener(function (message) {

if (message.type === 'add') {
Expand Down
7 changes: 2 additions & 5 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,9 @@ function findPreviousTextNode(root, previous) {
}

function copyToClipboard(data) {
chrome.runtime.sendMessage({
'type': 'copy',
'data': data
navigator.clipboard.writeText(data).then(() => {
showPopup('Copied to clipboard', null, -1, -1);
});

showPopup('Copied to clipboard', null, -1, -1);
}

function makeHtml(result, showToneColors) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Zhongwen: Chinese-English Dictionary",
"short_name": "Zhongwen",
"version": "6.0.0",
"version": "6.1.0",
"author": "Christian Schiller",
"homepage_url": "https://github.com/cschiller/zhongwen",
"description": "Great tool for learning Chinese. Includes links to Chinese Grammar Wiki. Supports adding words to Skritter.",
Expand Down

0 comments on commit de8d9d2

Please sign in to comment.