svtplaylist.se

I would really like to see support for playlists in SVT Play, but that has not been high enough on the priority list at SVT yet. So in the meantime I’ve built a small hack to provide a simple playlist using a bookmarklet. You can try it out on www.svtplaylist.se

The idea was born when a colleague of mine showed a really smart way to create bookmarklets by dynamically loading a script hosted on github. The only code you need to put in the bookmarklet looks something like this:

(function() {
  var e = document.createElement("script");
  e.async = 1;
  e.src = "https://gist.github.com/{user}/{hash}/raw";
  document.getElementsByTagName("body")[0].appendChild(e)
})()

This code just creates a <script> tag that loads a javascript file hosted on github. You can then put any stuff you want in that script. To make it a real bookmarklet you also need to pack it into one line, url-encode it and put a javascript: prefix in front, like this:

javascript:(function()%7Bvar%20e%3Ddocument.createElement(%22script%22)%3Be.async%3D1%3Be.src%3D%22https%3A%2F%2Fgist.github.com%2F%7Buser%7D%2F%7Bhash%7D%2Fraw%22%3Bdocument.getElementsByTagName(%22body%22)%5B0%5D.appendChild(e)%7D)()

What is really nice about this approach is that you can change the functionality of the bookmarklet after it has been saved as a bookmark.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: