Skip to content

Commit 4c3f077

Browse files
committed
Update user scripts to improve Google sign-in functionality and account selection
1 parent f1d69cc commit 4c3f077

2 files changed

Lines changed: 52 additions & 48 deletions

File tree

GoogleAutoClickFirstAccountSignIn.user.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
// ==UserScript==
2-
// @name Auto Click Google Sign-In Button
2+
// @name Automatically Select First Google Account to Sign In
33
// @namespace typpi.online
4-
// @version 1.1
5-
// @description Automatically clicks the Google sign-in button on the page
4+
// @version 1.2
5+
// @description Selects the first Google account in the Google account selector page
66
// @author Nick2bad4u
7-
// @match https://www.strava.com/login
7+
// @match https://accounts.google.com/*
88
// @grant none
99
// @license Unlicense
1010
// @homepageURL https://github.com/Nick2bad4u/UserStyles
1111
// @supportURL https://github.com/Nick2bad4u/UserStyles/issues
12-
// @icon https://www.google.com/s2/favicons?sz=64&domain=strava.com
12+
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
13+
// @downloadURL https://update.greasyfork.org/scripts/531638/Automatically%20Select%20First%20Google%20Account%20to%20Sign%20In.user.js
14+
// @updateURL https://update.greasyfork.org/scripts/531638/Automatically%20Select%20First%20Google%20Account%20to%20Sign%20In.meta.js
1315
// ==/UserScript==
1416

1517
(function() {
1618
'use strict';
1719

18-
// Function to find and click the Google sign-in button
19-
const clickGoogleSignIn = () => {
20-
const buttons = Array.from(document.querySelectorAll('button, a')); // Get all buttons and links
21-
const googleButton = buttons.find(btn => btn.innerText.includes('Sign In With Google'));
22-
if (googleButton) {
23-
googleButton.click();
20+
// Function to select the first account
21+
const selectFirstAccount = () => {
22+
const firstAccount = document.querySelector('li.aZvCDf');
23+
if (firstAccount) {
24+
const firstLink = firstAccount.querySelector('div[role="link"]');
25+
if (firstLink) {
26+
firstLink.click();
27+
} else {
28+
console.log('First account link not found.');
29+
}
2430
} else {
25-
console.log('Google Sign-In button not found.');
31+
console.log('First account not found on the page.');
2632
}
2733
};
2834

29-
// Use MutationObserver to wait for the button if the page loads dynamically
35+
// Set up a MutationObserver to wait for dynamic content
3036
const observer = new MutationObserver(() => {
31-
const buttons = Array.from(document.querySelectorAll('button, a'));
32-
const googleButton = buttons.find(btn => btn.innerText.includes('Sign In With Google'));
33-
if (googleButton) {
34-
clickGoogleSignIn();
35-
observer.disconnect(); // Stop observing once the button is found and clicked
37+
if (document.querySelector('li.aZvCDf')) {
38+
selectFirstAccount();
39+
observer.disconnect(); // Stop observing once the element is found
3640
}
3741
});
3842

StravaAutoGoogleSignIn.user.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
// ==UserScript==
2-
// @name Automatically Select First Google Account to Sign In
2+
// @name Auto Click Google Sign-In Button
33
// @namespace typpi.online
4-
// @version 1.1
5-
// @description Selects the first Google account in the Google account selector page
4+
// @version 1.2
5+
// @description Automatically clicks the Google sign-in button on the page
66
// @author Nick2bad4u
7-
// @match https://accounts.google.com/*
7+
// @match https://www.strava.com/login
88
// @grant none
99
// @license Unlicense
1010
// @homepageURL https://github.com/Nick2bad4u/UserStyles
1111
// @supportURL https://github.com/Nick2bad4u/UserStyles/issues
12-
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
12+
// @icon https://www.google.com/s2/favicons?sz=64&domain=strava.com
13+
// @downloadURL https://update.greasyfork.org/scripts/531639/Auto%20Click%20Google%20Sign-In%20Button.user.js
14+
// @updateURL https://update.greasyfork.org/scripts/531639/Auto%20Click%20Google%20Sign-In%20Button.meta.js
1315
// ==/UserScript==
1416

15-
(function() {
16-
'use strict';
17+
(function () {
18+
'use strict';
1719

18-
// Function to select the first account
19-
const selectFirstAccount = () => {
20-
const firstAccount = document.querySelector('li.aZvCDf');
21-
if (firstAccount) {
22-
const firstLink = firstAccount.querySelector('div[role="link"]');
23-
if (firstLink) {
24-
firstLink.click();
25-
} else {
26-
console.log('First account link not found.');
27-
}
28-
} else {
29-
console.log('First account not found on the page.');
30-
}
31-
};
20+
// Function to find and click the Google sign-in button
21+
const clickGoogleSignIn = () => {
22+
const buttons = Array.from(document.querySelectorAll('button, a')); // Get all buttons and links
23+
const googleButton = buttons.find((btn) => btn.innerText.includes('Sign In With Google'));
24+
if (googleButton) {
25+
googleButton.click();
26+
} else {
27+
console.log('Google Sign-In button not found.');
28+
}
29+
};
3230

33-
// Set up a MutationObserver to wait for dynamic content
34-
const observer = new MutationObserver(() => {
35-
if (document.querySelector('li.aZvCDf')) {
36-
selectFirstAccount();
37-
observer.disconnect(); // Stop observing once the element is found
38-
}
39-
});
31+
// Use MutationObserver to wait for the button if the page loads dynamically
32+
const observer = new MutationObserver(() => {
33+
const buttons = Array.from(document.querySelectorAll('button, a'));
34+
const googleButton = buttons.find((btn) => btn.innerText.includes('Sign In With Google'));
35+
if (googleButton) {
36+
clickGoogleSignIn();
37+
observer.disconnect(); // Stop observing once the button is found and clicked
38+
}
39+
});
4040

41-
// Observe changes in the document body
42-
observer.observe(document.body, { childList: true, subtree: true });
41+
// Observe changes in the document body
42+
observer.observe(document.body, { childList: true, subtree: true });
4343
})();

0 commit comments

Comments
 (0)