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

Added confirmation button for clearing all cookies #11

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
43 changes: 35 additions & 8 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @author Vinit Shahdeo
* @email [email protected]
*/
var conf_flag = false;
var count = 0;
$("#banner").fadeTo(4000, 500).slideUp(500, function(){
$("#banner").slideUp(500);
Expand All @@ -13,6 +14,7 @@ function setCookieCount(){
chrome.cookies.getAll({},function(cookies){
count=cookies.length;
document.getElementById("cookie-counter").innerHTML = count;
document.getElementById("confirmation").style.display = "none";
});
}

Expand Down Expand Up @@ -121,16 +123,30 @@ function onCookieChanged(){

onCookieChanged();

function updateFlag(val){
conf_flag = val
}

function clearAllCookies(){
console.log("cookies cleared");
chrome.cookies.getAll({}, function(cookies) {
for (var i in cookies) {
removeCookie(cookies[i]);
}
});
document.getElementById("banner").className="alert alert-danger alert-dismissible";
document.getElementById("message").innerHTML = "All Cookies are cleared!";
setCookieCount();
var display_stat = document.getElementById("banner").style.display
if(display_stat == 'block'){
document.getElementById("banner").style.display = 'none';
document.getElementById("confirmation").style.display = 'none';
}else{
document.getElementById("banner").style.display = 'block';
document.getElementById("confirmation").style.display = 'block';
}
document.getElementById("banner").className="alert alert-danger alert-dismissible";
document.getElementById("message").innerHTML = "Do you want to delete all cookies?";
if(conf_flag == true){


}
// else{
// document.getElementById("banner").className="alert alert-danger alert-dismissible";
// document.getElementById("message").innerHTML = "Operation cancelled!";
// }
}

function removeCookie(cookie) {
Expand All @@ -147,6 +163,7 @@ onCookieChanged();
var clear_Cookies = document.getElementById("clear_cookies");
var set_Cookies = document.getElementById("set_cookies");
var display_Cookies = document.getElementById("display_cookies");
var del_confirmation = document.getElementById("confirmation");
var url = document.getElementById("url");
// onClick's logic below:
clear_Cookies.addEventListener('click', function() {
Expand All @@ -158,6 +175,16 @@ onCookieChanged();
display_Cookies.addEventListener('click',function(){
displayCookies();
});
del_confirmation.addEventListener('click',function(){
chrome.cookies.getAll({}, function(cookies) {
for (var i in cookies) {
removeCookie(cookies[i]);
}
});
document.getElementById("banner").className="alert alert-danger alert-dismissible";
document.getElementById("message").innerHTML = "All Cookies are cleared!";
document.getElementById("cookie-counter").innerHTML = 0;
});
url.addEventListener('blur',function(){
updateBanner();
});
Expand Down
3 changes: 3 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: Cookie Manager
show_downloads: true
theme: jekyll-theme-hacker
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ <h2 class="title text-center text-capitalize">Cookie Manager</h2>
<div class="alert alert-info alert-dismissible" id="banner">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<p id="message">Please enter <strong>complete url</strong> below and press <span class='label label-primary'>Display Cookies</span></p>
<br>
<button type="button" class="btn btnBelow btn-danger" id="confirmation">Yes</button>
</div>
<div id="result"></div>
<form>
Expand All @@ -68,7 +70,6 @@ <h2 class="title text-center text-capitalize">Cookie Manager</h2>

<div id="developer"><p class="text-center text-info developer"><span class="label label-default">Developed by Vinit Shahdeo</span> </p></div>

<script src="index.js"></script>
<script src="background.js"></script>
<!--Made by Vinit Shahdeo-->
</body>
Expand Down