如何聆听twitter中动态加载的推文? [英] how to listen to tweets loaded dynamically in twitter?

查看:210
本文介绍了如何聆听twitter中动态加载的推文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过构建一个Chrome插件来为我的时间线中的每条推文添加图片。目前该插件适用于页面刷新时加载的推文。但是,如何扩展插件以包含在我的时间轴中动态加载的新推文和过时推文?

解决方案

您可以使用 setInterval()或搜索如果有任何事件在推文后被Twitter脚本调用。



还有一些看起来相关的事件,但我没有对它们进行测试,例如:



编辑

我看到 Twitter使用jQuery 。 jQuery依次具有 jQuery.ajaxPrefilter() 。你可以用它来将你的事件绑定到 jqXHR 对象(我猜想它是 XMLHttpRequest 对象)取决于它会返回什么不同的东西。请参阅 jQuery.ajaxPrefilter() 有关 XMLHttpRequest 的文档。

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?

解决方案

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 the jqXHR object (which is XMLHttpRequest object, I suppose) and do different things depending on what it will return. See the documentation of jQuery.ajaxPrefilter() and the documentation on XMLHttpRequest.

这篇关于如何聆听twitter中动态加载的推文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆