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. // @grant none
  9. // @run-at document-start
  10. // ==/UserScript==
  11.  
  12. /* wait until the page is ready for the code snipped to run */
  13. document.addEventListener('DOMContentLoaded', function()
  14. {
  15. window.MetaC = window.MetaC || {};
  16. window.MetaC.CANPlayer = window.MetaC.CANPlayer || {};
  17.  
  18. /* override the flash video function and call it a day */
  19. Object.defineProperty(window.MetaC.CANPlayer, 'initPlayer',
  20. {
  21. configurable: false,
  22. writable: false,
  23. value: function(elem, width, height, options)
  24. {
  25. console.info("check overriden! video arguments =>", arguments);
  26.  
  27. v = document.createElement("video");
  28.  
  29. v.width = width;
  30. v.height = height;
  31. v.src = options[0].assetURL;
  32.  
  33. v.poster = options[0].prevImg;
  34. v.controls = 'true';
  35.  
  36. /* replace the old SWF Flash object with it, voilà */
  37. elem = document.getElementById(elem);
  38. elem.parentNode.replaceChild(v, elem);
  39.  
  40. console.log("video replaced =>", v, elem);
  41. }
  42. });
  43. });