tagesschau.de-html5-videos

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

当前为 2014-08-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name tagesschau.de-html5-videos
  3. // @description tagesschau.de: HTML5 Video all the way - get rid of annoying projekktor player
  4. // @include http://www.tagesschau.de/multimedia/video/video-*.html
  5. // @include http://www.tagesschau.de/multimedia/sendung/*.html
  6. // @include http://www.tagesschau.de/100sekunden/index.html
  7. // @exclude http://www.tagesschau.de/multimedia/video/video-*~player_autoplay-true.html
  8. // @run-at document-end
  9.  
  10. // @version 1.4.1
  11. // @namespace https://github.com/about-robots
  12. // ==/UserScript==
  13.  
  14. var iframe = document.getElementsByTagName("iframe")[0];
  15. var videoResources = iframe.getAttribute("data-ctrl-iframe");
  16. var i1 = videoResources.indexOf("'src'") + 7;
  17. var i2 = videoResources.indexOf("'", i1);
  18. var videoPageUrl = "http://www.tagesschau.de" + videoResources.substr(i1, i2 - i1);
  19. iframe.parentNode.removeChild(iframe);
  20.  
  21. function reqListener () {
  22. i1 = this.responseText.indexOf("var playlist");
  23. i1 = this.responseText.indexOf("3:", i1);
  24. i1 = this.responseText.indexOf('"', i1) + 1;
  25. i2 = this.responseText.indexOf('"', i1);
  26. var videoFileUrl = this.responseText.substr(i1, i2 - i1);
  27. i1 = this.responseText.indexOf('poster:', i2);
  28. i1 = this.responseText.indexOf("5:", i1);
  29. i1 = this.responseText.indexOf('"', i1) + 1;
  30. i2 = this.responseText.indexOf('"', i1);
  31. var videoPosterImg = "http://www.tagesschau.de" + this.responseText.substr(i1, i2 - i1);
  32. var videoElement = document.createElement("video");
  33. videoElement.setAttribute("src", videoFileUrl);
  34. videoElement.setAttribute("controls", "1");
  35. videoElement.setAttribute("poster", "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
  36. videoElement.setAttribute("style", "width:100%;background-image:url("+videoPosterImg+");background-size:99.9%");
  37. var videoContainerDiv = document.getElementsByClassName("box")[0];
  38. videoContainerDiv.insertBefore(videoElement, videoContainerDiv.firstChild.nextSibling.nextSibling);
  39. }
  40.  
  41. var oReq = new XMLHttpRequest();
  42. oReq.onload = reqListener;
  43. oReq.open("get", videoPageUrl, true);
  44. oReq.send();