golem-html5-vids

Golem.de HTML5 Videos: kill flash and ads on golem.de!

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @id             video.golem.de-cf1af14e-25ea-4d9a-9924-58563eb39677@https://github.com/about-robots/
// @name           golem-html5-vids
// @description    Golem.de HTML5 Videos: kill flash and ads on golem.de!
// @namespace      https://github.com/about-robots/
// @author         about:robots
// @include        http://video.golem.de/*
// @include        http://www.golem.de/news/*
// @run-at         document-end
//
// @version        1.4.2
// ==/UserScript==

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;border-radius:4px;";
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;border-radius:4px;";
function createSwitchMouseOver(Id) {
  return function() { document.getElementById(Id).setAttribute("style", styleMouseover); };
}
function createSwitchMouseOut(Id) {
  return function() { document.getElementById(Id).setAttribute("style", styleUnfocused); };
}
function createSwitchOnClick(vidId, swId, vUrlHD, vUrlSD) {
  return function() {
    var video = document.getElementById(vidId);
    var qswitch = document.getElementById(swId);
    var videoPos = video.currentTime - 1.1;
    if (videoPos < 0) videoPos = 0;
    if (qswitch.innerHTML == "HD") {
      localStorage.setItem("videoQuality", "SD");
      qswitch.innerHTML = "SD";
      video.setAttribute("src", vUrlHD);
    } else {
      localStorage.setItem("videoQuality", "HD");
      qswitch.innerHTML = "HD";
      video.setAttribute("src", vUrlSD);
    }
    video.play();
    video.oncanplay = function() {
      video.currentTime = videoPos;
      video.oncanplay = "";
    };
  };
}

var divs = document.getElementById("screen").getElementsByTagName("div");
var videoDIV = [];
for (var i = 0; i < divs.length; i++) {
  if (divs[i].id.indexOf("NVBPlayer") > -1) {
    videoDIV.push(divs[i]);
  }
}
for (var i = 0; i < videoDIV.length; i++) {
  var videoId = videoDIV[i].id.substring(9);
  var videoURL_HD = "http://video.golem.de/download/"+videoId+"?q=high";
  var videoURL_SD = "http://video.golem.de/download/"+videoId+"?q=normal";
  var html5video = document.createElement("video");
  var qualitySwitch = document.createElement("div");
  var style = videoDIV[i].getAttribute("style")
  var i1 = style.indexOf("http");
  var i2 = style.indexOf('"', i1);
  var snapshotImg = style.substring(i1, i2);
  html5video.setAttribute("poster", snapshotImg);
  html5video.setAttribute("width", 620);
  html5video.setAttribute("height", 349);
  html5video.setAttribute("controls", 1);
  var html5vidId = "html5video"+videoId;
  html5video.setAttribute("id", html5vidId);
  if (localStorage.getItem("videoQuality") === null) {
    localStorage.setItem("videoQuality", "SD");
  }
  if (localStorage.getItem("videoQuality") == "SD") {
    html5video.setAttribute("src", videoURL_SD);
    qualitySwitch.innerHTML = "SD";
  } else {
    html5video.setAttribute("src", videoURL_HD);
    qualitySwitch.innerHTML = "HD";
  }
  qualitySwitch.setAttribute("style", styleUnfocused);
  qualitySwitch.setAttribute("title", "Qualität zwischen SD und HD umschalten");
  var switchId = "qualitySwitch"+videoId;
  qualitySwitch.setAttribute("id", switchId);
  while (videoDIV[i].hasChildNodes()) {
    videoDIV[i].removeChild(videoDIV[i].lastChild);
  }
  qualitySwitch.onmouseover = createSwitchMouseOver(switchId);
  qualitySwitch.onmouseout = createSwitchMouseOut(switchId);
  qualitySwitch.onclick = createSwitchOnClick(html5vidId, switchId, videoURL_HD, videoURL_SD);
  videoDIV[i].appendChild(html5video);
  videoDIV[i].appendChild(qualitySwitch);
}