Skip to content

Instantly share code, notes, and snippets.

@MartiUK
Last active November 6, 2019 12:34
Show Gist options
  • Save MartiUK/d04e34b00c58793c78bab297b2d43ddf to your computer and use it in GitHub Desktop.
Save MartiUK/d04e34b00c58793c78bab297b2d43ddf to your computer and use it in GitHub Desktop.
Places the account name/number for your aws account in the console nav bar, useful if you have to switch between different accounts often
// ==UserScript==
// @name AWS Console - Account Name in Nav Bar
// @namespace https://www.martinke.mp
// @version 1.0
// @description Adds the Account Name in Nav Bar
// @author @martiuk
// @match https://*.console.aws.amazon.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var acctName = "";
if (document.querySelector("#awsc-role-display-name-account") != null) {
acctName = document.querySelector("#awsc-role-display-name-account").getAttribute("title");
}
else {
acctName = document.querySelector("#awsc-login-display-name-account").getAttribute("title");
}
var navBell = document.querySelector("#nav-phd");
var menuSep = document.createElement("div")
menuSep.setAttribute("class", "nav-menu-separator");
var newNode = document.createElement("div")
newNode.setAttribute("class", "nav-elt nav-menu");
var nNC = document.createElement("b")
nNC.setAttribute("class", "nav-elt-label");
var emB = document.createElement("b")
emB.appendChild(document.createTextNode(acctName));
nNC.appendChild(emB);
newNode.appendChild(nNC);
navBell.parentNode.insertBefore(newNode, navBell.nextSibling);
navBell.parentNode.insertBefore(menuSep, navBell.nextSibling);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment