HTML5 player for Metacritic

Avoid having to use Flash Player to watch videos. No ads.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        HTML5 player for Metacritic
// @namespace   https://greasyfork.org/users/4813-swyter
// @description Avoid having to use Flash Player to watch videos. No ads.
// @match       http://www.metacritic.com/*
// @version     2015.11.19
// @noframes
// @icon        https://i.imgur.com/CecLLKu.png
// @grant       none
// @run-at      document-start
// ==/UserScript==

/* wait until the page is ready for the code snipped to run */
document.addEventListener('DOMContentLoaded', function()
{
  window.MetaC = window.MetaC || {};
  window.MetaC.CANPlayer = window.MetaC.CANPlayer || {};

  /* override the flash video function and call it a day */
  Object.defineProperty(window.MetaC.CANPlayer, 'initPlayer',
  {
    configurable: false,
    writable: false,
    value: function(elem, width, height, options)
    {
      console.info("check overriden! video arguments =>", arguments);

      v = document.createElement("video");

      v.width = width;
      v.height = height;
      v.src = options[0].assetURL;

      v.poster = options[0].prevImg;
      v.controls = 'true';

      /* replace the old SWF Flash object with it, voilà */
      elem = document.getElementById(elem);
      elem.parentNode.replaceChild(v, elem);

      console.log("video replaced =>", v, elem);
    }
  });
});