views:

48

answers:

1

Hi,

I'm trying to write an extension that monitors every time someone types hits enter when using the address bar. The steps would be something along the lines of

  1. User types in a bunch of text in the address bar and hits Enter
  2. My addon springs to life and recieves what the user typed in
  3. My addon then decides what to do with the string the user typed in.

I get the url in step 2 by using var url = window.location.href. I also have most of step 3 written out already. The only probably I can't seem to figure out is how to monitor every tab to watch for when the user hits return.

I'm really new to javascript, but regardless of that, any information would be appreciated.

This is what my myaddon.xul file looks like:

<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
<script type="application/x-javascript" src="chrome://myaddon/content/myaddon.js" />
<textarea id="urlbar" ontextentered="return myaddon_URLBar(param);" />

Thanks in advanced!

+8  A: 

I think the following link would help. You need to implement Progress Listeners, they allow extensions to be notified whenever some events happen associated with the document. You can also extend this to multiple tabs. Please try the link

https://developer.mozilla.org/en/Code_snippets/Progress_Listeners#Example.3a_Notification_when_the_value_in_Address_Bar_changes

Hope it helps :)

sumit_programmer