Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thunder-spb/44a2b2f70e08f66d8543757fe2dd7427 to your computer and use it in GitHub Desktop.
Save thunder-spb/44a2b2f70e08f66d8543757fe2dd7427 to your computer and use it in GitHub Desktop.
AWS-Shortlinks
// ==UserScript==
// @name AWS short labels safe
// @namespace http://tampermonkey.net/
// @version 0.2
// @match https://*.console.aws.amazon.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const replacements = {
"Elastic Kubernetes Service": "EKS",
"Amazon DocumentDB": "DocDB",
"Aurora and RDS": "RDS",
"Elacticache": "OS",
"Amazon OpenSearch Service": "OpenSearch",
"Secrets Manager": "Secrets",
"Simple Queue Service": "SQS",
"Resource Groups & Tag Editor": "RG/Tags",
"Billing and Cost Management": "Billing",
"AWS CloudFormation": "CloudFormation",
"CloudWatch": "CW",
"CloudFront": "CF",
"API Gateway": "APIGW",
"IAM Identity Center": "IAMIC",
"ElastiCache": "Redis",
"AWS CloudTrail": "CloudTrail",
"AWS CodeBuild": "CodeBuild",
"AWS CodePipeline": "CodePipeline",
"AWS CodeDeploy": "CodeDeploy",
"AWS Lambda": "Lambda",
"AWS Step Functions": "Step Functions",
"AWS Systems Manager": "SSM",
"AWS Transfer Family": "Transfer",
"Elastic Load Balancing": "ELB",
"Amazon Elastic File System": "EFS",
"Amazon Elastic Block Store": "EBS",
"Amazon Simple Queue Service": "SQS",
"Amazon Simple Notification Service": "SNS",
"Amazon API Gateway": "API Gateway",
"AWS Identity and Access Management": "IAM",
"AWS Key Management Service": "KMS",
"Amazon CloudWatch": "CloudWatch",
"Amazon Route 53": "Route 53",
"Amazon Virtual Private Cloud": "VPC",
"AWS Certificate Manager": "ACM",
"Amazon Cognito": "Cognito"
};
function replaceText(node) {
if (node.nodeType === Node.TEXT_NODE) {
let text = node.textContent;
for (let orig in replacements) {
if (text.includes(orig)) {
text = text.replace(orig, replacements[orig]);
}
}
node.textContent = text;
} else {
node.childNodes.forEach(replaceText);
}
}
function processHeader() {
const headerSelectors = [
'[data-testid="awsc-nav-header"]',
'.awsc-nav-header',
'header',
'[role="banner"]',
'.awsui-header',
'#awsc-nav-header'
];
let header = null;
for (let selector of headerSelectors) {
header = document.querySelector(selector);
if (header) break;
}
if (header) {
replaceText(header);
}
}
processHeader();
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
const headerSelectors = [
'[data-testid="awsc-nav-header"]',
'.awsc-nav-header',
'header',
'[role="banner"]',
'.awsui-header',
'#awsc-nav-header'
];
for (let selector of headerSelectors) {
if (node.closest && node.closest(selector)) {
replaceText(node);
break;
}
}
}
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment