Forked from gregory-seidman/expand-sso-aws-login-options.user.js
Last active
March 20, 2024 22:20
-
-
Save hjdarnel/c09cc38f9348f4d5bf8985ff8d42f463 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name AWS SSO Start Page | |
// @version 1.2.0 | |
// @description Expand all account options | |
// @author Gregory Seidman @gregory-seidman | |
// @downloadURL https://gist.github.com/hjdarnel/c09cc38f9348f4d5bf8985ff8d42f463/raw/expand-sso-aws-login-options.user.js | |
// @updateURL https://gist.github.com/hjdarnel/c09cc38f9348f4d5bf8985ff8d42f463/raw/expand-sso-aws-login-options.user.js | |
// @match https://*.awsapps.com/start* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=awsapps.com | |
// @grant none | |
// ==/UserScript== | |
const accountRE = /\d+/im; | |
(function (win) { | |
"use strict"; | |
const doc = win.document; | |
function click(e) { | |
e.click(); | |
} | |
function findAccounts() { | |
return Array.prototype.filter.call( | |
Array.from( | |
doc.querySelectorAll('div[data-testid="account-list"] button') | |
).filter((button) => { | |
const nameDiv = button.querySelector("strong"); | |
return ( | |
nameDiv && | |
["dev", "staging", "prod", "PrivilegeEscalation"].includes( | |
nameDiv.textContent.trim() | |
) | |
); | |
}), | |
(e) => accountRE.test(e.innerText) | |
); | |
} | |
function expandAccounts() { | |
const accounts = findAccounts(); | |
if (!accounts.length) { | |
win.setTimeout(expandAccounts, 100); | |
return; | |
} | |
accounts.forEach(click); | |
} | |
win.setTimeout(expandAccounts, 100); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment