Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjdarnel/c09cc38f9348f4d5bf8985ff8d42f463 to your computer and use it in GitHub Desktop.
Save hjdarnel/c09cc38f9348f4d5bf8985ff8d42f463 to your computer and use it in GitHub Desktop.
// ==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