HTML5 Player for Ningmeng

Replace flash player with HTML5 audio tags for Ningmeng.name.

  1. // ==UserScript==
  2. // @name HTML5 Player for Ningmeng
  3. // @namespace userscripts@dearrrfish
  4. // @version 0.1
  5. // @description Replace flash player with HTML5 audio tags for Ningmeng.name.
  6. // @author dearrrfish
  7. // @homepage https://github.com/dearrrfish/my-userscripts
  8. // @match http://www.ningmeng.name/?p=*
  9. // @match http://www.ningmeng.name
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function(ajaxOpen) {
  14. 'use strict';
  15. var replaceFlashPlayer = function() {
  16. var flashObjects = document.getElementsByTagName('object');
  17. while(flashObjects.length) {
  18. var obj = flashObjects[0];
  19. var embed = obj.getElementsByTagName('embed')[0];
  20. if (embed && embed.src) {
  21. var audio = document.createElement('audio');
  22. audio.src = embed.src.match(/mp3=[^&]*/)[0].slice(4);
  23. audio.controls = true;
  24. audio.autoplay = false;
  25.  
  26. obj.parentNode.replaceChild(audio, obj);
  27. }
  28. }
  29. };
  30.  
  31. XMLHttpRequest.prototype.open = function() {
  32. this.addEventListener('load', function() {
  33. setTimeout(replaceFlashPlayer, 500);
  34. })
  35. ajaxOpen.apply(this, arguments);
  36. };
  37.  
  38. replaceFlashPlayer();
  39.  
  40. })(XMLHttpRequest.prototype.open);