Jump to content

A fix for the Youtube embed code


VampyrPrince

Recommended Posts

So I was finally tired of the fullscreen button not working, and decided to research a solution. I found an old userscript that forces old embed codes for YouTube to use a new html5 iframe. Which is great, but not really that great because there was no fullscreen button. I then took the time to look at the script and decided I'd try adding some simple code that would hopefully allow the button to work, and it did.

 

Here is the userscript, http://userscripts-mirror.org/scripts/show/116935.html

 

You will need to use Greasemonkey, or Tampermonkey depending on your browser. Do not use the Chrome native handler for userscripts as I do not know how you would make the edit without manually downloading the script, nor do I know if it would work.

 

Once you have your handler installed, download the script above. You could edit in the code there, but it's easier if you do it from the dashboard in tampermonkey. You can reach the dashboard by clicking on the Chrome app icon for it next to the address bar. Once there click on the script name and simply add this code to line 89:

 

iframe.setAttribute('allowfullscreen', 1);

 

------

 

The section should look something like this with the edit.

 

function createNode(id, paramsString, width, height) {
var iframe = document.createElement("iframe");
iframe.setAttribute("class", "youtube-player");
iframe.setAttribute('type', 'text/html');
if (width != null) {
iframe.setAttribute('width', width);
}
if (height != null) {
iframe.setAttribute('height', height);
}
iframe.setAttribute('frameborder', 0);
iframe.setAttribute('allowfullscreen', 1);
var src = "//www.youtube.com/embed/" + id;
if (paramsString != "")
src = src + "?" + paramsString;
iframe.setAttribute('src', src);
return iframe;
}
Enjoy the fabulous fullscreen experience. :tongue:
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...