User:Dickvl/Private Browsing disable: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
(pbconfig version 1.3 , no userChrome.css code needed)
m (some editng to make the Contents block appear)
Line 2: Line 2:
The extension hides these menu entries and also disables their shortcut keys and should prevent Firefox from entering Private Browsing mode. The CSS code (chrome://pbdisable/content/pbdisable.css) in the extension also hides "[[Menu_differences|Tools -> Options]] -> Privacy -> Automatically start Firefox in a private browsing session" and the History setting. You can copy that code to [[userChrome.css]] if you want these entries hidden if the extension is disabled. Current Firefox versions still process code in userChrome.css if started in [[Safe_mode]]. Keep in mind that removing or disabling "Private Browsing" will not make it impossible to delete private data like visited websites (history) or cache.  It is possible to clear the cache via "[[Menu_differences|Tools -> Options]] -> Advanced -> Network" and to clear history in the Library and History sidebar. See also [https://wiki.mozilla.org/Firefox3.1/PrivateBrowsing/SecurityReview]
The extension hides these menu entries and also disables their shortcut keys and should prevent Firefox from entering Private Browsing mode. The CSS code (chrome://pbdisable/content/pbdisable.css) in the extension also hides "[[Menu_differences|Tools -> Options]] -> Privacy -> Automatically start Firefox in a private browsing session" and the History setting. You can copy that code to [[userChrome.css]] if you want these entries hidden if the extension is disabled. Current Firefox versions still process code in userChrome.css if started in [[Safe_mode]]. Keep in mind that removing or disabling "Private Browsing" will not make it impossible to delete private data like visited websites (history) or cache.  It is possible to clear the cache via "[[Menu_differences|Tools -> Options]] -> Advanced -> Network" and to clear history in the Library and History sidebar. See also [https://wiki.mozilla.org/Firefox3.1/PrivateBrowsing/SecurityReview]


==Private Browsing toggle test==
You can copy and paste this code in the '''"Tools > Error Console"''' to test if it is possible to toggle Private Browsing mode before and after you have installed the extension. It should not be possible, but what Firefox shows can be deceiving as it looks a bit buggy to me. You can check if new history is still kept.
You can copy and paste this code in the '''"Tools > Error Console"''' to test if it is possible to toggle Private Browsing mode before and after you have installed the extension. It should not be possible, but what Firefox shows can be deceiving as it looks a bit buggy to me. You can check if new history is still kept.
<pre>var pbs = Components.classes["@mozilla.org/privatebrowsing;1"].getService(Components.interfaces.nsIPrivateBrowsingService);
<pre>var pbs = Components.classes["@mozilla.org/privatebrowsing;1"].getService(Components.interfaces.nsIPrivateBrowsingService);
Line 10: Line 11:
</pre>
</pre>


==Lock prefs with mozilla.cfg==
You can lock some history prefs and reset pref '''browser.privatebrowsing.autostart''' to false with this version of the file ''mozilla.cfg''.<br>
You can lock some history prefs and reset pref '''browser.privatebrowsing.autostart''' to false with this version of the file ''mozilla.cfg''.<br>
Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as '''mozilla.cfg''' (updated Feb 23, 2010) and copy the file to the Firefox program folder.
Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as '''mozilla.cfg''' (updated Feb 23, 2010) and copy the file to the Firefox program folder.
Line 27: Line 29:
For full instructions, see [[Locking_preferences]]
For full instructions, see [[Locking_preferences]]


==Extension code for pbdisable==
Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as '''pbdisable-1.3-fx.xpi''' (version 1.3, updated Feb 23, 2010)<br>
Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as '''pbdisable-1.3-fx.xpi''' (version 1.3, updated Feb 23, 2010)<br>
You can install the extension via "File > Open File" or by dragging the file in a Firefox window.<br>
You can install the extension via "File > Open File" or by dragging the file in a Firefox window.<br>

Revision as of 15:17, 26 February 2010

Here is a simple extension to disable the "Tools -> Start Private Browsing" menu entry and the "Tools > Clear Recent History" menu entry in Firefox 3.5/6.
The extension hides these menu entries and also disables their shortcut keys and should prevent Firefox from entering Private Browsing mode. The CSS code (chrome://pbdisable/content/pbdisable.css) in the extension also hides "Tools -> Options -> Privacy -> Automatically start Firefox in a private browsing session" and the History setting. You can copy that code to userChrome.css if you want these entries hidden if the extension is disabled. Current Firefox versions still process code in userChrome.css if started in Safe_mode. Keep in mind that removing or disabling "Private Browsing" will not make it impossible to delete private data like visited websites (history) or cache. It is possible to clear the cache via "Tools -> Options -> Advanced -> Network" and to clear history in the Library and History sidebar. See also [1]

Private Browsing toggle test

You can copy and paste this code in the "Tools > Error Console" to test if it is possible to toggle Private Browsing mode before and after you have installed the extension. It should not be possible, but what Firefox shows can be deceiving as it looks a bit buggy to me. You can check if new history is still kept.

var pbs = Components.classes["@mozilla.org/privatebrowsing;1"].getService(Components.interfaces.nsIPrivateBrowsingService);
var oldPM = pbs.privateBrowsingEnabled;
var newPM;
pbs.privateBrowsingEnabled = !pbs.privateBrowsingEnabled;
void(alert('PB is '+((newPM=pbs.privateBrowsingEnabled)?'on':'off')+((oldPM==newPM)?' (failed)':'')));

Lock prefs with mozilla.cfg

You can lock some history prefs and reset pref browser.privatebrowsing.autostart to false with this version of the file mozilla.cfg.
Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as mozilla.cfg (updated Feb 23, 2010) and copy the file to the Firefox program folder.

data:application/octet-stream;base64,
PDwaF31/cnM1L29/fISAcn87fX92g26Bcm9/fISAdnt0O26CgXyAgW5/gS85LXNueYByNkgaF3l8
cHhdf3JzNS9vf3yEgHJ/O3V2gIF8f4ZscoV9dn9ybHFuhoAvOS0+RT02SBoXeXxweF1/cnM1L29/
fISAcn87dXaAgXx/hmxyhX12f3JscW6GgGx6dnsvLTlGPTZIGhd5fHB4XX9yczUvfXlucHKAO3V2
gIF8f4Y7cntub3lycS85LYF/gnI2SBoXeXxweF1/cnM1L31/doNucIY7cHlybn9ce2B1goFxfIR7
O3V2gIF8f4YvOS1zbnmAcjZIGhd5fHB4XX9yczUvfX92g25whjtwfXE7dXaAgXx/hi85LXNueYBy
NkgaF3l8cHhdf3JzNS99f3aDbnCGO4Bue3aBdodyO4Bue3aBdodyXHtgdYKBcXyEey85LXNueYBy
NkgaFw==

You need to create a file local-settings.js with this line:

pref("general.config.filename", "mozilla.cfg");

Copy the file local-settings.js to the grefprefs folder or the defaults\pref folder in the Firefox program folder.
Prefs that are locked show as italic with Status is Locked on the about:config page and can't be changed.
For full instructions, see Locking_preferences

Extension code for pbdisable

Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as pbdisable-1.3-fx.xpi (version 1.3, updated Feb 23, 2010)
You can install the extension via "File > Open File" or by dragging the file in a Firefox window.
You can move the extensions folder (pbdisable@mozillazine.org) from the extensions folder in the Profile Folder to the %AppData%\Mozilla\extensions\{ec8030f7-c20a-464f-9b0e-13a3a9e97384} folder or to the extensions folder in the Firefox program folder to make the extension work in all Firefox profiles. If you do that then you can't uninstall, but you can disable the extension. You can also drop the XPI file in that folder and the extension will be installed on the next start of Firefox [2].

data:application/octet-stream;base64,
UEsDBBQAAAAIAHuYPzw3xI8ySQAAAHwAAAAPABUAY2hyb21lLm1hbmlmZXN0VVQJAAMJxmVLCcZl
S1V4BADoA2QAS87PK0nNK+EsSErJLE5MyknlTM4oys9N1U+GSOjzcvFy5ZelFuUkVkKlrPT1k4ry
y4tTi+CKoHy9itIchCK4kXBlcBGQQl4uAFBLAwQUAAAACAC5jVg80w1rs3kBAAD9AgAACwAVAGlu
c3RhbGwucmRmVVQJAAO9V4VLvVeFS1V4BADoA2QAbZJRT4MwFIXfTfYfKr6ZlDJANwhjahaffDBL
9L2Dy9ZIW9IWN2f877JCHRrfyjnfub33lmx54DV6B6WZFAtv6gfeMp9cTC6y9eoRdZ7QC29nTJMS
st/v/X3kS7Ul0yRJSBCSMMSqrLD+EIYesNBXXp9Jgf+KcXlkdU1tNgyCmAA/Ba+87i6UrUAXijWm
awHRjWzNwmuVSIdQyoQ2tK4xp4JVoI0NoQx4ysq82ZRM000NdwN+ZAJO92SkBxwrKIf8+QENuLWt
5oBhCfnUj6zpvp1fnrsc1UHYnTTqVA6iRXonlSlaY8uMY65UoYAaqfKSFW/vtcWc5JCd5NDQLbys
n/JhkZVULdf+f3OOaVfBfDSQh9a2R6tfYowemYJKHhDGZ5aqLZj7pqlZQX9a/fUyveLW/gnFPIiC
aoaLMKA4vo0rnGwCwNOIRjSBZBbN46/xG/RRzsTrsNfIv7H+SBpx9ODE2L/uubPUN0f+dtfP+t8o
f9mMdL93/g1QSwMECgAAAAAADaV2OwAAAAAAAAAAAA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5yZGZVVAUAA71XhUtVeAAAUEsBAhcDCgAAAAAADaV2OwAAAAAA
AAAAAAAAAAcADQAAAAAAAAAQAO1BQgIAAGNocm9tZS9VVAUAA6mTCUtVeAAAUEsBAhcDCgAAAAAA
WJg/PAAAAAAAAAAAAAAAAA8ADQAAAAAAAAAQAO1BfAIAAGNocm9tZS9jb250ZW50L1VUBQADx8Vl
S1V4AABQSwECFwMUAAAACABvj1g8IWXJHYQDAADcCAAAHAANAAAAAAABAAAA7YG+AgAAY2hyb21l
L2NvbnRlbnQvcGJkaXNhYmxlLnh1bFVUBQAD8lqFS1V4AABQSwECFwMUAAAACABcj1g8GV7cAyoB
AAD4AQAAHAANAAAAAAABAAAA7YGRBgAAY2hyb21lL2NvbnRlbnQvcGJkaXNhYmxlLmNzc1VUBQAD
z1qFS1V4AABQSwUGAAAAAAYABgDKAQAACggAAAAA

Byte Shift JavaScript

You can use this JavaScript program to encode mozila.cfg.txt to mozilla.cfg and decode mozila.cfg to mozilla.cfg.txt.

/*
 * Paste this file into Firefox's JavaScript console and click the Evaluate button to run the script - dickvl@kb.mozillazine.org 
 * use a byte shift of 13 to encode the file mozilla.cfg.txt to mozilla.cfg
 * use a byte shift of -13 to decode mozilla.cfg to mozilla.cfg.txt
*/
(function(){
 var Cc = Components.classes;
 var Ci = Components.interfaces;

 var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
 var stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
 var streamIO = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
 var input,output='',i,s,sV=13;

 fp.init(window, "", fp.modeOpen);
 fp.appendFilter("", "*.txt; *.cfg");
 
 if (fp.show() == fp.returnCancel) return;

 stream.init(fp.file, 0x01, 0444, null);
 streamIO.init(stream);
 input = streamIO.read(stream.available());
 streamIO.close();
 stream.close();

 if((s=prompt('Byte Shift value (13 to encode and -13 to decode):','13'))!=null){
  sV=parseInt(s,10);
  for(i=0;i<input.length;i++){output+=String.fromCharCode(input.charCodeAt(i)+sV)}

  fp.init(window,"",Ci.nsIFilePicker.modeSave);
  fp.defaultString="mozilla.cfg";
  if (fp.show() == fp.returnCancel) return;

  var stream=Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
  stream.init(fp.file,0x04|0x08,0644,0);
  stream.write(output,output.length);
  stream.close();
 }
})();