<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>I know YouTube has been done to death (The same thing over and over) but i have something reasonably unique i'd like to try.

I looked at Michael Sheldon's FLV Player userscript [from http://www.mikeasoft.com/], which takes the youtube video player and replaces it with a pure &lt;embed&gt; tag, but i'd like to use jeroen wijering's flash player as the replacement.

The flash player needs to have a .flv in it's &quot;&amp;file=&quot; flashvar.

So i have removed the &lt;embed&gt; code from the orignal script and the following is the result (Not including header info - it's running on http://youtube.com/* and http://www.youtube.com/*)

[Code]
var reg = /&amp;t=[\w-]{10,}/ig
var html = document.getElementById(&quot;interactDiv&quot;).innerHTML;
extra = reg.exec(html);
if (extra) {
	var flashplayer = document.getElementById(&quot;playerDiv&quot;);
	var title = document.getElementById(&quot;video_title&quot;);
	var embedded = document.createElement(&quot;div&quot;);
	URL = window.location.href;
	var code = URL.substr(URL.lastIndexOf('v=')+2);
	if(code.indexOf('&amp;') != -1) {
		code = code.substr(0,code.indexOf('&amp;'))
	}
	flvURL = 'http://youtube.com/get_video?video_id=' + code + extra[0];
	embedded.innerHTML = &quot;&lt;e mbed src=&quot;http://www.jeroenwijering.com/embed/mediaplayer.swf&quot; width=&quot;455&quot; height=&quot;340&quot; allowfullscreen=&quot;true&quot; flashvars=&quot;&amp;file=&quot; + flvURL + &quot;&amp;height=340&amp;width=455&amp;type=flv&quot; &gt;&lt;/e mbed&gt;&quot;;
	title.parentNode.insertBefore(embedded, title.nextSibling);
	flashplayer.parentNode.removeChild(flashplayer);
}
[/code]
(Spaces added to embed to stop it embedding in the page)

The original script work fine, and does it's job well, however, the code above doesn't even remove the old player (Which, from what i know of coding user scripts, it really should)

My number one suspicion is that the /s in the URLs are causing the rest of the script to be commented out and therefore not run, but i'm not very good at this stuff.

If someone could help, that'd be great.</body>
  <body-html>&lt;p&gt;I know YouTube has been done to death (The same thing over and over) but i have something reasonably unique i'd like to try.&lt;/p&gt;

&lt;p&gt;I looked at Michael Sheldon's FLV Player userscript [from &lt;a href=&quot;http://www.mikeasoft.com/&quot;&gt;http://www.mikeasoft.com/&lt;/a&gt;], which takes the youtube video player and replaces it with a pure &amp;lt;embed&gt; tag, but i'd like to use jeroen wijering's flash player as the replacement.&lt;/p&gt;

&lt;p&gt;The flash player needs to have a .flv in it's &quot;&amp;amp;file=&quot; flashvar.&lt;/p&gt;

&lt;p&gt;So i have removed the &amp;lt;embed&gt; code from the orignal script and the following is the result (Not including header info - it's running on &lt;a href=&quot;http://youtube.com/&quot;&gt;http://youtube.com/&lt;/a&gt;* and &lt;a href=&quot;http://www.youtube.com/&quot;&gt;http://www.youtube.com/&lt;/a&gt;*)&lt;/p&gt;

&lt;p&gt;[Code]
&lt;br /&gt;var reg = /&amp;amp;t=[\w-]{10,}/ig
&lt;br /&gt;var html = document.getElementById(&quot;interactDiv&quot;).innerHTML;
&lt;br /&gt;extra = reg.exec(html);
&lt;br /&gt;if (extra) {
&lt;br /&gt;	var flashplayer = document.getElementById(&quot;playerDiv&quot;);
&lt;br /&gt;	var title = document.getElementById(&quot;video_title&quot;);
&lt;br /&gt;	var embedded = document.createElement(&quot;div&quot;);
&lt;br /&gt;	URL = window.location.href;
&lt;br /&gt;	var code = URL.substr(URL.lastIndexOf('v=')+2);
&lt;br /&gt;	if(code.indexOf('&amp;amp;') != -1) {
&lt;br /&gt;		code = code.substr(0,code.indexOf('&amp;amp;'))
&lt;br /&gt;	}
&lt;br /&gt;	flvURL = 'http://youtube.com/get_video?video_id=' + code + extra[0];
&lt;br /&gt;	embedded.innerHTML = &quot;&amp;lt;e src=&quot;http://www.jeroenwijering.com/embed/mediaplayer.swf&quot; height=&quot;340&quot; width=&quot;455&quot;&gt;&amp;lt;/e&gt;&quot;;
&lt;br /&gt;	title.parentNode.insertBefore(embedded, title.nextSibling);
&lt;br /&gt;	flashplayer.parentNode.removeChild(flashplayer);
&lt;br /&gt;}
&lt;br /&gt;[/code]
&lt;br /&gt;(Spaces added to embed to stop it embedding in the page)&lt;/p&gt;

&lt;p&gt;The original script work fine, and does it's job well, however, the code above doesn't even remove the old player (Which, from what i know of coding user scripts, it really should)&lt;/p&gt;

&lt;p&gt;My number one suspicion is that the /s in the URLs are causing the rest of the script to be commented out and therefore not run, but i'm not very good at this stuff.&lt;/p&gt;

&lt;p&gt;If someone could help, that'd be great.&amp;lt;/embed&gt;&amp;lt;/embed&gt;&lt;/p&gt;</body-html>
  <created-at type="datetime">2007-04-28T16:35:03Z</created-at>
  <forumable-id type="integer">1</forumable-id>
  <forumable-type>Forum</forumable-type>
  <id type="integer">1424</id>
  <topic-id type="integer">387</topic-id>
  <updated-at type="datetime">2008-05-25T06:12:48Z</updated-at>
  <user-agent nil="true"></user-agent>
  <user-id type="integer">26618</user-id>
</post>
