|
//Copyright (C) 2010 by Cosmin Stejerean |
|
//Licensed under the Conkeror License http://conkeror.org/ConkerorLicense |
|
|
|
// Add clear-site-cookies and list-site-cookies. |
|
|
|
// clear-site-cookies is like clear-cookies but only for the host of the current buffer. |
|
// I needed because I needed to clear cookies only for a particular website |
|
// without logging me out of every other web application. |
|
|
|
// list-site-cookies is a hack to user alert to list all of the cookies for the current site |
|
// since I haven't had a chance to implement using separate special-buffer for cookie listing. |
|
|
|
// also, M-x permission-manager doesn't seem to do anything for me. |
|
|
|
require("cookie.js"); |
|
|
|
function for_each_host_cookie(host, fn) { |
|
var cookies = cookie_manager.getCookiesFromHost(host); |
|
while (cookies.hasMoreElements()) { |
|
var cookie = cookies.getNext().QueryInterface(Components.interfaces.nsICookie2); |
|
fn(cookie); |
|
} |
|
} |
|
|
|
function list_host_cookies(host, window) { |
|
for_each_host_cookie(host, |
|
function (cookie) { |
|
window.alert("Name: " + cookie.name + "\nPath: " + cookie.path + "\nValue: " + cookie.value); |
|
}); |
|
} |
|
|
|
function clear_host_cookies(host) { |
|
for_each_host_cookie(host, |
|
function (cookie) { |
|
cookie_manager.remove(cookie.host, cookie.name, cookie.path, false); |
|
}); |
|
} |
|
|
|
interactive("clear-site-cookies", "Delete all cookies for the current site", |
|
function (I) { |
|
var host = I.buffer.current_uri.host; |
|
clear_host_cookies(host); |
|
I.minibuffer.message("Cookies cleared for " + host); |
|
}); |
|
|
|
interactive("list-site-cookies", "List all cookies for the current site", |
|
function (I) { |
|
var host = I.buffer.current_uri.host; |
|
list_host_cookies(host, I.window); |
|
}); |