Skip to content
\n
\n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n\n \n \n \n \n
function pasteCode(code: string) {
const _inputBoxes = document.getElementsByTagName(\"input\");
const inputBoxes: HTMLInputElement[] = [];
for (let i = 0; i < _inputBoxes.length; i++) {
if (
_inputBoxes[i].type === \"text\" ||
_inputBoxes[i].type === \"number\" ||
_inputBoxes[i].type === \"tel\" ||
_inputBoxes[i].type === \"password\"
) {
inputBoxes.push(_inputBoxes[i]);
}
}
if (!inputBoxes.length) {
return;
}
const identities = [
\"2fa\",
\"otp\",
\"authenticator\",
\"factor\",
\"code\",
\"totp\",
\"twoFactorCode\",
];
for (const inputBox of inputBoxes) {
for (const identity of identities) {
if (
inputBox.name.toLowerCase().indexOf(identity) >= 0 ||
inputBox.id.toLowerCase().indexOf(identity) >= 0
) {
if (!inputBox.value || /^(\\d{6}|\\d{8})$/.test(inputBox.value)) {
inputBox.value = code;
fireInputEvents(inputBox);
}
return;
}
}
}
\n
\n
\n

","upvoteCount":1,"url":"https://github.com/Authenticator-Extension/Authenticator/discussions/1364#discussioncomment-11857875"}}}

Auto copy to text box? #1364

Closed Answered by mymindstorm
Connor9220 asked this question in Q&A
Jan 16, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Here's our logic for autofill:

function pasteCode(code: string) {
const _inputBoxes = document.getElementsByTagName("input");
const inputBoxes: HTMLInputElement[] = [];
for (let i = 0; i < _inputBoxes.length; i++) {
if (
_inputBoxes[i].type === "text" ||
_inputBoxes[i].type === "number" ||
_inputBoxes[i].type === "tel" ||
_inputBoxes[i].type === "password"
) {
inputBoxes.push(_inputBoxes[i]);
}
}
if (!inputBoxes.length) {
return;
}
const identities = [
"2fa",
"otp",
"authenticator",
"factor",
"code",
"totp",
"…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Connor9220
Comment options

Answer selected by mymindstorm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants