HTML5 player for Metacritic

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

目前为 2015-11-19 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name HTML5 player for Metacritic
  3. // @namespace https://greasyfork.org/users/4813-swyter
  4. // @description Avoid having to use Flash Player to watch videos. No ads.
  5. // @match http://www.metacritic.com/*
  6. // @version 2015.11.19
  7. // @noframes
  8. // @icon https://i.imgur.com/CecLLKu.png
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. /* wait until the page is ready for the code snipped to run */
  14. document.addEventListener('DOMContentLoaded', function()
  15. {
  16. window.MetaC = window.MetaC || {};
  17. window.MetaC.CANPlayer = window.MetaC.CANPlayer || {};
  18.  
  19. /* override the flash video function and call it a day */
  20. Object.defineProperty(window.MetaC.CANPlayer, 'initPlayer',
  21. {
  22. configurable: false,
  23. writable: false,
  24. value: function(elem, width, height, options)
  25. {
  26. console.info("check overriden! video arguments =>", arguments);
  27.  
  28. v = document.createElement("video");
  29.  
  30. v.width = width;
  31. v.height = height;
  32. v.src = options[0].assetURL;
  33.  
  34. v.poster = options[0].prevImg;
  35. v.controls = 'true';
  36.  
  37. /* replace the old SWF Flash object with it, voilà */
  38. elem = document.getElementById(elem);
  39. elem.parentNode.replaceChild(v, elem);
  40.  
  41. console.log("video replaced =>", v, elem);
  42. }
  43. });
  44. });