3 // @description Turn RaiTV silverlight objects into video tags
4 // @namespace http://oblomov.myopenid.com
5 // @include http://rai.tv/*
6 // @include http://rai.it/*
7 // @include http://www.rai.tv/*
8 // @include http://www.rai.it/*
9 // @author Giuseppe "Oblomov" Bilotta
15 function getURL(name) {
16 var list = document.getElementsByName(name) ;
17 if (list && list[0]) {
18 return list[0].content;
25 std: getURL('videourl'),
26 mp4: getURL('videourl_mp4'),
27 wmv: getURL('videourl_wmv'),
28 h264: getURL('videourl_h264'),
29 m3u8: getURL('videourl_m3u8'),
32 function srctag(url, av, fmt) {
35 return '<source src="' + url + '" ' + (fmt ? 'type="' + av + '/' + fmt + '" ' : '') + '/>'
38 function H5video(fmt) {
39 return srctag(urls[fmt], 'video', (fmt == 'std' ? null : fmt));
42 var sch = document.getElementById("silverlightControlHost");
44 // if we are on a page that defines the videourl* metas, go straight to creating
47 // prevent other JS with messing with this element further
48 sch.id = 'html5mediaHost';
49 sch.innerHTML = "<video style='width:100%; height:100%' controls>" +
50 H5video('mp4') + H5video('wmv') +
51 H5video('h264') + H5video('m3u8') +
53 "<h3>Sorry, no supported video format found :-(</h3></video>";
54 console.log(sch, 'hacked');
58 // hack the play* JS functions
60 window.playTg = function (liveTg, video, h264, androidUrl) {
61 var dataP = new Date();
63 ggP = dataP.getDate() + "-";
64 mmP = dataP.getMonth() + 1 + "-";
65 aaaaP = 1900 + dataP.getYear();
66 // stop loading any current audio/video
67 if (sch.firstChild && sch.firstChild.src) {
68 console.log('stopping current A/V');
69 sch.firstChild.src = '';
71 sch.innerHTML = "<video width='258' height='195' controls autoplay>" +
72 srctag(h264, 'video', 'h264') +
73 srctag(androidUrl, 'video') +
74 srctag(video, 'video') +
75 "<h3>Sorry, no supported video format found :-(</h3></video>";
76 setNielsen(location.href + '&video=' + liveTg + '&data=' + ggP + mmP + aaaaP + '', true);
77 console.log('playTg', liveTg, video, h264, androidUrl)
79 console.log('playTg hacked');
81 if (window.playAudio) {
82 window.playAudio = function (grrEdizione, mediaUrl, mediatype) {
83 var dataP = new Date();
85 ggP = dataP.getDate() + "-";
86 mmP = dataP.getMonth() + 1 + "-";
87 aaaaP = 1900 + dataP.getYear();
88 // stop loading any current audio/video
89 if (sch.firstChild && sch.firstChild.src) {
90 console.log('stopping current A/V');
91 sch.firstChild.src = '';
93 sch.innerHTML = "<audio width='258' height='35' controls autoplay>" +
94 srctag(mediaUrl, 'audio') +
95 "<h3>Sorry, no supported audio format found :-(</h3></audio>";
96 setNielsen(location.href + '&audio=' + grrEdizione + '&data=' + ggP + mmP + aaaaP + '', true);
97 console.log('playAudio', grrEdizione, mediaUrl, mediatype);
99 console.log('playAudio hacked');