From 1bffb51fcf82942d926bdca52bbd398e94a4be2d Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Mar 2013 22:53:57 +0100 Subject: [PATCH] Some support for streaming Rai pages --- raitv.user.js | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/raitv.user.js b/raitv.user.js index 9f84973..83d515a 100644 --- a/raitv.user.js +++ b/raitv.user.js @@ -7,7 +7,7 @@ // @include http://www.rai.tv/* // @include http://www.rai.it/* // @author Giuseppe "Oblomov" Bilotta -// @version 20130322.2205 +// @version 20130322.2255 // ==/UserScript== (function() { @@ -17,7 +17,10 @@ if (list && list[0]) { return list[0].content; } else { - return null; + var altname = name.toUpperCase().replace('VIDEO','video'); + console.log(name, altname); + console.log(window[name], window[altname]); + return window[altname]; } } @@ -52,6 +55,7 @@ var sch = document.getElementById("silverlightControlHost"); if (sch) { + console.log(urls); // if we are on a page that defines the videourl* metas, go straight to creating // the video element if (urls.std) { @@ -66,24 +70,24 @@ var list = document.createElement("li"); list.id = 'mediaurl'; - list.innerHTML = 'Download:'; - var a = H5a('mp4'); - if (a) - list.appendChild(a); - a = H5a('h264'); - if (a) - list.appendChild(a); - a = H5a('wmv'); - if (a) - list.appendChild(a); + list.innerHTML = 'Stream/Download:'; + for (var fmt in urls) { + var a = H5a(fmt); + if (a) + list.appendChild(a); + } // find place to append the list to: - var specs = sch.parentNode.parentNode.previousElementSibling.getElementsByTagName('ul'); - if (specs && specs[0]) { - specs[0].appendChild(list); - console.log(list, 'enumerated and appended'); + var pp = sch.parentNode.parentNode.previousElementSibling; + var specs = pp.getElementsByTagName('ul'); + if (!specs || !specs[0]) { + specs = document.createElement('ul'); + specs.className = 'Specifiche'; + pp.appendChild(specs); } else { - console.log(list, 'enumerated, but not appended'); + specs = specs[0]; } + specs.appendChild(list); + console.log(list, 'enumerated and appended'); return; // done } -- 2.32.0.93.g670b81a890