What I can tell you (no too much) is:
1. Review [this code](http://jsfiddle.net/u3dDk/1/), I think that you already see it but if not.. :)
2. If you understand how it works (having read [documentations of function](https://developer.mozilla.org/en-US/docs/DOM/MutationObserver), etc.), c/p [the code](http://stackoverflow.com/a/13278380/1505348) and make it work, and **then** adapting it.
3. If you already know how it works and you run it without problems so your problems is *adapting it*, then you should use debug tools, such as console of firefox or a JS specific IDE