Created
February 23, 2012 10:57
-
-
Save gpolitis/1892300 to your computer and use it in GitHub Desktop.
Disable HttpOnly cookies in firefox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you make extension with this code?