Skip to content

Instantly share code, notes, and snippets.

@jordiclariana
Last active May 28, 2021 16:14
Show Gist options
  • Save jordiclariana/37e412146913a2b8e836ee13f95961c0 to your computer and use it in GitHub Desktop.
Save jordiclariana/37e412146913a2b8e836ee13f95961c0 to your computer and use it in GitHub Desktop.
Greeasemonkey/Tampermonkey script to change the logged in title to show simplify and show the account
// ==UserScript==
// @name AWS Console menu SSO role and account setter
// @version 1.0
// @include /^https?://(.+\.)?console.aws.amazon.com/.*$/
// @run-at document-end
// @grant none
// @icon https://www.google.com/s2/favicons?domain=amazon.com
// ==/UserScript==
const regex = /AWSReservedSSO_([^_]+)_[^/]+\/([^ ]+).*@ (.*)/;
var title = document.getElementById("nav-usernameMenu").childNodes[0].childNodes[1].title;
var matches = title.match(regex);
var accountNumber = document.querySelectorAll(`[data-testid*="aws-my-account-details"]`)[0].innerText;
document.getElementById("nav-usernameMenu").childNodes[0].childNodes[1].textContent = `SSO ${matches[1]}/${matches[2]} @ ${matches[3]} (${accountNumber})`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment