Skip to content

Instantly share code, notes, and snippets.

@BoKKeR
Last active July 22, 2023 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BoKKeR/20f033ea049bd1245d13da55e2ce79d4 to your computer and use it in GitHub Desktop.
Save BoKKeR/20f033ea049bd1245d13da55e2ce79d4 to your computer and use it in GitHub Desktop.
Tampermonkey/Greasemonkey script to change AWS ID and navbar color based on the aws user id.
// ==UserScript==
// @name Rewrite user id to stage/prod in AWS
// @match https://*.console.aws.amazon.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant none
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
(function () {
// Just to tell the linter that $ is defined in jquery
/* global $ */
const stageId = "0080-1443-yourid"
const prodId = "1145-5743-yourid"
const spanEl = document.querySelectorAll('span');
let i = spanEl.length;
while (i--) {
if (spanEl[i].textContent === stageId) {
spanEl[i].textContent = 'STAGE';
addGlobalStyle('nav[class*="globalNav"] { background-color: #D2691E !important; }');
}
if (spanEl[i].textContent === prodId) {
spanEl[i].textContent = 'PRODUCTION';
addGlobalStyle('nav[class*="globalNav"] { background-color: #000080 !important; }');
}
}
})();
@BoKKeR
Copy link
Author

BoKKeR commented Mar 15, 2023

image
image

It also replaces the user-id in the dropdown with stage/production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment