I am trying to add an image to every tweet in my timeline by building a chrome plugin. Currently the plugin works for tweets loaded when the page is refreshed. But how do i extend the plugin to include the "new tweets" and the "past tweets" which are dynamically loaded in my timeline?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can check for them periodically using
setInterval()
or search if there is any event that is called by Twitter script after pulling tweets.There are also some events that look relevant, but I did not test them, eg.:
DOMNodeInserted
- fires when a node has been added as a child of another node,EDIT:
I see that Twitter uses jQuery. jQuery in turn has
jQuery.ajaxPrefilter()
function that is called before AJAX request is being made. You can probably use it to bind your event to thejqXHR
object (which isXMLHttpRequest
object, I suppose) and do different things depending on what it will return. See the documentation ofjQuery.ajaxPrefilter()
and the documentation onXMLHttpRequest
.