Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alert box to confirm cookies clearing #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ function onCookieChanged(){

onCookieChanged();

function appendAlertClearCookies() {
document.getElementById("alert_clear_all").style.display="block";
}

function hideAlertClearCookies() {
document.getElementById("alert_clear_all").style.display="none";
}

function clearAllCookies(){
hideAlertClearCookies();
console.log("cookies cleared");
chrome.cookies.getAll({}, function(cookies) {
for (var i in cookies) {
Expand All @@ -144,11 +153,19 @@ onCookieChanged();
}

document.addEventListener('DOMContentLoaded', function() {
var append_alert_clear_Cookies = document.getElementById("append_alert_clear_cookies");
var cancel_clear_Cookies = document.getElementById("cancel_clear_cookies");
var clear_Cookies = document.getElementById("clear_cookies");
var set_Cookies = document.getElementById("set_cookies");
var display_Cookies = document.getElementById("display_cookies");
var url = document.getElementById("url");
// onClick's logic below:
append_alert_clear_Cookies.addEventListener('click', function() {
appendAlertClearCookies();
});
cancel_clear_Cookies.addEventListener('click', function() {
hideAlertClearCookies();
});
clear_Cookies.addEventListener('click', function() {
clearAllCookies();
});
Expand Down
14 changes: 12 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
}
.btnBelow{
font-family: 'Kanit', sans-serif;

}
.alertClearAll {
text-align: center;
display: none;
}
.btnClearAll {
margin-top: 10px;
}
#banner{
font-family: 'Rubik', sans-serif;
Expand Down Expand Up @@ -56,7 +62,11 @@ <h2 class="title text-center text-capitalize">Cookie Manager</h2>
<label for="value">Value:</label>
<input type="text" class="form-control" id="value" required="required">
</div>
<button type = "button" class="btn btnBelow btn-danger" id="clear_cookies">Clear All Cookies</button>
<div class="alert alert-danger alertClearAll" id="alert_clear_all"> You're about to Clear all Cookies. Are you sure ?
<button type="button" class="btn btnClearAll btn-success" id="clear_cookies">Yes!</button>
<button type="button" class="btn btnClearAll btn-danger" id="cancel_clear_cookies">No!</button>
</div>
<button type = "button" class="btn btnBelow btn-danger" id="append_alert_clear_cookies">Clear All Cookies</button>
<button type="button" class="btn btnBelow btn-primary" id="display_cookies">Display Cookies</button>
<button type="button" class="btn btnBelow btn-success" id="set_cookies">Set Cookies</button>
</form>
Expand Down