在Facebook上使用动态帖子的Chrome扩展程序 [英] Chrome Extension on Facebook with Dynamic Posts

查看:151
本文介绍了在Facebook上使用动态帖子的Chrome扩展程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,我认为这篇文章可能存在,但我找不到它。也许我使用的是错误的词语。



我正在制作一个Chrome扩展程序,用于查看Facebook帖子并对它们做些什么。我的内容脚本可以正确地获取帖子,但是随着用户的滚动而产生的新帖子不会被捕获,因为它们迟了。我试图挂钩到一个ajaxComplete处理程序,但这并没有工作(Chrome浏览器) -extension Javascript来检测动态加载的内容)我不知道如果我做错了什么或者如果这不是我想要的。

那么,如何在用户注意之前检测这些新帖子并更改它们的内容?任何提示都会被赞赏。



谢谢! 观看DOM突变事件。

请参阅规范问题其答案



请注意, DOMSubtreeModified 等被认为不推荐使用,并且DOM突变观察者是现代的方式。



您还可以查看更易于使用的突变摘要库

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!

解决方案

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.

这篇关于在Facebook上使用动态帖子的Chrome扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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