Skip to content

Commit

Permalink
Add bucket delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecBlance committed Apr 14, 2020
1 parent cf39f74 commit e3e9ff8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BucketList is a Firefox plugin that records S3 Buckets found in requests. It is

**Features to be added**
- ~~Clear button~~
- Remove bucket button
- ~~Remove bucket button~~
- ~~Start and stop bucket search~~
- Additional S3 Bucket Checks
- Misconfiguration and Permission check
Expand Down
16 changes: 15 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
record = false;
} else {
browser.browserAction.setBadgeText({
text: null
text: clicks.toString()
});
browser.browserAction.setBadgeBackgroundColor({
color: "green"
});
record = true;
}
Expand All @@ -87,4 +90,15 @@ browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
"file": blob
});
}
if (request.action == "delete") {
browser.browserAction.setBadgeText({
text: (--clicks).toString()
});
if (clicks == 0) {
browser.browserAction.setBadgeText({
text: null
});
}
bucket.splice(bucket.indexOf(request.buckets) , 1);
}
});
22 changes: 16 additions & 6 deletions popup/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ h2 {
display:flex;
}
.bucket {
padding:1% 0 1% 3%;
padding:1% 2% 1% 3%;
display:flex;
justify-content: space-between;
align-items: center;
Expand All @@ -48,6 +48,7 @@ h2 {
width:350px;
}
.bucketDelete {
text-decoration: none;
font-family: Medium;
border-radius: 3px;
display:flex;
Expand All @@ -57,6 +58,9 @@ h2 {
color:white;
padding:1%;
}
.bucketDelete:hover {
background-color:#e65761;
}
.bucket div{
margin:0 2%;
}
Expand All @@ -74,9 +78,6 @@ h2 {
background-color:white;
text-decoration:none;
}
#right {
width:55px;
}
label {
display:flex;
align-items: center;
Expand All @@ -100,10 +101,19 @@ i {
/*padding:3% 3% 0.1% 3%;*/
background-color:#363B59;
display:flex;
display:flex;
justify-content: flex-end;
justify-content: space-between;
}
.end a {
font-family: Medium;
margin:0 0 0 2%;
}
#credits {
width:300px;
}
#credits a {
text-decoration: none;
color:white;
}
#name {
margin:0;
}
7 changes: 6 additions & 1 deletion popup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<body>
<div id="header">
<h2>Bucket List</h2>
<div id="right"></div>
<label>
<input type="checkbox" id="record" checked>
Record
Expand All @@ -18,6 +17,12 @@ <h2>Bucket List</h2>
<div id="content">
</div>
<div class="end">
<div id="credits">
<p>
Made by
<a href="https://github.com/AlecBlance" id="name">Alec Blance</a>
</p>
</div>
<a href="" id="clear">Clear</a>
<a href="" id="save" download>Save</a>
</div>
Expand Down
16 changes: 12 additions & 4 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ document.getElementById("clear").addEventListener("click", () => {
var sending = browser.runtime.sendMessage({
"action" : "clear"
});
sending.then(()=>{
document.getElementById("content").innerHTML = "";
});
});

(() => {
Expand All @@ -28,13 +25,24 @@ document.getElementById("clear").addEventListener("click", () => {
response.bucketList.forEach((bucket)=>{
document.getElementById("content").innerHTML +=
"<div class=\"bucket\"><div class=\"bucketName\"><p>"+bucket
+"</p></div></div>";
+"</p></div><a href=\"\" class=\"bucketDelete\"><div>Delete</div></a></div>";
});
if (response.file != null){
save.download = "buckets.txt";
save.href = response.file;
} else {
save.removeAttribute("download");
}
var bucketDelete = document.getElementsByClassName("bucketDelete");
var bucketName = document.getElementsByClassName("bucketName");
for (var i = 0; i < bucketDelete.length; i++) {
bucketDelete[i].addEventListener('click', (target) => {
var sending = browser.runtime.sendMessage({
"action" : "delete",
"buckets": target.currentTarget.bucket.textContent
});
}, false);
bucketDelete[i].bucket = bucketName[i];
}
});
})();

0 comments on commit e3e9ff8

Please sign in to comment.