From 6ca1f1ff4e4716dd94ca978132bb1d64e6496a7c Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 7 Nov 2026 11:56:13 +0100 Subject: [PATCH] README: copy the token with an on-page button Chromium truncates prompt() default values at 2,000 characters, cutting off the ~2,500-character token. The command now adds a 'Click to copy' button whose handler calls navigator.clipboard.writeText; the click supplies the user activation the Clipboard API needs in every browser. The token is also logged as a fallback. Co-authored-by: Cursor --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e112ef6..6c9c312 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,14 @@ The integration needs a one-time verification token from PerfectDraft's website. 3. Paste this command at the console prompt and press **Enter** — once, not as a "Live expression", which re-runs it over and over: ```javascript -grecaptcha.enterprise.execute('6LcZQiUoAAAAAAO3JUjLiT470c-pNXbWyepuvMtV', {action: 'Magento/login'}).then(t => { console.log(t); prompt('PerfectDraft verification token. Press Ctrl+C (Cmd+C on a Mac) to copy it, then OK.', t) }) +grecaptcha.enterprise.execute('6LcZQiUoAAAAAAO3JUjLiT470c-pNXbWyepuvMtV', {action: 'Magento/login'}).then(t => { console.log(t); const b = document.body.appendChild(document.createElement('button')); b.textContent = 'Click to copy your PerfectDraft token'; b.style = 'position:fixed;top:40%;left:50%;transform:translateX(-50%);z-index:2147483647;padding:20px 40px;font-size:22px;background:#000;color:#fff;border-radius:8px;cursor:pointer'; b.onclick = () => navigator.clipboard.writeText(t).then(() => b.textContent = 'Copied! Paste it into Home Assistant', e => b.textContent = 'Copy failed: ' + e.message) }) ``` -4. A dialog opens with the token already selected — press **Ctrl+C** (**Cmd+C** on a Mac), then **OK** +4. A black **Click to copy your PerfectDraft token** button appears in the middle of the page — click it, and it changes to **Copied!** 5. Paste the token into the Home Assistant setup dialog 6. Click **Submit** within 2 minutes (the token expires) -If no dialog appears, the same token is printed in the console: right-click it and choose **Copy** (or select it and copy). +If the button says **Copy failed**, the same token is printed in the console: right-click it there and copy it. That's it! The integration will authenticate and start polling your PerfectDraft Pro. Token refresh is automatic — you should not need to repeat this step. If the session does eventually expire, Home Assistant will prompt you to re-authenticate. (This is a new integration, so the exact session lifespan is still being determined — it's at least 30 days and may well be indefinite.)