firefox snippets

Disable javascript resizing of Firefox

Tagged resize, firefox, browser, koon muuttaminen, javascript, fã¶nstrets dimensioner  Languages bash

There is absolutely not a single developer in the world who knows what size I like my browser, although many people think they do. To prevent resizing of FF make the following steps.

  1. Open browser preferences
  2. Choose "Content"
  3. Choose "Advanced" on the "Enable javascript" preference
  4. Untick "Move or resize existing windows"

Notes on how to develop a Firefox extension

Tagged firefox, extension, development, notes  Languages 

Create a new profile for extension development

Tweak Firefox configuration for extension development\_up\_extension\_development\_environment

Create a skeleton extension

Extract it to the your project folder, for example:


Setup Firefox to load your extension

Follow these instructions to configure Firefox to load your extension from /home/name/projects/my_extension:\_up\_extension\_development\_environment\#Custom\_code\_location\_up\_extension\_development\_environment\#Using\_directories\_rather\_than\_JARs

Install the Extension developer

Start Firefox with the development profile

firefox-bin -P development -no-remote

To start the default profile use:

firefox-bin -P THE_PROFILE_NAME -no-remote

Build your extension

The extension wizard includes a build script, but it might be a good idea to upgrade it to the latest version, which can be found here (including a Windows build script):\_build\_script


If you're on windows and using CygWin, you might get this error:

./ line 6: $'\r': command not found
./ line 29: $'\r': command not found
./ line 40: $'\r': command not found
./ line 70: syntax error near unexpected token $'do\r''
'/ line 70: for CHROME_SUBDIR in $CHROME_PROVIDERS; do

The solution is to run the dos2unix command on the *.sh files:


Opening a new tab with Firefox

Tagged open, tab, firefox  Languages javascript

Note that this only works from a Firefox extension:

function openTab(url, focus) 
    var tab = getBrowser().addTab(url);

      getBrowser().selectedTab = tab;
    return tab;

Restricting memory usage of Firefox cache

Tagged firefox  Languages bash

Firefox hogs a lot of memory when using pages using Ajax enabled web pages. I need to restart the browser many times during a day at the office. This hack seems to have fixed that issue.

Open the location about:config, right click and create a new key of integer type.





Trusted and sensitive email protection with GPG using Gmail with Firefox

Tagged firefox, gmail, gpg, trusted emails, sensitive emails, firegpg  Languages bash

It's really simple to use GPG to encrypt and/or sign email you send through Gmail.

Generate your private key.

gpg --gen-key

Extract your public key, which you will send to people you need to communicate securely with.

gpg --armor --export > my_public_pgp_key

Install FireGPG and restart the browser. Use GPG in Gmail.

How to create a separate development profile for Firefox

Tagged firefox, development, profile, mode  Languages bash

Extensions slow down Firefox so I prefer disabling all but the most important Firefox extensions when coding.

Here's how to do it:

  1. First, create a development profile following these instructions
  1. Next, create a shortcut that starts Firefox in development mode:
# Mac OSX
/Applications/ -P development -no-remote

# Linux
/usr/lib/firefox/firefox-bin -P development -no-remote

# Windblows
"C:\Program Files\Mozilla Firefox\firefox.exe" -P development -no-remote

Deleting favicons in Firefox 3

Tagged mac, osx, firefox, favicon  Languages bash

To force Firefox to show your updated favicon (updating favicon.ico is not enough), first quit Firefox. Then issue the following commands in the terminal:

$ cd /Volumes/Macintosh\ HD/Users/christian/Library/Application\ Support/Firefox/Profiles/46xov8kt.default
$ sqlite3 places.sqlite 
SQLite version 3.5.0
Enter ".help" for instructions
sqlite> delete from moz_favicons;
sqlite> update moz_places set favicon_id = NULL;
sqlite> .quit

How to use the Geolocation API

Tagged geolocation, firefox  Languages javascript

Firefox 3.1 supports the geolocation API specification.

Try copying this code and running it in Firebug:

function showMap(position) {
  // Show a map centered at (position.coords.latitude, position.coords.longitude).


A Mozilla Jetpack extension template

Tagged jetpack, extension, firefox, plugin  Languages javascript

Jetpack extension:

jetpack.future.import('selection');'img').add(function(target) ({
  label:   "Post to",
  icon:    "http://xxx/icon.png",
  command: function() {
    var url = "";

    var selectedText = jetpack.selection.text || '';
    var sourceImage   = target.node.src;
    var sourcePage = jetpack.tabs.focused.url;

    url += encodeURI('image') + '=' + encodeURI(sourceImage);
    url += '&' + encodeURI('description') + '=' + encodeURI(selectedText.substr(0, 200));; 

Installation page:

<html lang="en">
    <title>The Jetpack Feature</title>
    <link rel="jetpack" href="/javascripts/jetpack-extension.js" name="com extension" />