Debian Codegraph @

chrome-extension/capture.js

raw
1 // Read auth code from URL parameters
2 const params = new URLSearchParams(window.location.search);
3 const code = params.get("code");
4
5 if (code) {
6 document.getElementById("success").style.display = "block";
7 // Mask the code, showing only last 4 characters
8 const masked = "•".repeat(Math.max(0, code.length - 4)) + code.slice(-4);
9 document.getElementById("authCode").textContent = masked;
10 } else {
11 document.getElementById("noCode").style.display = "block";
12 }
13
14 // Copy handler
15 document.getElementById("copyCode").addEventListener("click", async () => {
16 await navigator.clipboard.writeText(code);
17 const toast = document.getElementById("toast");
18 toast.classList.add("show");
19 setTimeout(() => toast.classList.remove("show"), 2000);
20 });