-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
108 lines (92 loc) · 3.38 KB
/
Copy pathcontent.js
File metadata and controls
108 lines (92 loc) · 3.38 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
var browser = browser || chrome;
// Find all the delete buttons on the page
function findDeleteButton(selector, text) {
var elements = document.querySelectorAll(selector);
return Array.prototype.filter.call(elements, function(element){
// Add a click listener to process on click
RegExp(text).test(element.addEventListener('click', clickDeleteButton));
// This was more for the newer style react / s3 ui
if (element.disabled == true) {
clickDeleteButton()
}
});
}
// Found a delete button that was clicked
function clickDeleteButton() {
Array.prototype.forEach.call(
document.querySelectorAll('input.awsui-input-type-text, input.awsui-textfield-type-text'), function(e) {
e.focus();
// Get intput placeholder text, if two words, use second word, if one word use single word
let setWord;
let placeholder = e.placeholder;
placeLength = placeholder.split(/\W+/).length
// DynamoDB
if (placeholder === "Type delete") {
let secondWord = placeholder.split(" ");
setWord = secondWord[1];
// SNS
} else if (placeholder === "delete me") {
// let secondWord = placeholder.split(" ");
setWord = placeholder;
}
else if (placeLength === 1) {
let firstWord = placeholder.split(" ");
setWord = firstWord[0];
} else {
console.log("no match")
}
// What to set the input box to
if (setWord) {
e.focus();
// React needed dispatch
setTimeout(() => {
e.value = setWord;
e.dispatchEvent(new Event('input', { bubbles: true }));
});
// Enable delete button if found
// Class didn't seem to change
let deleteButton = document.querySelector("button.GDET2CPCBUB");
if (deleteButton) {
deleteButton.disabled = false;
deleteButton.classList.remove('GDET2CPCBUB');
}
}
});
}
// Is the account stored for bypass?
function accountPref(accountId) {
browser.storage.sync.get(['accounts'], function(result) {
if (result !== null) {
// Is there an account set to exlcude
if (typeof result.accounts === 'undefined') {
// Find the delete buttons and process
findDeleteButton('button', 'elete')
} else if (!result.accounts.includes(accountId)) {
// Find the delete buttons and process
findDeleteButton('button', 'elete')
}
}
});
}
function accountId() {
// Store account id here
let accountIdCheck;
// Standard? Assume this is like SSO here
// AWS SSO
let accountIdSso = document.querySelector('#menu--account *[data-testid="aws-my-account-details"]');
if (accountIdSso) {
accountIdCheck = accountIdSso.innerHTML
};
// Federated
let accountIdFed = document.querySelector('#menu--account *[data-testid="account-menu-title"]');
if (accountIdFed) {
let splitAcc = accountIdFed.split(":")
accountIdCheck = splitAcc[1]
};
if (accountIdCheck) {
accountPref(accountIdCheck)
}
}
// Main run to kick it off
// Query for account ID to compare against excludes (if any)
accountId()