HTML5 player for Metacritic

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل 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);
    }
  });
});