Skip to content

Instantly share code, notes, and snippets.

@gpolitis
Created February 23, 2012 10:57
Show Gist options
  • Save gpolitis/1892300 to your computer and use it in GitHub Desktop.
Save gpolitis/1892300 to your computer and use it in GitHub Desktop.
Disable HttpOnly cookies in firefox
(function () {
function cookieObserver()
{
this.register();
}
cookieObserver.prototype = {
observe: function(subject, topic, data) {
this.onCookieChanged(subject.QueryInterface(Components.interfaces.nsICookie2), data);
},
register: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(this, "cookie-changed", false);
},
unregister: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(this, "cookie-changed");
},
onCookieChanged: function(c, action) {
switch (action) {
case "added":
case "changed":
// TODO preferences.
if (c.isHttpOnly && c.host.match(/\.google\.[A-Za-z]*/)) {
var cm = Components.classes["@mozilla.org/cookiemanager;1"].getService(Components.interfaces.nsICookieManager2);
cm.remove(c.host, c.name, c.path, false);
cm.add(c.host, c.path, c.name, c.value, c.isSecure, false, c.isSession, c.expiry);
}
break;
}
}
}
new cookieObserver();
})();
@gpolitis
Copy link
Author

Hmm.. Gmail does not load properly with this code (turned into an addon) running.. Every time I try to login I get redirected to the login screen.

@Lincor
Copy link

Lincor commented Jan 3, 2015

can you make extension with this code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment