Skip to content

Commit

Permalink
Fix not to use nbsp and recent items exclude loaded items
Browse files Browse the repository at this point in the history
  • Loading branch information
tilfin committed Aug 8, 2016
1 parent d49a6ad commit e19dfd5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ function extendIAMFormList() {
}

function loadProfiles(profiles, list, csrf) {
var submits = list.querySelectorAll('input[type="submit"]');
var recentNames = [];

submits.forEach(function(input){
input.style = 'white-space:pre';
recentNames.push(input.value);
});

profiles.forEach(function(item) {
var name = item.profile + ' | ' + item.aws_account_id;
if (recentNames.indexOf(name) !== -1) return true;

var color = item.color || 'aaaaaa';
var listItem = document.createElement('li');
listItem.innerHTML = '<form action="https://signin.aws.amazon.com/switchrole" method="POST" target="_top">'
Expand All @@ -28,8 +39,7 @@ function loadProfiles(profiles, list, csrf) {
+ '<input type="hidden" name="redirect_uri" value="https%3A%2F%2Fconsole.aws.amazon.com%2Fs3%2Fhome">'
+ '<label for="awsc-recent-role-switch-0" class="awsc-role-color" style="background-color: #'+color+';">&nbsp;</label>'
+ '<input type="submit" class="awsc-role-submit awsc-role-display-name" name="displayName" value="'
+ item.profile + ' &nbsp;|&nbsp; ' + item.aws_account_id
+ '" title="' + item.role_name + '@' + item.aws_account_id + '">'
+ name + '" title="' + item.role_name + '@' + item.aws_account_id + '" style="white-space:pre">'
+ '</form>';

list.appendChild(listItem);
Expand All @@ -42,6 +52,8 @@ function attachColorLine(profiles) {
var r = usernameMenu.textContent.match(/^([^\s]+)/);
if (r.length < 2) return;

usernameMenu.style = 'white-space:pre';

var profileName = r[1];
var color = null;
profiles.some(function(item) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AWS Extend Switch Roles",
"version": "0.1.5",
"version": "0.1.6",
"description": "Extend your AWS IAM switching roles. You can set the configuration by aws config format",
"short_name": "Extend SwtichRole",
"permissions": ["storage"],
Expand Down

0 comments on commit e19dfd5

Please sign in to comment.