Golem.de HTML5 Video

Replaces the Flash player with a native HTML5 one

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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>';
}