Last active
July 22, 2023 13:54
-
-
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.
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 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; }'); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It also replaces the user-id in the dropdown with
stage/production