Skip to content

Commit 39fa0e4

Browse files
authored
Overwrite 2FA input box if it has old code
#580
1 parent 6e00097 commit 39fa0e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function pasteCode(code: string) {
225225
inputBox.name.toLowerCase().indexOf(identity) >= 0 ||
226226
inputBox.id.toLowerCase().indexOf(identity) >= 0
227227
) {
228-
if (!inputBox.value) {
228+
if (!inputBox.value || /^(\d{6}|\d{8})$/.test(inputBox.value)) {
229229
inputBox.value = code;
230230
fireInputEvents(inputBox);
231231
}
@@ -240,15 +240,15 @@ function pasteCode(code: string) {
240240
: null;
241241
if (activeInputBox) {
242242
const inputBox = activeInputBox as HTMLInputElement;
243-
if (!inputBox.value) {
243+
if (!inputBox.value || /^(\d{6}|\d{8})$/.test(inputBox.value)) {
244244
inputBox.value = code;
245245
fireInputEvents(inputBox);
246246
}
247247
return;
248248
}
249249

250250
for (const inputBox of inputBoxes) {
251-
if (!inputBox.value && inputBox.type !== "password") {
251+
if ((!inputBox.value || /^(\d{6}|\d{8})$/.test(inputBox.value)) && inputBox.type !== "password") {
252252
inputBox.value = code;
253253
fireInputEvents(inputBox);
254254
return;

0 commit comments

Comments
 (0)