Golem.de HTML5 Video

Replaces the Flash player with a native HTML5 one

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Golem.de HTML5 Video
// @namespace   golem.de.html5.video.stuff.dasprids.de
// @description Replaces the Flash player with a native HTML5 one
// @include     http://*.golem.de/*
// @version     1
// @grant       none
// ==/UserScript==

// For www.golem.de
var figures = document.getElementsByTagName('figure');

for (var i = 0; i < figures.length; ++i) {
  if (!figures[i].hasAttribute('id')) {
    continue;
  }

  var id = figures[i].getAttribute('id');

  if (!id.startsWith('gvideo')) {
    continue;
  }

  figures[i].removeAttribute('id');

  var videoId  = id.split('_')[1];
  var videoUrl = 'http://video.golem.de/download/' + videoId;

  figures[i].innerHTML = '<video controls="controls" width="620"><source src="' + videoUrl + '" type="video/mp4" /></video>';
}

// For video.golem.de
var projectors = document.getElementsByClassName('projekktor');

for (var i = 0; i < projectors.length; ++i) {
  if (!projectors[i].hasAttribute('id')) {
    continue;
  }

  var match = projectors[i].getAttribute('id').match(/^NVBPlayer(\d+)$/);

  if (!match) {
    continue;
  }

  projectors[i].removeAttribute('id');

  var videoId  = match[1];
  var videoUrl = 'http://video.golem.de/download/' + videoId;

  projectors[i].innerHTML = '<video controls="controls" width="620"><source src="' + videoUrl + '" type="video/mp4" /></video>';
}