golem-html5-vids

Kill flash and ads on video.golem.de

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @id             video.golem.de-cf1af14e-25ea-4d9a-9924-58563eb39677@scriptish
// @name           golem-html5-vids
// @version        1.0
// @namespace      
// @author         about:robots
// @description    Kill flash and ads on video.golem.de
// @include        http://video.golem.de/*
// @run-at         document-end
// ==/UserScript==

var url = document.URL;
var i1 = url.indexOf("/", 22) + 1;
var i2 = url.indexOf("/", i1);
var videoId = url.substring(i1, i2);

var videoUrlHD = "http://video.golem.de/download/"+videoId+"?q=high";
var videoUrlSD = "http://video.golem.de/download/"+videoId+"?q=normal";

var videoObj = document.createElement("video");
var switchObj = document.createElement("div");
var flashObj = document.getElementById("NVBPlayer"+videoId+"video");
var containerObj = document.getElementById("NVBPlayer"+videoId);

i1 = containerObj.getAttribute("style").indexOf("http");
i2 = containerObj.getAttribute("style").indexOf('"', i1);
var snapshotUrl = containerObj.getAttribute("style").substring(i1, i2);

if (localStorage.getItem("videoQuality") === null) {
  localStorage.setItem("videoQuality", "SD");
}
if (localStorage.getItem("videoQuality") == "SD") {
  videoObj.setAttribute("src", videoUrlSD);
  switchObj.innerHTML = "SD"
} else {
  videoObj.setAttribute("src", videoUrlHD);
  switchObj.innerHTML = "HD"
}
videoObj.setAttribute("height", flashObj.height);
videoObj.setAttribute("width", flashObj.width);
videoObj.setAttribute("controls", 1);
videoObj.setAttribute("poster", snapshotUrl);
videoObj.setAttribute("id", "videoGolem")

while (containerObj.hasChildNodes())
  containerObj.removeChild(containerObj.lastChild);

containerObj.appendChild(videoObj);

var styleUnfocused = "color:rgba(255,255,255,0.3);background:rgba(0,0,0,0.1);cursor:pointer;height:32px;width:32px;position:absolute;top:1em;right:0.8em;font:bold 18px/32px sans-serif;text-align:center;";
var styleMouseover = "color:rgba(255,255,255,0.5);background:rgba(0,0,0,0.2);cursor:pointer;height:32px;width:32px;position:absolute;top:1em;right:0.8em;font:bold 18px/32px sans-serif;text-align:center;";
switchObj.setAttribute("style", styleUnfocused);
switchObj.setAttribute("title", "Qualität zwischen SD und HD umschalten");
switchObj.onmouseover = function() {
  switchObj.setAttribute("style", styleMouseover);
};
switchObj.onmouseout = function() {
  switchObj.setAttribute("style", styleUnfocused);
};
switchObj.onclick = function() {
  var videoPos = videoObj.currentTime - 1.1;
  if (videoPos < 0) videoPos = 0;
  if (switchObj.innerHTML == "HD") {
    localStorage.setItem("videoQuality", "SD");
    switchObj.innerHTML = "SD";
    videoObj.setAttribute("src", videoUrlSD);
  } else {
    localStorage.setItem("videoQuality", "HD");
    switchObj.innerHTML = "HD";
    videoObj.setAttribute("src", videoUrlHD);
  }
  videoObj.play();
  videoObj.oncanplay = function() {
    videoObj.currentTime = videoPos;
    videoObj.oncanplay = "";
  };
};
containerObj.appendChild(switchObj);