Skip to content

Instantly share code, notes, and snippets.

@erikvold
Created October 10, 2012 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikvold/3868985 to your computer and use it in GitHub Desktop.
Save erikvold/3868985 to your computer and use it in GitHub Desktop.
var pbService = Components.classes["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
var listener = {
QueryInterface: function(iid) {
if (Ci.nsIPrivacyTransitionObserver.equals(iid) ||
Ci.nsISupportsWeakReference.equals(iid) ||
Ci.nsISupports.equals(iid))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
privateModeChanged: function() {
alert('change!');
}
}
window.gBrowser.docShell.addWeakPrivacyTransitionObserver(listener);
pbService.privateBrowsingEnabled = true;
window.gBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
alert(window.gBrowser.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment