Fix
Fixed it so it says copied to clipboard when you click a image/link Signed-off-by: AvaLilac <amyshimplays@gmail.com>
This commit is contained in:
parent
58088aa094
commit
5c3b0073e2
1 changed files with 26 additions and 4 deletions
|
|
@ -165,6 +165,18 @@ function toggleFavoritesPanel() {
|
|||
}, 2000);
|
||||
}
|
||||
|
||||
function fallbackCopy(text) {
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.value = text;
|
||||
textarea.style.position = "fixed";
|
||||
textarea.style.opacity = "0";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
try { document.execCommand("copy"); } catch {}
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
grid.innerHTML = "";
|
||||
|
|
@ -274,9 +286,19 @@ function toggleFavoritesPanel() {
|
|||
card.appendChild(titleOverlay);
|
||||
}
|
||||
|
||||
card.onclick = async () => {
|
||||
await navigator.clipboard.writeText(item.url);
|
||||
showToast(card);
|
||||
card.onclick = () => {
|
||||
const doToast = () => showToast(card);
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(item.url)
|
||||
.then(doToast)
|
||||
.catch(() => {
|
||||
fallbackCopy(item.url);
|
||||
doToast();
|
||||
});
|
||||
} else {
|
||||
fallbackCopy(item.url);
|
||||
doToast();
|
||||
}
|
||||
};
|
||||
|
||||
grid.appendChild(card);
|
||||
|
|
@ -324,4 +346,4 @@ new MutationObserver(injectButton)
|
|||
|
||||
injectButton();
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue