User:Dickvl: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
(→‎Private Browsing: code cleanup (1.1))
(→‎Private Browsing: better working code, with alert.)
Line 346: Line 346:
===Private Browsing===
===Private Browsing===
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.<br>
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.<br>
The extension hides these menu entries and also disables their shortcut keys. The code doesn't hide "[[Menu_differences|Tools -> Options]] -> Privacy" to start PB mode automatically and you need to add code to userChrome.css to do that. The code in userChrome.css also hides the menu entries if the extension is disabled or not installed. Current Firefox versions still process code in userChrome.css if started in [[Safe_mode]]. You can lock the pref ''browser.privatebrowsing.autostart'' to prevent auto start in PB mode (see below). It is still 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. The code doesn't hide "[[Menu_differences|Tools -> Options]] -> Privacy" to start PB mode automatically and you need to add code to userChrome.css to do that. The code in userChrome.css also hides the menu entries if the extension is disabled or not installed. Current Firefox versions still process code in userChrome.css if started in [[Safe_mode]]. 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]
 
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.
<pre>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)':'')));
</pre>


Add this code to [[userChrome.css]] below the @namespace line (only add the @namespace line if it is missing).<br>
Add this code to [[userChrome.css]] below the @namespace line (only add the @namespace line if it is missing).<br>
Line 360: Line 368:
</pre>
</pre>


You can lock some prefs with this version of the file mozilla.cfg.<br>
Locking the pref '''browser.privatebrowsing.autostart''' is causing problems (can throw an exception), so I've removed it from '''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''' (last updated Feb 22, 2010) and copy the file to the Firefox program folder.
You can add that line to [[user.js]] instead if you want to reset that pref on each start and avoid an alert.
user_pref("browser.privatebrowsing.autostart", false);
 
You can lock some history prefs 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.
<pre>data:application/octet-stream;base64,
<pre>data:application/octet-stream;base64,
PDwaF3l8cHhdf3JzNS9vf3yEgHJ/O31/doNugXJvf3yEgHZ7dDtugoF8gIFuf4EvOS1zbnmAcjZI
PDwaF3l8cHhdf3JzNS9vf3yEgHJ/O3V2gIF8f4ZscoV9dn9ybHFuhoAvOS0+RT02SBoXeXxweF1/
Ghd5fHB4XX9yczUvb398hIByfzt9f3aDboFyb398hIB2e3Q7cXx7gWx9f3x6fYFsfHtscnuBcn8v
cnM1L29/fISAcn87dXaAgXx/hmxyhX12f3JscW6GgGx6dnsvLTlGPTZIGhd5fHB4XX9yczUvfXlu
OS2Bf4JyNkgaF3l8cHhdf3JzNS9vf3yEgHJ/O3V2gIF8f4ZscoV9dn9ybHFuhoAvOS0+RT02SBoX
cHKAO3V2gIF8f4Y7cntub3lycS85LYF/gnI2SBoXeXxweF1/cnM1L31/doNucIY7cHlybn9ce2B1
eXxweF1/cnM1L29/fISAcn87dXaAgXx/hmxyhX12f3JscW6GgGx6dnsvLTlGPTZIGhd5fHB4XX9y
goFxfIR7O3V2gIF8f4YvOS1zbnmAcjZIGhd5fHB4XX9yczUvfX92g25whjtwfXE7dXaAgXx/hi85
czUvfXlucHKAO3V2gIF8f4Y7cntub3lycS85LYF/gnI2SBoXeXxweF1/cnM1L31/doNucIY7cHly
LXNueYByNkgaF3l8cHhdf3JzNS99f3aDbnCGO4Bue3aBdodyO4Bue3aBdodyXHtgdYKBcXyEey85
bn9ce2B1goFxfIR7O3V2gIF8f4YvOS1zbnmAcjZIGhd5fHB4XX9yczUvfX92g25whjtwfXE7dXaA
LXNueYByNkgaFw==
gXx/hi85LXNueYByNkgaF3l8cHhdf3JzNS99f3aDbnCGO4Bue3aBdodyO4Bue3aBdodyXHtgdYKB
cXyEey85LXNueYByNkgaFw==
</pre>
</pre>
You also need to create the file '''local-settings.js''' with this line:<br>
You also need to create the file '''local-settings.js''' with this line:
  pref("general.config.filename", "mozilla.cfg");
  pref("general.config.filename", "mozilla.cfg");
Copy that file to the '''grefprefs''' folder or the '''defaults\pref''' folder in the Firefox program folder.
Copy the file '''local-settings.js''' to the '''grefprefs''' folder or the '''defaults\pref''' folder in the Firefox program folder.<br>
Prefs that are locked show as italic on the [[about:config]] page and can't be changed.<br>
For full instructions, see [[Locking_preferences]]
For full instructions, see [[Locking_preferences]]


Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as '''pbdisable.xpi''' (last 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.xpi''' (version 1.2, 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>
You can move the extensions folder (pbdisable@mozillazine.org) from the extensions folder in the [[Profile_folder_-_Firefox|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 [https://developer.mozilla.org/en/Installing_extensions].<br><!-- http://ehsanakhgari.org/blog/2008-11-08/prepare-your-add-private-browsing -->
You can move the extensions folder (pbdisable@mozillazine.org) from the extensions folder in the [[Profile_folder_-_Firefox|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 [https://developer.mozilla.org/en/Installing_extensions].<br><!-- http://ehsanakhgari.org/blog/2008-11-08/prepare-your-add-private-browsing -->

Revision as of 21:46, 23 February 2010

Bookmarklets

Bookmarklets can be found here: User:Dickvl/Bookmarklets
See also Wikipedia: Bookmarklet

Navigator Object

Here is a bookmarklet to display the content of the Navigator object (plugins, mimeTypes)

javascript:/* dickvl@kb.mozillazine.org */
(function(){
var b='<br>',i,L,O,p,pN,pT=('Navigator properties:').bold()+b+b,oT=('Navigator objects:').bold()+b+b,fT=('Navigator functions:').bold()+b+b;
for(pN in navigator){
if(typeof navigator[pN]=='object'){
O=navigator[pN];L=(O.length)?O.length:0;oT+=(pN+': ').bold()+L.toString().bold()+b;
for(i=0;i<L;i++){M=O[i];oT+=('['+(i+1)+'] ').bold();
for(p in M){if(typeof M[p]!='function'&&typeof M[p]!='object'&&p!='length'){oT+=(p+': ').bold()+M[p]+(' | ').bold()}}
if(M.enabledPlugin){oT+=('Plugin: ').bold()+M.enabledPlugin.name}
oT+=b}
oT+=b}
else if(typeof navigator[pN]!='function'){pT+=(pN+': ').bold()+navigator[pN]+b}
else if(typeof navigator[pN]=='function'){if(/Enabled/.test(pN)){fT+=(pN+': ').bold()+navigator[pN]()+b}}}
with(document.open()){write(pT+b+oT+b+fT);close();}
})();

Code

Code for userChrome.css and userContent.css can be found here User:Dickvl/Code

Double Underlined pop-ups

You can add this code to userContent.css to hide some ads and some IntelliTXT type pop-ups (double underlined links) [1].

/* google_ads_frame */
iframe[src*="googlesyndication"],
iframe[name="google_ads_frame"] {display:none!important}

/* intelliTXT and others */
#iTt,#adbrite_inline_div,#AdvertBanner,#amzn-popup-div,#konaLayers,#lwPreview,#menuModule,#tf_AdDiv,#tooltipBox,#IL_BUBBLE,#IL_FORM_CONT
 {display:none!important} 

/* get.lingospot.com */
.lingo_info_box *,.lingo_spot *,.lingo_reset *{display:none!important}

Error Console

List Add-ons

Sometime ago I noticed the Mozilla's Places Stats Project thread with the possibility to display a list of installed extensions in JSON notation by using the Error Console. That gave me an idea to do the same for the printing passwords code in the Password Manager article.

I have also taken the opportunity to create a similar file for displaying the installed extensions. So here are two versions.
The first version shows the name and version number and the second version has the possibility to select which additional columns you wish to see.

/*
 * Paste this file into Firefox's JavaScript Console and evaluate it to display the installed extensions and themes - dickvl@kb.mozillazine.org
*/
(function () {
var Cc = Components.classes;
var Ci = Components.interfaces;
var EMP = "http://www.mozilla.org/2004/em-rdf#";
var rv = {}; rv.ext = []; rv.the = [];

var ds =
    Cc["@mozilla.org/extensions/manager;1"].
    getService(Ci.nsIExtensionManager).
    datasource;
var rdf =
    Cc["@mozilla.org/rdf/rdf-service;1"].
    getService(Ci.nsIRDFService);
var elts =
    Cc["@mozilla.org/rdf/container-utils;1"].
    getService(Ci.nsIRDFContainerUtils).
    MakeSeq(ds, rdf.GetResource("urn:mozilla:item:root")).
    GetElements();

function rdfGS(elt,res){
 try{
     return(ds.GetTarget(elt,rdf.GetResource(EMP+res),true).QueryInterface(Ci.nsIRDFLiteral).Value);
 } catch(e){return("")}
}

function makeRV(elt,rv){
 var nam = rdfGS(elt,"name");
 var ver = rdfGS(elt,"version");
 var dis = rdfGS(elt,"isDisabled");
 var hom = rdfGS(elt,"homepageURL");
 rv.push({name:nam,id:elt.Value.replace(/^urn:mozilla:item:/,""),vers:ver,dis:dis,home:hom});
return(rv);
}

function makeLIST(rv){
 var list="",i,RV;
 for (i=0;RV=rv[i];i++) {
  var name = RV.name;
  var vers = RV.vers;
  var disab = (RV.dis=="true")?"(disabled)":"";
  var home = RV.home;
  list+="<a href=" + home + "><span>" + name + " </span><span> " + vers + " </span></a><span> " + disab + " </span></br>";
 }
return(list);
}

while (elts.hasMoreElements()) {
 var elt = elts.getNext().QueryInterface(Ci.nsIRDFResource);
 if (ds.HasAssertion(elt,rdf.GetResource(EMP+"type"),rdf.GetIntLiteral(2),true)){
  makeRV(elt,rv.ext); 
 }
 if (ds.HasAssertion(elt,rdf.GetResource(EMP+"type"),rdf.GetIntLiteral(4),true)){
  makeRV(elt,rv.the);
 }
}

var extList="<p><b>Extensions:</b><br>"+makeLIST(rv.ext)+"</p>";
var theList="<p><b>Themes:</b><br>"+makeLIST(rv.the)+"</p>";

window.open('data:text/html,
<html><head>
<meta http-equiv=content-type" content="text/html; charset=ISO-8859-1">
<title>Mozilla Extensions</title>
</head><body style="margin: 1em 3em; background-color: rgb(255, 221, 221);">
' + extList + theList + '
</body></html>',
"", "menubar=yes,toolbar=no,scrollbars=yes,resizable=yes,width=1000,height=600");
})();
/* 
 *To display the installed extensions and themes paste this file into Firefox's JavaScript Console and evaluate it - dickvl@kb.mozillazine.org
*/
(function () {
var Cc = Components.classes;
var Ci = Components.interfaces;
var EMP = "http://www.mozilla.org/2004/em-rdf#";
var EMT = 2; /* Extensions: EMT = 2;  Themes: EMT = 4; */
var rv = {}; rv.ext = []; rv.the = [];

/* columns - 0:space  1:name  2:version  3,4:disabled  5:id  6:description  7:homepage  8:compatible  9:install location */
var THEAD = ["","Name","Version","Disabled","(-)","ID","Description","Home Page","Comp.","Inst.Loc"];
var TCONT = (prompt("Columns:\n\n1:Name\n2:Version\n3:Disabled  4:(U|A)\n5:ID\n6:Description\n7:Home Page\n","1 2 3"));
TCONT=((TCONT==null || TCONT=="")?"1 2 3":TCONT).split(" ");

var ds =
    Cc["@mozilla.org/extensions/manager;1"].
    getService(Ci.nsIExtensionManager).
    datasource;
var rdf =
    Cc["@mozilla.org/rdf/rdf-service;1"].
    getService(Ci.nsIRDFService);
var elts =
    Cc["@mozilla.org/rdf/container-utils;1"].
    getService(Ci.nsIRDFContainerUtils).
    MakeSeq(ds, rdf.GetResource("urn:mozilla:item:root")).
    GetElements();

function rdfGS(elt,res){
 try{
  return(ds.GetTarget(elt,rdf.GetResource(EMP+res),true).QueryInterface(Ci.nsIRDFLiteral).Value);
 }catch(e){return("")}
}

function makeTD(rv){
var i,j,DV,RV,TC,td="";
for (i=0;RV=rv[i];i++) {
  td+="<tr>";
 for(j=0;TC=TCONT[j];j++){
  switch(parseInt(TC)){
   case 1: DV=RV.name;break;
   case 2: DV=RV.vers;break;
   case 3: DV=(RV.dis=="true")?"(disabled)":"";break;
   case 4: DV=((RV.adis=="true")?"(A)":"")+((RV.udis=="true")?"(U)":"");break;
   case 5: DV=RV.id;break;
   case 6: DV=RV.descr;break;
   case 7: DV=RV.home;break;
   case 8: DV=(RV.comp=="true")?"Yes":((RV.comp=="false")?"No":"");break;
   case 9: DV=RV.inst;break;
   default: DV="";break;
  } td+="<td>"+DV+"</td>";
 }
 td+="</tr>";
}
return(td);
}

function makeRV(elt,rv){
 var nam = rdfGS(elt,"name");
 var ver = rdfGS(elt,"version");
 var des = rdfGS(elt,"description");
 var dis = rdfGS(elt,"isDisabled");
 var ads = rdfGS(elt,"appDisabled");
 var uds = rdfGS(elt,"userDisabled");
 var hom = rdfGS(elt,"homepageURL");
 var com = rdfGS(elt,"compatible");
 var ins = rdfGS(elt,"installLocation");
 rv.push({name:nam,id:elt.Value.replace(/^urn:mozilla:item:/,""),vers:ver,descr:des,adis:ads,udis:uds,home:hom,dis:dis,inst:ins,comp:com});
return(rv);
}

while (elts.hasMoreElements()){
 var elt = elts.getNext().QueryInterface(Ci.nsIRDFResource);
 if(isExt=ds.HasAssertion(elt,rdf.GetResource(EMP+"type"),rdf.GetIntLiteral(2),true)){
  makeRV(elt,rv.ext);
 }
 if(isExt=ds.HasAssertion(elt,rdf.GetResource(EMP+"type"),rdf.GetIntLiteral(4),true)){
  makeRV(elt,rv.the);
 }
}

var thead="";
for(j=0;TC=TCONT[j];j++){thead+="<td><b>"+(THEAD[(TC<THEAD.length)?TC:0])+"</b></td>";}

var tdivE = makeTD(rv.ext);
var tdivT = makeTD(rv.the);

function TD(string) {return (string.length < 2) ? "0" + string : string ;}
function FD(number){return (number < 1000) ? number + 2000 : number;}

var now = new Date();
var hrs = TD(now.getHours() + "");
var min = TD(now.getMinutes() + "");
var sec = TD(now.getSeconds() + "");

var timeValue = " | At  " + hrs + ":" + min + ":" + sec;
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

var today =  "On " + days[now.getDay()] + ", " + date + " " + months[now.getMonth()] + " " +    (FD(now.getYear())) + timeValue;

function makeTABLE(label,thead,tcont){
return('<p><b>'+label+':</b><br>
<table style="empty-cells: show; background-color: rgb(221, 255, 221);" border="1" cellspacing="0">
<tbody><tr style="background-color: rgb(204, 204, 255);">'+thead+'</tr>'+
tcont+'</tbody></table></p>');
}

window.open('data:text/html,
<html><head>
<meta http-equiv=content-type" content="text/html; charset=ISO-8859-1">
<title>Mozilla Extensions & Themes</title>
<style type="text/css">
 td {
  font-family: "Trebuchet MS", Arial, Verdana, Sans-Serif;
  font-size: 85%;
  padding: 1px 2px 1px 2px;
}
</style>
</head><body style="margin: 1em 3em; background-color: rgb(255, 221, 221);">
<b>MOZILLA ADD-ONS INFORMATION (by dickvl@kb.mozillazine.org)</b><p>'+today+'</p>'+
makeTABLE("Extensions",thead,tdivE) + makeTABLE("Themes",thead,tdivT)+'
</body></html>',"", "menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,width=1000,height=700");
})();

Printing Passwords

Here is an enhanced version of the Password printing code from Password Manager to show all the fields, may be helpful for troubleshooting issues.

/*
 * Paste this file into Firefox's JavaScript Console and evaluate it to display the saved names and passwords - dickvl@kb.mozillazine.org
*/

(function(){
function tdigs(str) {return (str.length < 2) ? "0" + str : str;}
function fdigs(num){return (num < 1000) ? num + 2000 : num;}

var now = new Date();
var hrs = tdigs(now.getHours() + "") ;
var mins = tdigs(now.getMinutes() + "") ;
var secs = tdigs(now.getSeconds() + "") ;

var tValue = " | At  " + hrs + ":" + mins + ":" + secs;
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var mons = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

var today =  "On " + days[now.getDay()] + ", " + date + " " + mons[now.getMonth()] + " " +    (fdigs(now.getYear())) + tValue ;

var Cc = Components.classes;
var Ci = Components.interfaces;

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

var tokendb = Cc["@mozilla.org/security/pk11tokendb;1"]
                .createInstance(Ci.nsIPK11TokenDB);
var token = tokendb.getInternalKeyToken();

try {token.login(true);} catch (e) {}

if (token.isLoggedIn()) {
 var passwordmanager = Cc["@mozilla.org/login-manager;1"]
                       .getService(Ci.nsILoginManager);
 var names="",signons = passwordmanager.getAllLogins({});

 for (i=0;i<signons.length;i++) {
  try {
   var host = signons[i].hostname;
   var realm = signons[i].httpRealm;
   var user = signons[i].username;
   var usrf = signons[i].usernameField;
   var psw = signons[i].password;
   var pswf = signons[i].passwordField;
   var surl = signons[i].formSubmitURL;
   if (user == ""){ user = "<br>"; }
   names+="<tr>\n<td>"+host+"</td>\n<td>"+realm+" </td>\n<td>"+usrf+"</td>\n<td>"+user+"</td>\n<td>"+pswf+"</td>\n<td>"+psw+"</td>\n<td>"+surl+"</td>\n</tr>\n";
   } catch(e) {}
 }

 void(window.open('data:text/html,
<html><head>
<meta http-equiv=content-type" content="text/html; charset=ISO-8859-1">

<title>Exported Mozilla Passwords</title>
<style type="text/css">
 td {
  font-family: "Trebuchet MS", Arial, Helvetica, Geneva, Verdana, Sans-Serif;
  font-size: 85%;
  padding: 1px 2px 1px 2px;
}
</style>
</head><body style="margin: 1em 3em; background-color: rgb(255, 221, 221);">
<b>MOZILLA PASSWORD INFORMATION</b>
<p>Produced by <i>Pasting Code in the "Tools > Error Console: Code field"</i> (by "ernie" - Andrew Poth - Ed Mullen - adapted by dickvl@kb.mozillazine.org to run in the Error Console)<br>'+today+
'</p><p>
<table style="empty-cells: show; background-color: rgb(221, 255, 221);" border="1" cellspacing="0">
<tbody><tr style="background-color: rgb(204, 204, 255);">
<td>
<b>Host</b>
</td>
<td>
<b>Realm</b>
</td>
<td>
<b>User Field</b>
</td>
<td>
<b>User Name</b>
</td>
<td>
<b>Psw Field</b>
</td>
<td>
<b>Password</b>
</td>
<td>
<b>Submit URL</b>
</td>
</tr>'+names+'</tbody></table>
</p></body></html>',"","menubar=yes,resizable=yes,scrollbars=yes,width=1000,height:600"));
}
})();

Extensions

Private Browsing

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. The code doesn't hide "Tools -> Options -> Privacy" to start PB mode automatically and you need to add code to userChrome.css to do that. The code in userChrome.css also hides the menu entries if the extension is disabled or not installed. Current Firefox versions still process code in userChrome.css if started in Safe_mode. It is possible to clear the cache via "Tools -> Options -> Advanced -> Network" and to clear history in the Library and History sidebar. See also [2]

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.

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)':'')));

Add this code to userChrome.css below the @namespace line (only add the @namespace line if it is missing).
See http://kb.mozillazine.org/Editing_configuration#How_to_edit_configuration_files

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

/* Hide PB and Sanitize item in Tools menu */
#sanitizeSeparator, #privateBrowsingItem, #sanitizeItem {display:none!important;}

/* Hide AutoStart PB and some History settings in Options > Privacy */
#rememberHistoryDays,#historyDays,#rememberAfter,
#privateBrowsingAutoStart, #clearDataBox {display:none!important;}

Locking the pref browser.privatebrowsing.autostart is causing problems (can throw an exception), so I've removed it from mozilla.cfg.
You can add that line to user.js instead if you want to reset that pref on each start and avoid an alert.

user_pref("browser.privatebrowsing.autostart", false);

You can lock some history prefs 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,
PDwaF3l8cHhdf3JzNS9vf3yEgHJ/O3V2gIF8f4ZscoV9dn9ybHFuhoAvOS0+RT02SBoXeXxweF1/
cnM1L29/fISAcn87dXaAgXx/hmxyhX12f3JscW6GgGx6dnsvLTlGPTZIGhd5fHB4XX9yczUvfXlu
cHKAO3V2gIF8f4Y7cntub3lycS85LYF/gnI2SBoXeXxweF1/cnM1L31/doNucIY7cHlybn9ce2B1
goFxfIR7O3V2gIF8f4YvOS1zbnmAcjZIGhd5fHB4XX9yczUvfX92g25whjtwfXE7dXaAgXx/hi85
LXNueYByNkgaF3l8cHhdf3JzNS99f3aDbnCGO4Bue3aBdodyO4Bue3aBdodyXHtgdYKBcXyEey85
LXNueYByNkgaFw==

You also need to create the 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 on the about:config page and can't be changed.
For full instructions, see Locking_preferences

Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as pbdisable.xpi (version 1.2, 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 [3].

data:application/octet-stream;base64,
UEsDBBQAAAAIAHuYPzw3xI8ySQAAAHwAAAAPABUAY2hyb21lLm1hbmlmZXN0VVQJAAMJxmVLCcZl
S1V4BADoA2QAS87PK0nNK+EsSErJLE5MyknlTM4oys9N1U+GSOjzcvFy5ZelFuUkVkKlrPT1k4ry
y4tTi+CKoHy9itIchCK4kXBlcBGQQl4uAFBLAwQUAAAACACaNlc8eebBm3kBAAD9AgAACwAVAGlu
c3RhbGwucmRmVVQJAAMzbYNLM22DS1V4BADoA2QAbZJLT4QwFIX3Jv6HijuTUl46A2HwkYkrF8ZE
9x24zDTSlrTFeRj/u1iowxh35Zzv3N57S3674w36AKWZFAsv9APvtjg/Oz/LX5aPqPeEXngbY9qM
kO12629jX6o1CdM0JUFEogirqsZ6LwzdYaEvvSGTAT+JcXlgTUNtNgqChAD/CV56/V0oX4IuFWtN
3wKiK9mZhdcpkY2hjAltaNNgTgWrQRsbQjnwjFVFu6qYpqsG7kb8wAT83JOTAXCsoByK5wc04ta2
mgPGJRShH1rTfTu/OnY5qYOwO2nUqxxEh/RGKlN2xpaZxlypUgE1UhUVK98/Gos5ySEbyaGla3h9
eSrGRdZSdVz7/805pV0Fs2+hiKxtj1a/wBg9MgW13CGMjyxVazD3bduwkv62evIyg+LW/gnlPIiD
eobLKKA4uUlqnK4CwGFMY5pCOovnydf0DYYoZ+Jt3GvsX1t/Ik04unNi4l8N3FEamiN/uxtm/W+U
v2xO+t+7+AZQSwMECgAAAAAADaV2OwAAAAAAAAAAAAAAAAcAFQBjaHJvbWUvVVQJAAOpkwlLqZMJ
S1V4BADoA2QAUEsDBAoAAAAAAFiYPzwAAAAAAAAAAAAAAAAPABUAY2hyb21lL2NvbnRlbnQvVVQJ
AAPHxWVLx8VlS1V4BADoA2QAUEsDBBQAAAAIAIU6VzzF+DDN/gIAAKIHAAAcABUAY2hyb21lL2Nv
bnRlbnQvcGJkaXN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cuts that I want to use in Prefbar or that are otherwise dangerous (Ctr+Q to Quit Firefox is too close to Ctrl+W).

if(E=window.document.getElementById('key_closeWindow')){E.removeAttribute('key');E.removeAttribute('modifiers');E.removeAttribute('command');}
if(E=window.document.getElementById('key_quitApplication')){E.removeAttribute('key');E.removeAttribute('modifiers');E.removeAttribute('command');}
if(E=window.document.getElementById('key_privatebrowsing')){E.removeAttribute('key');E.removeAttribute('modifiers');E.removeAttribute('command');}
if(E=window.document.getElementById('key_openDownloads')){E.removeAttribute('key');E.removeAttribute('modifiers');E.removeAttribute('command');}
if(E=window.document.getElementById('key_undoCloseWindow')){E.removeAttribute('key');E.removeAttribute('modifiers');E.removeAttribute('command');}
if(E=window.document.getElementById('manBookmarkKb')){E.removeAttribute('key');E.removeAttribute('modifiers');E.removeAttribute('command');}

You can use the DOM Inspector to find the ID of a menu entry if you want to disable other menu entries.
You can modify the file keysdisable.xul in the keysdisable.jar (zip) archive in the keysdisable.xpi (zip) archive to make the changes.

Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as keysdisable.xpi

data:application/octet-stream;base64,
UEsDBBQAAAAIAHegODx68wipWAAAAJcAAAAPABUAY2hyb21lLm1hbmlmZXN0VVQJAAOSmVxLkplc
S1V4BADoA2QAS87PK0nNK+HMTq0sTsksTkzKSeXMSiyySs4oys9N1UcS1gMKK+onQ9Tr83LxcuWX
pRblJFZyQtRa6esnFeWXF6cWwRVB+XoVpTkIRUhGwhUiWwNUzMsFAFBLAwQUAAAACAAxoTg8ps9x
mX8BAAAMAwAACwAVAGluc3RhbGwucmRmVVQJAAPtmlxL7ZpcS1V4BADoA2QAbZJRT4MwFIWfZ+J/
qPhmUsqAqBCGmiy+6NMSfe/gsjXSlrTFbRr/u1hax4xv9Nzv3J57S3G35y16B6WZFItgHkbBXXl+
dn5WrJaPaKgJvQi2xnQ5IbvdLtwloVQbMs+yjEQxiWOs6gbrgzB0j4W+DEZPDvzExuUHa1tqvXEU
pQT4j/EyGO6aFUvQlWKdG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t/m55nNfqnyLj75f9zjz+oPNscHwKPpxCxbm1seLEXngbxIRtzRlFxcDI6m
cPVkbxCGRVNvwF6/ww4897S/yt7Z5MBSXr17S87c3yzLSoO1y7+9PJc5S+HeXG4npyQHn21v3p//
xntjKneMhcCVWQbSL5bycVpJnZ7Jve+q6N3eJRu49hyY6X9X980iPxkmP50nJtsv/HiatPMGp5sW
pz9LLV//69WRtyrseZp/q51JiN+qLLb4TbTJq46g3NWZasePrmy5ePf3hrpb52bta2yf8jNs4vrI
9kOX5HqU9lwv0XywQ1A0qtBnFu/RbfLxkWlhjomPO/tC+J0v//lj/Hv5Ef3HtflVW3561wfbMwZ4
MzKJM+NKwbwMIADkMrxtBLFwpmdWSHoOrWBgQDYRM7CRTVzOiN1EcNCzQoIeYiIrG0gXExAuAdIH
mEA8AFBLAQIXAxQAAAAIAHegODx68wipWAAAAJcAAAAPAA0AAAAAAAEAAADtgQAAAABjaHJvbWUu
bWFuaWZlc3RVVAUAA5KZXEtVeAAAUEsBAhcDFAAAAAgAMaE4PKbPcZl/AQAADAMAAAsADQAAAAAA
AQAAAO2BmgAAAGluc3RhbGwucmRmVVQFAAPtmlxLVXgAAFBLAQIXAwoAAAAAAA2ldjsAAAAAAAAA
AAAAAAAHAA0AAAAAAAAAEADtQVcCAABjaHJvbWUvVVQFAAOpkwlLVXgAAFBLAQIXAxQAAAAIAMix
Pjy6Qemw9AIAAHoDAAAWAA0AAAAAAAAAAACkgZECAABjaHJvbWUva2V5c2Rpc2FibGUuamFyVVQF
AAMooWRLVXgAAFBLBQYAAAAABAAEACMBAADOBQAAAAA=

Restart Firefox

This extension adds a Restart Firefox item to the File menu. It displays that menu entry in the language of the installed locale (should work for all locales). All open tabs and windows should be restored if session restore is working properly.
Copy and paste the full DATA code in the location bar and press the Enter key. Save the file as restarter-1.0-fx.xpi

data:application/octet-stream;base64,
UEsDBAoAAAAAAMl4OzUAAAAAAAAAAAAAAAAHABUAY2hyb21lL1VUCQADWoUaRVqFGkVVeA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tZS9jb250ZW50L3Jlc3RhcnRlci54dWxVVAUAAxrhY0tVeAAAUEsBAhcDFAAAAAgAT6aL
O9Rl/E6AAQAA9QIAAAsADQAAAAAAAQAAAO2BjAMAAGluc3RhbGwucmRmVVQFAAOGoiJLVXgAAFBL
AQIUABQAAgAIACo/PzioHh6ARQAAAHgAAAAPAAAAAAAAAAAAIAAAAEoFAABjaHJvbWUubWFuaWZl
c3RQSwUGAAAAAAUABQBmAQAAvAUAAAAA

TabVisited

In Firefox 3.6 and above it is no longer possible to use the selected attribute to style unvisited and visited tabs with code in userChrome.css. In Firefox 3.6 and above only the selected tab gets a selected="true" attribute. In previous Firefox 3 and 3.5 versions the visited tabs get a selected="false" attribute, but that attribute was removed to fix buggy behavior [4], [5].

For more information about the TabVisited extension please visit: User:Dickvl/TabVisited