tagesschau.de-html5-videos

tagesschau.de: HTML5 Video all the way - get rid of annoying projekktor player

目前為 2014-08-26 提交的版本,檢視 最新版本

// ==UserScript==
// @name           tagesschau.de-html5-videos
// @description    tagesschau.de: HTML5 Video all the way - get rid of annoying projekktor player
// @include        http://www.tagesschau.de/multimedia/video/video-*.html
// @include        http://www.tagesschau.de/multimedia/sendung/*.html
// @include        http://www.tagesschau.de/100sekunden/index.html
// @exclude        http://www.tagesschau.de/multimedia/video/video-*~player_autoplay-true.html
// @run-at         document-end

// @version        1.4.1
// @namespace https://github.com/about-robots
// ==/UserScript==

var iframe = document.getElementsByTagName("iframe")[0];
var videoResources = iframe.getAttribute("data-ctrl-iframe");
var i1 = videoResources.indexOf("'src'") + 7;
var i2 = videoResources.indexOf("'", i1);
var videoPageUrl = "http://www.tagesschau.de" + videoResources.substr(i1, i2 - i1);
iframe.parentNode.removeChild(iframe);

function reqListener () {
  i1 = this.responseText.indexOf("var playlist");
  i1 = this.responseText.indexOf("3:", i1);
  i1 = this.responseText.indexOf('"', i1) + 1;
  i2 = this.responseText.indexOf('"', i1);
  var videoFileUrl = this.responseText.substr(i1, i2 - i1);
  
  i1 = this.responseText.indexOf('poster:', i2);
  i1 = this.responseText.indexOf("5:", i1);
  i1 = this.responseText.indexOf('"', i1) + 1;
  i2 = this.responseText.indexOf('"', i1);
  var videoPosterImg = "http://www.tagesschau.de" + this.responseText.substr(i1, i2 - i1);
  
  var videoElement = document.createElement("video");
  videoElement.setAttribute("src", videoFileUrl);
  videoElement.setAttribute("controls", "1");
  videoElement.setAttribute("poster", "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
  videoElement.setAttribute("style", "width:100%;background-image:url("+videoPosterImg+");background-size:99.9%");
  
  var videoContainerDiv = document.getElementsByClassName("box")[0];
  videoContainerDiv.insertBefore(videoElement, videoContainerDiv.firstChild.nextSibling.nextSibling);
}

var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.open("get", videoPageUrl, true);
oReq.send();