Skip to content

Commit 1e91bfa

Browse files
committed
feat(GoogleAutoClickFirstAccountSignIn): bump version to 1.6 and enhance error logging for account selection
1 parent 1461d8c commit 1e91bfa

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

GoogleAutoClickFirstAccountSignIn.user.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Automatically Select First Google Account to Sign In
33
// @namespace typpi.online
4-
// @version 1.5
4+
// @version 1.6
55
// @description Selects the first Google account in the Google account selector page
66
// @author Nick2bad4u
77
// @match https://accounts.google.com/*
@@ -19,22 +19,24 @@
1919

2020
// Function to select the first account
2121
const selectFirstAccount = () => {
22-
const firstAccount = Array.from(document.querySelectorAll('li')).find(el => el.textContent.includes('@gmail.com'));
22+
const firstAccount = Array.from(document.querySelectorAll('li')).find((el) => el.textContent.includes('@gmail.com'));
2323
if (firstAccount) {
2424
const firstLink = firstAccount.querySelector('div[role="link"]');
2525
if (firstLink) {
2626
firstLink.click();
2727
} else {
28-
console.log('First account link not found. This might be due to changes in the page structure or the account list not being fully loaded.');
28+
console.log(
29+
'First account link not found. Ensure the page contains a <li> element with a child <div> having role="link". This might be due to changes in the page structure or the account list not being fully loaded.',
30+
);
2931
}
3032
} else {
31-
console.log('First account not found on the page. Waiting for the element to load dynamically...');
33+
console.log('First account not found on the page. Waiting for the element to load dynamically via MutationObserver...');
3234
}
3335
};
3436

3537
// Set up a MutationObserver to wait for dynamic content
3638
const observer = new MutationObserver(() => {
37-
if (document.querySelector('li.aZvCDf')) {
39+
if (Array.from(document.querySelectorAll('li')).some((el) => el.textContent.includes('@gmail.com'))) {
3840
selectFirstAccount();
3941
observer.disconnect(); // Stop observing once the element is found
4042
}

0 commit comments

Comments
 (0)