Skip to content

Instantly share code, notes, and snippets.

@jamesinc
Last active February 7, 2024 22:20
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jamesinc/7623301b9acc94b54dd73f4f5ddacb55 to your computer and use it in GitHub Desktop.
Save jamesinc/7623301b9acc94b54dd73f4f5ddacb55 to your computer and use it in GitHub Desktop.
AWS console notification dismisserator 9000 - dismiss AWS flash notifications after (about) 5 seconds
// ==UserScript==
// @name AWS console notification dismisserator 9000
// @namespace https://github.com/jamesinc
// @version 1.1
// @description Dismiss AWS flash notifications after about 5 seconds
// @author James Ducker
// @match https://*.console.aws.amazon.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(() => {
// How long, in milliseconds, to display the notification before auto-hiding it.
const FLASH_HIDE_MS = 5000;
let dismissNotifications = ( ) => {
// Find alerts
let container = document.querySelectorAll("div[awsui-app-layout-region='notifications']")[0];
if (!container) return;
let notifications = container.querySelectorAll("awsui-flash");
for ( let flash of notifications ) {
// Make sure we only run this badboy once for each notification
if ( ! flash.hasAttribute("dismissed") ) {
// Mark this notification as dismissed
flash.setAttribute("dismissed", "dismissed");
// Do a bit of scope magic
setTimeout(((item) => {
return () => {
// Trigger click event on button node
let closeButton = item.querySelectorAll("button.awsui-button")[0];
// P U S H T H E B U T T O N
closeButton.dispatchEvent(new Event('click'));
}
})(flash), FLASH_HIDE_MS);
}
}
}
// Scan for new notifications once per second
setInterval(dismissNotifications, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment