Facebook JavaScript API for Google chrome extension [英] Facebook JavaScript API for google chrome extension
问题描述
我自动将chrome扩展名与特定页面帖子相似。
使用简单的弹出控制器和后台线程来处理fb api interactive
我无法通过官方示例方法将facebook js api加载到扩展页面。
脚本 jssdk 被chrome开发工具加载并执行。
但是window.FB没有被加载的脚本定义!!!
- 我还手动添加脚本标签。
- 它出现了后台线程和弹出窗口。
- 如果注入iframe加载页面,它将成功加载window.FB并弹出登录/验证窗口。但是它有一个跨域问题!
- div#fb-root存在。
- menifest.json content_security_policy
- script-src'self' https ://connect.facebook.net ; object-src'self'
我没有一个解决方案,但这可能会导致您的方向正确。
问题可能在于扩展文档的document.location。对于在扩展范围内运行的JavaScript,协议是chrome-extension://,而许多JS库都希望使用http或https。
从jssdk文件中查看以下行,FB似乎也假设:
var k = typeof j =='undefined'? location.protocol.replace(':',''):j? 'https':'http';
尝试调试这些情况,用以下代码替换上面的行:
var k ='http';
希望这有帮助。 >
I make a chrome extension to like specific page posts automatically. With a simple popup controller and background thread to handle fb api interactive
I cannot load facebook js api into extension page with official example method.
The script jssdk was loaded and executed checked by chrome developer tools.
But window.FB is not defined by script loaded!!!
- I also add script tag manually.
- It appeared both background thread and popup window.
- If inject with iframe to load page, it will success loaded window.FB and popup a login/authenticate window. But it had a cross domain problem!
- The div#fb-root is exist.
- menifest.json has content_security_policy
- script-src 'self' https://connect.facebook.net; object-src 'self'
I don't have a solution, but this might lead you in the right direction.
The problem might be with the document.location of the extension document. For javascript running in the extension scope, the protocol is "chrome-extension://", while many JS libraries expect either "http" or "https".
From looking at the following line at the jssdk file, it seems that FB make this assumption as well:
var k = typeof j == 'undefined' ? location.protocol.replace(':', '') : j ? 'https' : 'http';
Try debugging these cases, replacing the line above with something like:
var k = 'http';
Hope this helps.
这篇关于Facebook JavaScript API for Google chrome extension的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!