Skip to content

Instantly share code, notes, and snippets.

@a2intl
Last active November 16, 2019 06:06
Show Gist options
  • Save a2intl/7c97cf7a19511ec1df76454d7e202eeb to your computer and use it in GitHub Desktop.
Save a2intl/7c97cf7a19511ec1df76454d7e202eeb to your computer and use it in GitHub Desktop.
add a search box to the top of long (>10 items) popups in AWS Console, like the CloudFront Distribution List in Reports & Analytics
// ==UserScript==
// @name AWS Console Popup Search
// @namespace http://tampermonkey.net/
// @version 0.1
// @description add a search box to the top of long (>10 items) popups in AWS Console, like the CloudFront Distribution List in Reports & Analytics
// @author Andrew Allen https://github.com/a2intl
// @match https://console.aws.amazon.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var obs = new MutationObserver(function(mutations, observer) {
for(let mut of mutations) {
for(let newnode of mut.addedNodes) {
if(!newnode.mySearch && newnode.classList && newnode.classList.contains("gwt-PopupPanel")) {
var popups=newnode.getElementsByClassName("popupContent");
for(let el of popups) {
if(el.getElementsByTagName('tr').length>10) {
let d=document.createElement('input');
newnode.mySearch=d;
d.className='gwt-MenuItem mySearch';
d.style.visibility='visible';
d.style.width='100%';
d.placeholder='search list';
d.onkeyup = function(e) {
var v=d.value;
for(let td of el.getElementsByTagName('td')) {
if(v==='' || td.innerHTML.indexOf(v)>=0) {
td.parentElement.style.display='';
} else {
td.parentElement.style.display='none';
}
}
}
el.firstChild.insertBefore(d,el.firstChild.firstChild);
}
}
}
}
for(let delnode of mut.removedNodes) {
if(delnode.mySearch) {
let d=delnode.mySearch;
d.value='';
d.onkeyup();
}
}
}
});
obs.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