Skip to content

Commit 0ebe15d

Browse files
committed
Copy tokens to clipboard
1 parent 67de74c commit 0ebe15d

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

templates/info.html

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
--bs-nav-pills-link-active-bg: var(--main-color);
8686
--bs-link-hover-color: var(--main-color);
8787
}
88+
.hover-text:hover {
89+
cursor: pointer; /* Cambia el icono del mouse a un click */
90+
text-decoration: underline; /* Subraya el texto */
91+
color: #8fdf6c;
92+
}
8893
</style>
8994
</head>
9095
<body>
@@ -155,7 +160,7 @@
155160
</tr>
156161
</thead>
157162
<tbody>
158-
<tr><td style='word-break:break-word;white-space:pre-wrap;-moz-white-space:pre-wrap;'>{{access_token}}</td></tr>
163+
<tr><td style='word-break:break-word;white-space:pre-wrap;-moz-white-space:pre-wrap;' onclick="copyTextToClipboard(this)" class="hover-text">{{access_token}}</td></tr>
159164
<tr id="accessTokenSecondRow"><td>View in <a href='https://jwt.io/#token={{access_token}}' target='_blank'>https://jwt.io/</a></td></tr>
160165
</tbody>
161166
</table>
@@ -168,7 +173,7 @@
168173
</tr>
169174
</thead>
170175
<tbody>
171-
<tr><td style='word-break:break-word;white-space:pre-wrap;-moz-white-space:pre-wrap;'>{{refresh_token}}</td></tr>
176+
<tr><td style='word-break:break-word;white-space:pre-wrap;-moz-white-space:pre-wrap;' onclick="copyTextToClipboard(this)" class="hover-text">{{refresh_token}}</td></tr>
172177
<tr id="refreshTokenSecondRow"><td>View in <a href='https://jwt.io/#token={{refresh_token}}' target='_blank'>https://jwt.io/</a></td></tr>
173178
</tbody>
174179
</table>
@@ -244,6 +249,25 @@
244249
if (refreshToken === "Not Provided in token endpoint response") {
245250
document.getElementById("refreshTokenSecondRow").style.display = "none";
246251
}
252+
253+
function copyTextToClipboard(input) {
254+
//* Solo funciona con HTTPS
255+
// let copyText = input.textContent || input.innerText;
256+
// navigator.clipboard.writeText(copyText)
257+
258+
//* Para HTTP
259+
let copyText = input.textContent || input.innerText;
260+
let tempInput = document.createElement("textarea");
261+
tempInput.value = copyText;
262+
document.body.appendChild(tempInput);
263+
264+
// Seleccionar el texto dentro del campo temporal
265+
tempInput.select();
266+
// Ejecutar el comando de copiar
267+
document.execCommand("copy");
268+
// Remover el campo temporal
269+
document.body.removeChild(tempInput);
270+
}
247271
</script>
248272
</body>
249273
</html>

0 commit comments

Comments
 (0)