Chrome 拡張機能を Facebook に統合したいのですが、fbAsyncInit を実行できません。
これは、私の拡張機能 (editPage.html) の html にあるものです。
<body>
<div id="fb-root"> </div>
<script type="text/javascript" src="js/initializeFacebook.js"></script>
....
</body>
次のように呼び出して、この html を開きます。
chrome.tabs.create({
url : chrome.extension.getURL('editPage.html'),
selected : true
}, function(tab) {
});
これは initializeFacebook.js の内部です (このドキュメントから取得: https://developers.facebook.com/docs/reference/javascript/ )
( function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "https://connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function() {
console.log('lala');
// init the FB JS SDK
FB.init({
appId : 'XXXX',
status : true,
xfbml : true
});
FB.ui({
method : 'feed',
name : 'The Facebook SDK for Javascript',
caption : 'Bringing Facebook to the desktop and mobile web',
description : ('Description'),
link : 'https://developers.facebook.com/docs/reference/javascript/',
picture : 'http://www.fbrell.com/public/f8.jpg'
}, function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
});
};
これは、Facebook に関連する manifest.json にあるものです。
"content_security_policy": "script-src 'self' https://connect.facebook.net; object-src 'self'",
何が起こっているかというと、editPage.html ページが開かれ、ヘッダーに実際に次のように表示されます。
<script id="facebook-jssdk" src="https://connect.facebook.net/en_US/all.js"></script>
だからSDKはそこにあります...私は推測します...しかし、console.log('lala')は表示されず、fbAsyncInitをトリガーする方法がありません。コンソールにもエラーは表示されません。
Facebook が切断されていないことを確認するために、他のすべての Chrome 拡張機能を無効にしました。
それだけです、何か考えはありますか?
前もって感謝します!