Valid YouTube Embed

By Matthew Hill Last update Dec 30, 2010 — Installed 2,369 times.


Script Summary: Provides 100% valid and semantic (XHTML 1.0 Strict & Transitional) embed code for YouTube videos.

Script homepage

Thumb

Features

  • Provides 100% valid and semantic (XHTML 1.0 Strict & Transitional) embed code for YouTube videos.
  • Allows the option to replace the original embed button with the valid embed button (default settings keeps both visible).

Example

Default YouTube Embed (8 errors strict, 7 errors transitional):

<object width="425" height="344">
  <param name="movie" value="http://www.youtube.com/v/CQzUsTFqtW0?fs=1&hl=en_US"></param>
  <param name="allowFullScreen" value="true"></param>
  <param name="allowscriptaccess" value="always"></param>
  <embed src="http://www.youtube.com/v/CQzUsTFqtW0?fs=1&hl=en_US"
  type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"
  width="425" height="344">
</embed>
</object>

Valid YouTube Embed (0 errors strict, 0 errors transitional):

<object type="application/x-shockwave-flash" width="640" height="385"
data="http://www.youtube.com/v/CQzUsTFqtW0">
  <param name="movie" value="http://www.youtube.com/v/CQzUsTFqtW0" />
</object>

Default settings

var replaceOriginal = false

Instructions

  1. Install my Valid YouTube Embed User Script.

If you want to deviate from the default settings, follow these next three steps:

  1. Assuming you are using Firefox, open up the Greasemonkey User Scripts Manager in Firefox by selecting; Tools > Greasemonkey > Manage User Scripts...
  2. Click the edit button in the bottom left-hand corner of the window. If not done automatically, choose your favourite text editor (such as Notepad) to open up my Valid YouTube Embed User Script for editing.
  3. In the EDIT BELOW section of the script, set the variable (replaceOriginal) to either true or false depending whether you want the original button to be removed or visible respectively.

Changelog

version 0.4

  • Works with the new YouTube video pages.
  • Allows the option to replace the original embed button with the valid embed button.

version 0.3

  • CSS fixes.

version 0.2

  • CSS fixes.

version 0.1

  • Initial release.
  • Inserts an additional text field in the video details box containing the valid embed code.

Ambitions

  • Allow the options given when using the original embed code (such as custom width and height).
  • Allow the option to replace the original embed button with the valid embed button.

If you think of any additional improvements that can be made to my Valid YouTube Embed User Script, please let me know by starting a discussion.

Known bugs

So far so good... If you find any bugs in my Valid YouTube Embed User Script, please let me know by starting a discussion.

Learn more

Visit the Valid YouTube Embed's homepage at http://www.matthewhill.name/#user-scripts.

Other scripts

Check out my other scripts, such as Remove YouTube Adverts which has over 2,900 installs!

Final words

If you like my Valid YouTube Embed User Script, please become a fan and/or write a short review. You wouldn't think it, but it really means a lot to get feedback of any nature. Thanks!