Run Bookmarklet/Javascript on Firefox startup

1

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.

Manav

Posted 2011-08-01T10:35:14.250

Reputation: 153

Answers

1

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

window.moveTo (32, 32);

and you're done

Manav

Posted 2011-08-01T10:35:14.250

Reputation: 153

2

What happens if you set it as your home page?

pjc50

Posted 2011-08-01T10:35:14.250

Reputation: 5 786

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 – 2011-08-01T15:08:22.023

1looks like I cannot answer my own question for the next 3 hours, so till then here's the keyword: userChrome.js – Manav – 2011-08-01T15:13:40.617

@KnickerKicker, what does your homepage have to do with restoring a session? – Synetech – 2011-08-02T02:58:53.690

@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 – 2011-08-05T07:54:13.957

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 – 2011-08-06T01:57:10.550

0

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

sinni800

Posted 2011-08-01T10:35:14.250

Reputation: 3 048