Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.0
// @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==
(() => {
let container = document.querySelectorAll("div[awsui-app-layout-region='notifications']")[0];
let dismissNotifications = ( ) => {
// Find alerts
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", "...duh (spooky minimalist synth melody)");
// Do a bit of scope magic
setTimeout(((item) => {
return () => {
// Trigger click event on button node
let closeButton = item.querySelectorAll("button.awsui-button")[0];
// Create an event
// For more help with creating events, see facebook.com/events
let clickyBoi = new Event('click');
// P U S H T H E B U T T O N
closeButton.dispatchEvent(clickyBoi);
}
})(flash), 5000);
}
}
}
// 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