0

Sorry, I think this post probably exists but I couldn't find it. Maybe I am using the wrong words.

I am making a Chrome extension that looks at Facebook posts and does something to them. My Content Scripts gets the posts correctly, but the new ones that are generated as the user scrolls down are not captured since they came later. I tried hooking into an ajaxComplete handler, but that didn't work (Chrome-extension Javascript to detect dynamically-loaded content) I am not sure if I did something wrong or if this isn't what I want.

So, how can I detect these new posts and change the contents of them before the user notices? Any tips are appreciated.

Thanks!

Community
  • 1
  • 1
skaz
  • 21,962
  • 20
  • 69
  • 98

1 Answers1

0

You should be watching for DOM mutation events.

See this canonical question and its answer.

Note that DOMSubtreeModified and the like are considered deprecated, and DOM Mutation observers are the modern way.

You could also take a look at Mutation Summary library that's more friendly to use.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206