-
-
Save tteskac/a15c66bb46048137751b424e1edc7375 to your computer and use it in GitHub Desktop.
TamperMonkey: Hide AWS regions from dropdown menu.
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 ScreenCloud AWS: region dropdown cleanup | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @author wolf@screencloud.io | |
// @include https://*.console.aws.amazon.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// fill in the regions you're actually interested in | |
const regions = [ | |
{ id: "us-east-1" }, | |
{ id: "eu-west-1" }, | |
{ id: "eu-central-1" }, | |
]; | |
// work horse | |
const fix = (menuNode) => { | |
menuNode.childNodes.forEach((liNode) => { | |
// hide dividers | |
if (!liNode.childNodes[0]) { | |
liNode.style.display = 'none'; | |
return; | |
} | |
const liRegion = liNode.childNodes[0].getAttribute("data-region-id"); | |
const region = regions.find((r) => r.id === liRegion); | |
console.log({ liRegion, ...region }); | |
// remove? | |
if (!region) { | |
console.log(`hiding region: ${liRegion}`); | |
liNode.style.display = 'none'; | |
} else { | |
console.log(`keeping region: ${liRegion}`); | |
} | |
}); | |
console.log('all done'); | |
}; | |
// simple check function to see if html was rendered | |
const interval = setInterval(() => { | |
const menuNode = document.getElementById("menu--regions"); | |
if (!menuNode) { | |
console.log("menuNode not found (yet...)"); | |
return; | |
} | |
if (menuNode.childNodes.length == 0) { | |
//console.log("menuNode found but no items yet..."); | |
return; | |
} | |
console.log("menuNode found!"); | |
clearInterval(interval); | |
fix(menuNode); | |
}, 250); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment