From 75541a0764accce5af078f376e509c068028b491 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 26 Apr 2025 11:23:20 +0200 Subject: [PATCH] copy to clipboard instead of downloading an image --- index.html | 2 +- main.ts | 20 ++++++++++++++------ team-leader.html | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 684c642..0d13844 100644 --- a/index.html +++ b/index.html @@ -161,7 +161,7 @@

Screenshot the house: - +

diff --git a/main.ts b/main.ts index 33b33b6..4ccf5cd 100644 --- a/main.ts +++ b/main.ts @@ -83,12 +83,20 @@ const screenshotHouseButton = document.querySelector('#screenshot-house') if (screenshotHouseButton) { screenshotHouseButton.addEventListener('click', async () => { const house = document.querySelector('#thinking-people-system') - if (house) { - const png = await domToPng(house) - const a = document.createElement('a') - a.href = png - a.download = 'thinking-people-system.png' - a.click() + if (!house) { + return + } + + const png = await domToPng(house) + + try { + const response = await fetch(png) + const blob = await response.blob() + await navigator.clipboard.write([ + new ClipboardItem({ [blob.type]: blob }) + ]) + } catch (error) { + console.warn(error) } }) } diff --git a/team-leader.html b/team-leader.html index d722b50..be07cce 100644 --- a/team-leader.html +++ b/team-leader.html @@ -152,7 +152,7 @@

Screenshot the house: - +