How to use youtube API in firefox extension? - javascript

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.

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.

Related

How to get webcam feed in chrome extension persistently when chrome is open?

I am trying to make a chrome extension where I need access to the webcam feed once the user has allowed permission and has toggled on button in the extension popup. The feed should (and the extension) should keep running persistently until the user has stopped the feed via the control in the popup or has exited chrome.
Unfortunately, there's not sufficient information as to how to do this, let alone access webcam from the extension. I did read the related answer where its mentioned to use content scripts but there's no example code for it. (And no documentation as well).
Also, unfortunately I don't have enough working code to give insight of my progress.

How to send messages to the tab after page load in native safari app extension

In native safari extension,How to call dispatchMessageToScript after page loaded ,
In chrome we are using " chrome.tabs.onUpdated.addListener(listener);” function in background script and this is giving us tab URL and status with ‘complete’ then we are sending our message to the particular tab.
Please help me out to find an alternate solution for safari app extension
Your question is a bit unclear and hard to read. But, if you are asking how to wait until the DOM is loaded before executing, then that is exactly what the example in the Apple documentation shows, refer to the section 'Execute Your Code After the Webpage Loads'.

Audio recording with HTML5

I'm trying to implement audio recording in a website. Basically the user should be able to press a button and speak something into the microphone. The recorded audio should then be sent to the server for further processing. I realise that you can do this with Flash, but for now I'm trying to avoid that.
I found several resources on the internet about it (i.e. link) but as it seems, this functionality is not widly supported yet. I experienced differences betweet the used browser and between the used operating system. For instance, the Chrome Browser doesn't seem to access any microphone on Linux correctly. So i was wondering if anyone knows a good resource to dive into this. Or maybe someone tried to set up something like this himself, and can help with some suggestions about where the limitations of HTML5 and the JavaScript Web Audio API are right now.
Thanks!
As of Chrome Version 27.0.1453.56 beta Mac, audio recording works with this demo application https://github.com/mattdiamond/Recorderjs
This app returns back a WAV file for the user which can be uploaded to the server.
If you want a truly robust solution that works on most desktop web browsers, you may need to resort to Flash.
This article covers up pretty well the current state of audio video capture possibilites using HTML5:
http://hdfvr.com/html5-video-recording
Also for just audio capture, here's a gitHub project that records audio to mp3 directly from the browser:
https://github.com/nusofthq/Recordmp3js

How do I get microphone access in Google Chrome through getUserMedia?

I've tried many different types of Javascript code, and I've changed my microphone settings in Windows and in Chrome's settings, and nothing has worked. I've tried enabling "Web Audio Input" in chrome://flags but nothing works, at all. Does anyone have any suggestions? Camera access works and I can easily do HTML5 camera manipulation but any microphone tasks don't work.
The following JSFiddle doesn't work on my browser: http://jsfiddle.net/BWYu9/3/
Give it a shot in the Canary build of Chrome. I think the ability to do this with an audio stream is pretty new - although for some reason I can't find a link to the Chromium issue.
You can try with Chrome Canary or perform the following steps:
open google.com
speak on microphone
if the answer is "cannot recognize speech it might be that your microphone is not recognized. (this will help to identify the source of the problem)
See the following link for this issue:
https://code.google.com/p/chromium/issues/detail?id=226327
I have found that many different problems can accrue with the microphone in the Google search window of chrome. The main problem I have found to be the most upsetting is after a Java up date I find it not working, but everything appears to be working fine with all my audio settings. My microphone levels are good in sound properties a for Google voice and video chat. but in the search bar of Google chrome the thing is still not working to solve the problem I discovered that resetting my Integrated Microphone Array to default had been canceled and after resitting it again to default this go the microphone to work.

Permission Denied message when I do an open xhhtprequest in internet explorer

I am writing a javascript routine that uses xhttprequest to access the ebay API. I am running the script on internet explorer. I was testing it on the ebay API sandbox and it was working ok. Here is the relevant part of the code:
var url = "https://api.sandbox.ebay.com/ws/api.dll";
var Req = new ActiveXObject("Msxml2.XMLHTTP");
Req.open("POST",url,false);
I stopped testing for a couple of weeks and then when I ran it again the script halted at the open command with the message 'Permission Denied'
I tried everything I could think of and searched the internet but couldn't find an answer.
Then I decided to try running the script against the live ebay server. I changed the url to https://api.ebay.com/ws/api.dll and the script worked.
Can anyone provide an explanation or suggest a reason for this. It is doing my head in
Thanks
Paul
As far as i know that's XSS and it's not allowed in any browser, unless things become archaic!
The reason why they don't allow that is because it would make stealing cookies, pwds, and anything merely a child's play.
So, you won't be able to use XHR from any page to another domain, UNLESS you have for example an addon (lets say in firefox) that drives all your requests for you, which is far fetched...

Categories

Resources