Skip to content

Instantly share code, notes, and snippets.

@danielhamelberg
Last active January 17, 2020 13:13
Show Gist options
  • Select an option

  • Save danielhamelberg/cacacac2e204de0f6b3fa2613b17caf6 to your computer and use it in GitHub Desktop.

Select an option

Save danielhamelberg/cacacac2e204de0f6b3fa2613b17caf6 to your computer and use it in GitHub Desktop.
A snippet to emphasize the current AWS Console session's account name.
// A native Javascript snippet to display or emphesize the AWS account name in the AWS Console.
// Usage: Runs in your favourite user js browser add-on.
// E.g. 'User JavaScript and CSS' add-on for Chrome/Chromium.
function promoteAccountName() {
if(window.location.href.indexOf("console.aws.amazon.com") > -1) {
// Element containing the account name.
var x = document.getElementById("awsc-login-display-name-account").textContent;
// Elements with text content to manipulate.
var y = document.querySelector("a#nav-usernameMenu div.nav-elt-label");
var z = document.querySelector("head > title");
// Manipulate the elements.
if (x.length > 0) {
y.textContent = x;
z.textContent = "AWS "+x;
}
}
}
// Check DOMContentLoaded didn't fire before our function got a chance to run.
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", promoteAccountName);
} else {
promoteAccountName();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment