Alexandru Luchian
Alexandru Luchian

Reputation: 2780

HTML elements hooks in firefox add-ons api

I want to write a Firefox add-on.

I need to monitor the contents of a DIV element.

Is there a way to put a hook or subscribe to the modification of a certain HTML element?

I don't want to poll the contents of the DIV (per say) every second, would be nice to be notified when it is changed.

Thank you.

Upvotes: 0

Views: 425

Answers (2)

Alexandru Luchian
Alexandru Luchian

Reputation: 2780

Found how to do this!

function onLoadDoThings(){  
 document.getElementById('changingDiv').addEventListener('DOMSubtreeModified',function(){
    alert(document.getElementById('changingDiv').innerHTML);
  }
,false);
}

Upvotes: 2

Chris Haas
Chris Haas

Reputation: 55447

Instead of writing an extension have you thought about writing a Greasemonkey script? Much easier and no compiler needed. I've also seen programs that can convert scripts to XPI's but haven't tried them.

http://www.greasespot.net/

Upvotes: 0

Related Questions