Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As the title says, I want to run a piece of javascript whenever firefox starts.

My actual problem is that the firefox window always opens at 0,0 in the screen. I am on a debian system, with dwm as my window manager. I can successfully change the size of new firefox windows (by passing in the -geometry commandline options), but all attempts to coax it to remember its location have failed.

What works is the following bookmarklet:

javascript:window.moveTo (32, 32);

So now, my problem could be resolved if I could get this piece of javascript to run everytime firefox starts. I've tried putting it in user.js (without the 'javascript:'), but to no avail.

share|improve this question

What happens if you set it as your home page?

share|improve this answer
that works (and the deserving upvote given), but doing it this way means that I'll lose the ability to restore my session. See my own answer for a less hackish way, but as a quick and dirty solution, this was nice :) – Manav Aug 1 '11 at 15:08
looks like I cannot answer my own question for the next 3 hours, so till then here's the keyword: userChrome.js – Manav Aug 1 '11 at 15:13
@KnickerKicker, what does your homepage have to do with restoring a session? – Synetech Aug 2 '11 at 2:58
@Synetech - the browser will be automatically repositioned only when the browser is set to open the home page by default when it runs. It is an mutually exclusive option: either I set firefox to open the home page, or restore the previous session. – Manav Aug 5 '11 at 7:54
Oh, so you’re using a built-in session restore function. Okay, I see. Have you considered using an extension instead (which would provide much more functionality)? – Synetech Aug 6 '11 at 1:57
up vote 1 down vote accepted

download the userChrome.js extension now, enter the following line into /chrome/userChrome.js

window.moveTo (32, 32);

and you're done

share|improve this answer

Try creating a new home page (a HTML) and put it there, between <script> tags.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .