Last active
March 11, 2024 21:28
-
-
Save gregory-seidman/69be84cdd286dd5459cccde10a570ae4 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 | |
// @namespace https://gist.github.com/gregory-seidman/dd8b7a93f4603ef3e484c82d45809a95 | |
// @version 1.1.3 | |
// @description Expand all account options | |
// @author Gregory Seidman | |
// @downloadURL https://gist.github.com/gregory-seidman/69be84cdd286dd5459cccde10a570ae4/raw/expand-sso-aws-login-options.user.js | |
// @updateURL https://gist.github.com/gregory-seidman/69be84cdd286dd5459cccde10a570ae4/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 appRE = /aws\s+account/mi; | |
const accountRE = /#\d+/mi; | |
(function(win) { | |
'use strict'; | |
const doc = win.document; | |
function click(e) { e.click(); } | |
function findAwsAccountApps() { | |
return Array.prototype.filter.call( | |
doc.getElementsByTagName('portal-application'), | |
e => appRE.test(e.innerText)); | |
} | |
function findAccounts() { | |
return Array.prototype.filter.call( | |
doc.querySelectorAll('sso-expander portal-instance .instance-section'), | |
e => accountRE.test(e.innerText)); | |
} | |
function expandAccounts() { | |
const accounts = findAccounts(); | |
if (!accounts.length) { | |
win.setTimeout(expandAccounts, 100); | |
return; | |
} | |
accounts.forEach(click); | |
} | |
function expandApps() { | |
const apps = findAwsAccountApps(); | |
if (!apps.length) { | |
win.setTimeout(expandApps, 100); | |
return; | |
} | |
apps.forEach(click); | |
win.setTimeout(expandAccounts, 100); | |
} | |
expandApps(); | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment