Skip to content

Commit d4aeb97

Browse files
committed
feat(GoogleAutoClickFirstAccountSignIn): bump version to 1.7 and enhance automatic selection logic with improved timeout handling
1 parent 1e91bfa commit d4aeb97

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

GoogleAutoClickFirstAccountSignIn.user.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name Automatically Select First Google Account to Sign In
33
// @namespace typpi.online
4-
// @version 1.6
5-
// @description Selects the first Google account in the Google account selector page
4+
// @version 1.7
5+
// @description Automatically selects the first Google account in the Google account selector page
66
// @author Nick2bad4u
77
// @match https://accounts.google.com/*
88
// @grant none
@@ -17,6 +17,9 @@
1717
(function () {
1818
'use strict';
1919

20+
// Configurable delay for automatic selection (default: 5000ms)
21+
const AUTO_SELECT_DELAY_MS = 5000;
22+
2023
// Function to select the first account
2124
const selectFirstAccount = () => {
2225
const firstAccount = Array.from(document.querySelectorAll('li')).find((el) => el.textContent.includes('@gmail.com'));
@@ -47,6 +50,10 @@
4750

4851
// Automatically run the function after 5 seconds
4952
setTimeout(() => {
50-
selectFirstAccount();
51-
}, 5000);
53+
if (Array.from(document.querySelectorAll('li')).some((el) => el.textContent.includes('@gmail.com'))) {
54+
selectFirstAccount();
55+
} else {
56+
console.log('Account list not loaded within 5 seconds. Skipping automatic selection.');
57+
}
58+
}, AUTO_SELECT_DELAY_MS);
5259
})();

0 commit comments

Comments
 (0)