Fix slowdown when clipboard contains pictures
This commit is contained in:
parent
f5005a877e
commit
e977862e44
|
|
@ -25,6 +25,14 @@ browser.browserAction.onClicked.addListener(() => {
|
||||||
.then(([t]) => toggleTab(t.id))
|
.then(([t]) => toggleTab(t.id))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.onload = () => {
|
||||||
|
document.querySelector("#paste-target").addEventListener("paste", e => {
|
||||||
|
if(e.clipboardData.getData("text/plain") === "") {
|
||||||
|
e.preventDefault() // prevent anything that is not representable as plain text from being pasted
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function toggleTab(id) {
|
function toggleTab(id) {
|
||||||
const index = listeningTabs.indexOf(id)
|
const index = listeningTabs.indexOf(id)
|
||||||
if(index >= 0) {
|
if(index >= 0) {
|
||||||
|
|
@ -57,7 +65,7 @@ function checkClipboard() {
|
||||||
pasteTarget.focus()
|
pasteTarget.focus()
|
||||||
document.execCommand("paste")
|
document.execCommand("paste")
|
||||||
const content = pasteTarget.textContent
|
const content = pasteTarget.textContent
|
||||||
if(content != previousContent) {
|
if(content != previousContent && content != "") {
|
||||||
listeningTabs.forEach(id => notifyForeground(id, content))
|
listeningTabs.forEach(id => notifyForeground(id, content))
|
||||||
previousContent = content
|
previousContent = content
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue