I’m developing a Firefox addon and I would like to use facebook sdk in it. One of the features that I like to use is the callback that is triggered when a like button is pressed. In detail I mean this one:
FB.Event.subscribe(‘edge.create’, function() {dump(“like pressed”); });
Currently I’m doing it this way. I open a layer in the current window with an iframe. That iframe contains the facebook api + the features that I would like to use. My problem is that I can’t call my addons functions from the inside of that iframe. What I would like to do would be something like:
FB.Event.subscribe(‘edge.create’, function() {fbClass.like(); });
In my mind I’ve one idea. I think to make it safe it would be ok to create an empty hidden div container in that iframe, attach an eventlistener to it and fill it with json. Then use firefox safe json loader to receive it.
Any other idea how I could accomplish that one without creating a security issue?
I tried porting the FB api to FF but it leaded into a waste of time. Sure I got some features work but it’s that complex to debug it and in case if the api changes I would have to do it again. So I think the iframe way would be a much better one.
I would suggest to you that use the Add-on SDK makes this task probably easier. You could add your code to the page using
PageModand from the content script calls your addon’s function usingpostMessage. This also helps to you decoupled the content code from the addon code.