I'm trying to write a Greasemonkey script that alters keywords in Twitter posts. Trouble is, the content is "late loading" and is added to at the users request.
If I were adding event listeners to the added elements, I could use JQuery's delegate()
. As I simply want to change the content when it loads, this doesn't appear to be appropriate.
Mutation Events seem to fit the bill. They are Gecko specific, but this doesn't matter much for a Greasemonkey script. Problem is, they have been depreciated and for a set of very good reasons.
Of course I could use a timer and poll the DOM at regular intervals, but this just seems icky.
How can I detect additions to the DOM and react to the inserted elements?