-
Notifications
You must be signed in to change notification settings - Fork 0
/
userscript.js
40 lines (34 loc) · 1.27 KB
/
userscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// ==UserScript==
// @name AWS SAML Accounts Remover
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Remove unneeded accounts from AWS SAML sign-in page
// @match https://signin.aws.amazon.com/saml
// @grant none
// ==/UserScript==
(function() {
'use strict';
// List of excluded names
const excludedNames = [
'account-alias',
'Account: 000000000000'
];
// Function to delete div:nth-child elements
function deleteDivElements() {
const fieldset = document.querySelector('#saml_form > fieldset');
if (fieldset) {
const divElements = fieldset.querySelectorAll('div:nth-child(n)');
divElements.forEach(divElement => {
const expandableContainer = divElement.querySelector('div.expandable-container > div');
if (expandableContainer) {
const content = expandableContainer.textContent.trim();
if (excludedNames.some(name => content.includes(name))) {
divElement.remove();
}
}
});
}
}
// Wait for the page to load, then delete div:nth-child elements
window.addEventListener('load', deleteDivElements);
})();