Google Chrome:Facebook上的JQuery内容脚本 [英] Google Chrome: JQuery content script on Facebook

查看:188
本文介绍了Google Chrome:Facebook上的JQuery内容脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Chrome,我正在编写浏览器扩展程序。我试图将JQuery 2.0.3注入Facebook作为上下文脚本。只是为了看看是否可以,我正在尝试抓住消息页面上的文本区域。我直接在Javascript控制台中输入此行:

I am using Google Chrome and I'm writing a browser extension. I'm trying to inject JQuery 2.0.3 into facebook as a context script. Just to see if I could, I'm trying to grab the text area on the message page. I'm typing this line directly into the Javascript console:

$('textarea[name="message_body"]');

而不是获取一个JQuery对象,我收到这个错误:

Instead of getting a JQuery object I'm getting this error:

Error: <![EX[["Tried to get element with id of \"%s\" but it is not present on the page.","undefined"]]]>

Facebook是否具有反jquery措施,还是有其他事情发生,我做错了?
像往常一样,感谢所有提前!

Does facebook have anti-jquery measures or is there something else happening that I'm doing wrong? As usual, thanks all in advance!

推荐答案

您正在访问 $() 在Facebook页面定义的函数,这与jQuery无关。要从javascript控制台访问内容脚本的执行上下文,您需要从位于窗口底部的下拉框中选择它:

You are accessing a $() function defined in the Facebook page, which has nothing to do with jQuery. To access the execution context of you content scripts from the javascript console, you need to select it from the drop down box located at the bottom of the window:

而不是< page context> ,您必须选择 chrome-extension://<您的扩展ID>

这篇关于Google Chrome:Facebook上的JQuery内容脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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