ClickToPlugin HTML5 replacements

To replace plug-ins by HTML5, ClickToPlugin uses independent Javascript objects called “killers”, which transform plug-in data into media data. ClickToPlugin has a number of built-in killers for popular audio and video services, but it also has the ability to load additional killers.

How to add killers to ClickToPlugin

Installing killers is easy: simply add their URLs (taken for example from the list of killers below) to the “Plug-in to HTML5 conversion scripts” list in ClickToPlugin’s preferences. Close the preference window and ClickToPlugin will have loaded the new killer(s).

The order of the killers in the list matters, since at most one is applied to any given plug-in object. As a precaution you should add killers before the built-in Flash.js, Silverlight.js, and Generic.js killers, who have lax criteria of applicability.

List of killers

The killers in the first part of the table are included in ClickToPlugin, but the versions posted here may be more recent.

If you would like to share your own killers, you can do so by contacting me or directly on GitHub.

Applies to Updated on
BBC Videos on bbc.com
Brightcove Some instances of the Brightcove Flash player
Dailymotion On-site and embedded videos from dailymotion.com
Facebook On-site and embedded videos from facebook.com
Flash Several generic Flash media players
Generic All HTML5-playable embedded media
MTVNetworks Videos from cc.com, mtv.com, and gametrailers.com
Silverlight Several generic Silverlight media players
TED Videos on ted.com
YouTube On-site and embedded videos and playlists from youtube.com
ВКонтакте Videos on vk.com
Bild Videos on bild.de
BIM Some versions of the BIMVid Flash player used by several news websites
Eurogamer Videos on eurogamer.net
Flowplayer Some instances of the common Flowplayer Flash player
Gamestar Videos on gamestar.de
Golem Videos on golem.de
ImbcNews Videos on news.mbc.co.kr
Katu Videos on katu.com
Megavideo On-site and embedded videos from megavideo.com
Myspass Videos on myspass.de
NaverVideo On-site and embedded videos from naver.com
Novamov On-site and embedded videos from novamov.com
RaiTv Videos on rai.tv
Sevenone Videos on prosieben.de, kabeleins.de, sat1.de, and ran.de
SKCommsVideo On-site and embedded videos from video.nate.com, egloos.com, and video.cyworld.com
Spiegel Videos on www.spiegel.de
ThemisMedia Themis Media Flash player
TvPot On-site and embedded videos from tvpot.daum.net
Veoh On-site and embedded videos from veoh.com
Vodpod YouTube, Vimeo, and Blip.tv videos embedded through vodpod.com
Welt Videos on welt.de
XinMSN Videos on video.xin.msn.com
YouTubeXHR Alternative to YouTube.js
Zeit Videos on zeit.de

How to create a killer

Killer files are included as scripts in the extension’s global page, using ClickToPlugin’s built-in universal extension. In particular, all killer files share the same scope, so global definitions must be avoided.

Here is a minimal killer file:

addKiller("Useless killer", {
   "canKill": function(data) {return false;},
   "process": function(data, callback) {}
});

The first argument of the addKiller function serves as a unique identifier for the killer, which is the function’s second argument. The mandatory methods canKill and process are described below.

Here is what an actual killer file looks like:

addKiller("GitHub", {
   
   "canKill": function(data) {
      if(data.type !== "application/x-shockwave-flash") return false;
      return data.src.indexOf("http://hoyois.github.io/") !== -1;
   },

   "process": function(data, callback) {
      var flashvars = parseFlashVariables(data.params.flashvars);
      if(!flashvars.mp4Source) return;
   
      callback({
         "playlist": [{
            "poster": decodeURIComponent(flashvars.previewImage),
            "sources": [{
               "url": decodeURIComponent(flashvars.mp4Source),
               "isNative": true
            }]
         }]
      });
   }
   
});

This killer will process all Flash content hosted on this domain and offer a simple HTML5 alternative for those that have the mp4Source Flash variable.

The killers database provides further examples with varying degrees of complexity.

The canKill method

The canKill method has a plug-in data object as argument and must return a boolean. This function should be kept as simple as possible, since it will be executed for every blocked plug-in object. If it returns true, ClickToPlugin stops evaluating the canKill methods of other killers and asynchronously runs the process method of this killer. Otherwise the plug-in data object is passed to the next killer’s canKill method. In particular, the canKill method should not modify its argument if it does not return true.

The process method

The process method has a plug-in data object and a function callback as arguments and does not return anything. To be successful, this method must apply the callback function to a media data object. This needs not happen in the body of the process method itself: for example, if the killer makes an HTTP request, the callback function will be called in the onload handler of the XMLHttpRequest object.

Plug-in data objects

The same object is passed as first argument to the canKill and process methods. It has the following properties:

Media data objects

A media data object contains data to be used by ClickToPlugin’s media player. The following minimal media data object will result in an HTML5 video element with src attribute set to videoURL:

{
   "playlist": [{
      "sources": [{
         "url": videoURL
      }]
   }]
}

The only mandatory property of a media data object is playlist, which is an array of media track objects.

Each media track object can have the following properties:

Each media source object can have the following properties:

Available functions

The following functions form the interface between killers and ClickToPlugin.

ClickToPlugin also defines the following useful functions that can be used in killer files.