Reputation: 95
Due to the Content Security Policy of manifest version 2, I can't add a facebook like button to my chrome extension option page.
Take a like button for "google.com" as an example. I have followed the instruction on facebook dev centre, added
<div id="fb-root"></div>
<script type="text/javascript" src="js/facebook-jssdk.js"></script>
<div class="fb-like" data-href="http://www.google.com" data-send="true" data-width="450" data-show-faces="false" data-font="arial"></div>
into the options.html; and added
(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_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
into the js/facebook-jssdk.js; and added this line
"content_security_policy": "script-src 'self' https://connect.facebook.net; object-src 'self'",
into the manifest.json
I can get the facebook buttons working when open file://home/options.html. However, when it is opened via chrome://extensions, the buttons do not show up.
What can I do to get the buttons?
Thank you.
Upvotes: 1
Views: 1302
Reputation: 717
A simpler solution would be to use an iframe rather than their javascript sdk. The only downside is that you won't be able to include a "Send" button.
Upvotes: 3