tagesschau.de-html5-videos

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

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

// ==UserScript==
// @id             www.tagesschau.de-d25add17-4ab0-4d46-ad1e-980d91e0e4cd@https://github.com/about-robots
// @name           tagesschau.de-html5-videos
// @version        1.1
// @namespace      https://github.com/about-robots
// @author         about:robots
// @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
// ==/UserScript==

var iframe = document.getElementsByTagName("iframe")[0];
var videoResources = iframe.getAttribute("data-ctrl-iframe");
console.log(videoResources);
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 () {
  var nsidx1 = this.responseText.indexOf('id="noscriptblock"');
  nsidx1 = this.responseText.indexOf("href=", nsidx1) + 6;
  var nsidx2 = this.responseText.indexOf('"', nsidx1);
  var videoFileUrl = this.responseText.substr(nsidx1, nsidx2 - nsidx1 - 10) + "l.h264.mp4";
  
  var videoElement = document.createElement("video");
  videoElement.setAttribute("src", videoFileUrl);
  videoElement.setAttribute("controls", "1");
  videoElement.setAttribute("autoplay", "1");
  videoElement.setAttribute("style", "width:100%");
  
  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();