Reputation: 642
My question concerns running script that exists on the page the user is loading. For example on a youtube video if you go to the console and type:
player = document.getElementById('movie_player');
You can then interact with the player by using :
player.getDuration();
or
player.playVideo();
But I searched and researched for a way to do this from a firefox extension and all I could find find was a reference to XPCNativeWrapper but no real solution.
So let's say I want to get the video duration from the firefox extension, in my main.js code I use page-mod to detect a youtube video page loading. Then in the contentScriptFile I get the Id of the embeded flash player but I can't interact with it. In fact in extension devolopement console I get an error saying that the function getDuration() does not exists. From what I read on other post this has to do with Xray vision (XPCNativeWrapper).
My problem is I don't know how to use Xray vision to send commands to the content of the webpage I do not own.
PS: I am new to firefox extension programming and it might seem very easy for you but I would really be grateful for any help or lead.
Upvotes: 2
Views: 368
Reputation: 642
Sorry for asking I found the answer next to my question on the right side panel! For those who are looking for the same problem :
var player = document.getElementById('movie_player').wrappedJSObject;
should do the trick.
Upvotes: 1