Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sheldonhull/aeda3d7b9c0dd2bb12ab662dfeedafc6 to your computer and use it in GitHub Desktop.
Save sheldonhull/aeda3d7b9c0dd2bb12ab662dfeedafc6 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.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);
})();
@jamesinc
Copy link

jamesinc commented Feb 7, 2024

Hello, I have patched this with v1.1 that fixes a console error message, see https://gist.github.com/jamesinc/7623301b9acc94b54dd73f4f5ddacb55#file-aws-notification-timer-user-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment