|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Automatically Select First Google Account to Sign In |
3 | 3 | // @namespace typpi.online |
4 | | -// @version 1.2 |
| 4 | +// @version 1.3 |
5 | 5 | // @description Selects the first Google account in the Google account selector page |
6 | 6 | // @author Nick2bad4u |
7 | 7 | // @match https://accounts.google.com/* |
|
10 | 10 | // @homepageURL https://github.com/Nick2bad4u/UserStyles |
11 | 11 | // @supportURL https://github.com/Nick2bad4u/UserStyles/issues |
12 | 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 |
| 13 | +// @downloadURL https://update.greasyfork.org/scripts/531639/Automatically%20Select%20First%20Google%20Account%20to%20Sign%20In.user.js |
| 14 | +// @updateURL https://update.greasyfork.org/scripts/531639/Automatically%20Select%20First%20Google%20Account%20to%20Sign%20In.meta.js |
15 | 15 | // ==/UserScript== |
16 | 16 |
|
17 | | -(function() { |
| 17 | +(function () { |
18 | 18 | 'use strict'; |
19 | 19 |
|
20 | 20 | // Function to select the first account |
21 | 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 | | - } |
| 22 | + const firstAccount = document.querySelector('li.aZvCDf'); |
| 23 | + if (firstAccount) { |
| 24 | + const firstLink = firstAccount.querySelector('div[role="link"]'); |
| 25 | + if (firstLink) { |
| 26 | + firstLink.click(); |
30 | 27 | } else { |
31 | | - console.log('First account not found on the page.'); |
| 28 | + console.log('First account link not found.'); |
32 | 29 | } |
| 30 | + } else { |
| 31 | + console.log('First account not found on the page.'); |
| 32 | + } |
33 | 33 | }; |
34 | 34 |
|
35 | 35 | // Set up a MutationObserver to wait for dynamic content |
36 | 36 | const observer = new MutationObserver(() => { |
37 | | - if (document.querySelector('li.aZvCDf')) { |
38 | | - selectFirstAccount(); |
39 | | - observer.disconnect(); // Stop observing once the element is found |
40 | | - } |
| 37 | + if (document.querySelector('li.aZvCDf')) { |
| 38 | + selectFirstAccount(); |
| 39 | + observer.disconnect(); // Stop observing once the element is found |
| 40 | + } |
41 | 41 | }); |
42 | 42 |
|
43 | 43 | // Observe changes in the document body |
|
0 commit comments