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.