Skip to content

Link to YouTube Video Pages from Embedded YouTube Videos

In my last blog entry, I mentioned that there were two Greasemonkey scripts that I was working on, both of which would be used with Digg.com. However, putting finishing touches on these scripts is taking longer than expected because of the recent redesign of Digg. Functionality-wise, the scripts are complete, and I have, in fact, been using them. However, the design of them, which I must admit I cannot be excited about correcting, still requires some work. I did not find that correcting errors not related to functionality to be very interesting, although I might have worked on that if I did not come up with another idea for a Greasemonkey script. This idea, however, may not necessarily be considered my idea, and I discuss that next.

I recently came up with the idea of inserting links below embedded YouTube videos that would take the user to the YouTube page for the embedded video. When viewing a web page that has a video hosted on YouTube on it, the place where the video would be displayed can be clicked, and the video would be displayed there. And after viewing this video, one might want to view the page on YouTube for the video. One might want to get the information about how to embed the video in a web page. One might also want to check statistics on how many times it has been viewed. Perhaps one may want to read or post comments about the video on the page on which the video is hosted. And of course, there are those who may want to do what can only be done with the video by using Greasemonkey scripts that only work with the video when it is viewed on its YouTube page. For these reasons, it made sense for this kind of script to be made available.

I checked to see if any similar Greasemonkey scripts were already publicly available through Userscripts.org after I got this idea. And I saw one hosted on that site that I had not yet noticed before. There was this script there that was very similar to what I had in mind, in that it replaced the place in which the video would be viewed with a still image of the video. And when clicking on this still image, one would be taken to the YouTube page on which this video was hosted. I have periodically looked for scripts on Userscripts.org that were for YouTube and I had not noticed this one. Was it a coincidence that this script was recently added to the list of scripts with the “youtube” tag, or did I somehow subconsciously decide to “borrow” an idea from another script? In any case, I preferred having a choice between viewing the video where it was and going to the YouTube page for the video. And the script that I would write would give the user this choice.

So I decided to go about writing the script, knowing that if I had some difficulty with it, I could refer to the source code of scripts that did similar things. But I chose to avoid referring to the source code of these scripts. I could have looked up the answers to questions I had about writing this script, but I decided to put off looking up these answers until I finished working on this on my own. If I referred to the source code for these scripts, I could have released this script sooner. However, given the choice between getting this done quickly and taking on the challenge of finding out on my own how this could be done, I had to choose the latter option. The challenge of writing the script was one that I wanted to take on. It was not only the finished product that I was interested in.

After writing this script, I did refer to the source code of other scripts that work with embedded YouTube videos. I compared the way in which they were written to the way that I wrote mine. And although I did get some ideas on how they could be improved, I did not get all the answers that I wanted to find. I have found that YouTube videos do not always get embedded in web pages the way it is suggested on the pages for YouTube videos. In fact, if you click here or here you’ll see that the use of the <embed> tag may not always be used in embedding these videos. Some might copy and paste the code for embedding the video from the YouTube page for the video, but there are those who do not want to use a tag that has been deprecated in XHTML 1.0. In addition, an <embed> tag (that is not within an <object> tag) could also be used to embed videos. I have found that some Greasemonkey scripts that work with embedded videos do not handle the different ways in which videos are embedded. And I wanted to ensure that this script would be able to handle the different ways in which these videos can be embedded.

The script can be downloaded if you click here. And after downloading and installing it, you may want to try it out by visiting a page such as this one. If there are any pages with embedded videos that it does not work with, I would like to know about them. Any feedback on this script would be appreciated. And I am sure at least a few people will find this script useful, as the scripts that may or may not have led to me working on it are apparently being used by at least a few other people. It is however, interesting to note that this script that mine might be based on, was in turn based on this script.

Submit this entry to any of these sites: del.icio.us Digg Furl Reddit blogmarks Google Spurl StumbleUpon Technorati Yahoo!

6 Comments

  1. blahblah wrote:

    You may want to look at this script: http://userscripts.org/scripts/show/13502
    It does a very similar thing to yours. It is more similar to yours than the ‘YouTubeImageLink’ script, I think.

    Well. Why I’m posting here, is because that I tested the two scripts. Yours and the other I link to.
    The one I link to, on one point acts in a way your doesn’t, and that is in a better way I think. Instead of giving a link like your script does saying: ‘Click here to visit the YouTube page for this video.’ it shows the title of the Youtube video.
    Fx ‘YouTube – Robotic drummer Playing Take Five’.
    I’ve tested on this page: http://www.scienceahead.com/entry/the-top-20-student-innovations/

    If you have NoScript it says ‘YouTube – video page’. That is until the video is allowed, then after you refresh it says the Youtube title.
    I think both of the sentences it shows is better than yours.

    Then why don’t I then just use that script and shut up one could ask… Actually I am doing that, but I am a bit nervous about it. I think that its source code: http://userscripts.org/scripts/review/13502 is a bit confusing and is afraid there’s something bad in it. I trust you more (I have no knowledge about all this. Its because you describe your script more) , here’s your source code: http://userscripts.org/scripts/review/12673

    Also I notice that actually the script I link to (the not-yours-one) is newer than yours/has been posted later than yours. This could maybe let one think that he was inspired by what your script does, but didn’t think that it was fully great and then he made his own one. But maybe he wasn’t because the source codes reminds nothing about each other.

    So. Please comment on what you think about the source code of that script. And update your script with the mentioned features

    Saturday, April 19, 2008 at 6:58 pm | Permalink
  2. jkasprzak wrote:

    Hello, and thank you for your feedback.

    I knew that functionality could have been added to this script so that the titles of videos would be included in the links that it adds. And I actually considered including that functionality in the script. And now that you have suggested that I update the script so that it will display the titles of videos, I may take the time to make this update to the script.

    However, making this update may not be considered necessary, as you could use the other script that you mentioned. I have looked through that script’s source code, and I saw no reasons for you to be concerned about that script. It was mentioned in a comment in that script that it does not work with videos embedded a certain way, although videos are rarely embedded in the way with which that script does not work.

    So you could continue to use that other script that you mentioned, although I could update the one that I have written if you would still like me to do that. Please tell me if you would still like this script that I have written to be modified so that it will display the titles of videos.

    Thanks again,

    J.K.

    Monday, April 21, 2008 at 2:42 am | Permalink
  3. blahblah wrote:

    Hi… Thank you for replying.

    First: Okay it is calming to know that the other script is clean.

    Then you ask if I would still like you to update your script…
    Yes, I would like you to update your script. Because as I understand what you’re saying, your script supports some sites with videos “embedded a certain way” and the other script don’t.

    I have made some screenshots trying to explain the best way possible how I would like your script to do:
    1. Here is how it looks with the other script and the videos are not allowed with NoScript:
    http://img178.imageshack.us/img178/3884/othscriptvidnoalloweduh6.png
    = Then under the video it gives a link saying ‘YouTube – video page’. I think that is perfect.
    2. Here is how it looks with your script and the videos are not allowed with NoScript:
    http://img232.imageshack.us/img232/4249/yourscriptvidnoallowedxm0.png
    = no link is showed. I would like it to show ‘YouTube – video page’
    3. Here is how it looks with the other script with video allowed after refresh (F5:
    http://img232.imageshack.us/img232/5741/othscriptvidallowedbk2.png
    = It says ‘Youtube – [video name]‘. I think that that is perfect as well.
    4. Here is how it looks with your script with video allowed after refresh:
    http://img232.imageshack.us/img232/2807/yourscriptvidallowedts9.png
    = It says ‘Click here to visit the YouTube page for this video.’. I would like it to do as in 3. instead (=’Youtube – [video name]‘)

    Thanks a lot for your help :D. I really appreciate it.

    Tuesday, April 22, 2008 at 2:58 pm | Permalink
  4. jkasprzak wrote:

    Hello again.

    I have actually already started working on updating the script so that it will add video titles to the links. In a comment in the other script’s source code, it is acknowledged that the script does not work with videos embedded a certain way. However, I am not sure if or when that script will be corrected so that it will work with more embedded videos. Therefore, I decided to try adding this functionality before I received your reply.

    I also use the NoScript extension, and I was unaware of the fact that the script does not add these links when NoScript blocks the embedded videos. However, I have looked into this issue, and I am sure that I can have it corrected before long. As a matter of fact, I will try to complete making the updates you are requesting within the next few days.

    Thanks again,

    J.K.

    Thursday, April 24, 2008 at 3:51 am | Permalink
  5. blahblah wrote:

    Sorry that I haven’t got back giving feedback quicker than this, considering your quick update and all your work/research you have put into this. But don’t get fooled. I really appreciate it!!…

    I have just tried your new script, announced here:
    http://jake.kasprzak.ca/2008/04/26/adding-the-titles-of-videos-to-embedded-youtube-videos/
    and here:
    http://userscripts.org/scripts/show/12673

    And I have to say that it works very well as I requested. Some things surprised me of this updated script compared to the other script previously mentioned (the one you did not make, which I preferred before):
    1. On the test page: http://www.scienceahead.com/entry/the-top-20-student-innovations/ on video number 12 the other script in its link said ‘YouTube – Robotic drummer Playing Take Five’. I didn’t check if that title was correct (by going to the Youtube page red.), I just assumed it was.
    Now changed to your script it suddenly said ‘YouTube – SmartMirror’. That got me confused! But turned out (I went to the Youtube page) that your script has the right title and the other one hasn’t. I think it is a bit wierd why/how the other script shows a title which is not the one at the Youtube video page :S

    2. The second thing about this new version which surprised me (also positively like with the one above), is that this version shows the title even though the video is blocked by NoScript. That’s very nice! :D. The other script just said ‘YouTube – video page’ when the video was blocked. I didn’t assume it was possible to get the title when it was blocked, so this was a nice good surprise.

    Big time Thumbs up for your work!!!
    Cheers/Peace

    Sunday, May 11, 2008 at 3:46 pm | Permalink
  6. jkasprzak wrote:

    Hello, and thank you for your feedback. I would like to comment on the two points that you have made.

    I would like to note first that the other script that you mentioned seemed to work properly on the page on which these scripts were tested. I did not have any difficulty with that script, although I could take some time to try to determine why incorrect video titles were appearing when that script was used. Also, I thought that even though you did not request that video titles be displayed below videos blocked by NoScript, you would be pleased to see that these titles would be included in this case. It is good to know that I was correct in making that assumption.

    Thanks again,

    J.K.

    Monday, May 12, 2008 at 3:32 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*