Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sheldonhull/ac08df873e9501c949b22e112f4d93b8 to your computer and use it in GitHub Desktop.
Save sheldonhull/ac08df873e9501c949b22e112f4d93b8 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name AWS - Cloudwatch - Remove Insights Trial Banner
// @namespace https://github.com/david-duncan
// @version 0.1
// @description AWS cloudwatch has an annoying insights trial banner that pops up everytime. This removes it permanently
// @author David Duncan
// @grant none
// @match https://console.aws.amazon.com/cloudwatch/*
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
var retries = 0;
function clearButton() {
// we find a try button, because i'm assuming AWS is using styled components and the class names are unstable
var tryButton = document.getElementById('gwt-debug-tryNowButton');
if (tryButton) {
// go a few levels up
var firstParent = tryButton.parentNode;
if (firstParent) {
var secondParent = firstParent.parentNode;
if (secondParent) {
var thirdParent = secondParent.parentNode;
if (thirdParent) {
thirdParent.remove();
window.dispatchEvent( new Event("resize") );
}
}
}
} else {
// didnt find our button, page is loading slowly or it doesnt exist, bump retries, and try a few more times...
retries ++;
if (retries < 3) {
setTimeout(clearButton, 5000);
}
}
}
setTimeout(clearButton, 5000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment