diff --git a/manifest.json b/manifest.json index 920b227..1775eba 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "AWS Extend Switch Roles", - "version": "0.9.0", + "version": "0.10.0", "description": "Extend your AWS IAM switching roles. You can set the configuration like aws config format", "short_name": "Extend SwitchRole", "permissions": ["storage"], diff --git a/manifest_firefox.json b/manifest_firefox.json index bc380f4..2b749b5 100644 --- a/manifest_firefox.json +++ b/manifest_firefox.json @@ -1,5 +1,5 @@ { - "version": "0.9.1", + "version": "0.10.0", "applications": { "gecko": { "id": "aws-extend-switch-roles@toshi.tilfin.com", diff --git a/package.json b/package.json index 15d5c43..23892bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aws-extend-switch-roles", - "version": "0.8.1", + "version": "0.10.0", "description": "Extend your AWS IAM switching roles by Chrome extension", "main": "index.js", "directories": { diff --git a/src/lib/content.js b/src/lib/content.js index 7fcec2b..0a1cb34 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -152,6 +152,42 @@ function loadProfiles(profile, list, csrf, hidesHistory, hidesAccountId) { hookBeforeExit(this); }); } + + // Place role filter textinput + var AWSR_firstForm = null; + + document.getElementById('awsc-recent-roles-label').insertAdjacentHTML('beforeend', ''); + + document.getElementById('AESR_RoleFilter').onkeyup = function(e) { + const str = this.value; + if (e.keyCode === 13) { + if (AWSR_firstForm) { + AWSR_firstForm.querySelector('input[type="submit"]').click() + } + } else { + const lis = Array.from(document.querySelectorAll('#awsc-username-menu-recent-roles > li')); + let firstHitLi = null; + lis.forEach(li => { + const profileName = li.firstElementChild.dataset.aesrProfile.toLowerCase(); + const hit = str ? profileName.indexOf(str) > -1 : false; + const shown = str ? hit : true; + li.style.display = shown ? 'block' : 'none'; + li.style.background = null; + if (hit && firstHitLi === null) firstHitLi = li; + }); + + if (firstHitLi) { + firstHitLi.style.background = '#f0f9ff'; + AWSR_firstForm = firstHitLi.querySelector('form'); + } else { + AWSR_firstForm = null; + } + } + } + + document.getElementById('nav-usernameMenu').addEventListener('click', () => { + document.getElementById('AESR_RoleFilter').focus() + }) } function attachColorLine(profiles) {