Flash Accelerate

开启FlashPlayer硬件渲染加速

  1. // ==UserScript==
  2. // @name Flash Accelerate
  3. // @namespace fengwn1997@163.com
  4. // @description 开启FlashPlayer硬件渲染加速
  5. // @include http://*
  6. // @include https://*
  7. // @exclude http://www.imdb.com/*
  8. // @exclude http://www.xiami.com/play*
  9. // @version 1.16
  10. // @grant none
  11. // ==/UserScript==
  12. //创意来自 gpu-accelerated-flash-player 扩展!
  13. //是否有加速效果作者也不知道。
  14. //关于wmode参数的解释:http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html
  15. //如果你使用的是firefox,可以在about:config将plugins.force.wmode修改(新建)为 gpu 或 direct
  16. //如果你发现平时正常浏览的网页无法正常使用,请优先禁用此脚本以排查问题
  17. //
  18. var run_time_max = 2; //最大运行次数
  19. var wmode_value = 'gpu'; //默认 gpu,可以是 direct。一般不需要更改
  20.  
  21. var debug = false;
  22. function main(){
  23. ['object','embed'].forEach(function(tagname){
  24. [].slice.call(document.querySelectorAll(tagname) || []).forEach(function(element){
  25. //debug?console.log(element):null;
  26. if( !element || element.type != 'application/x-shockwave-flash' || (element.clientWidth<300 || element.clientHeight<300))
  27. {
  28. return;
  29. }
  30. else
  31. {
  32. debug?console.log(element):null;
  33. if(tagname == 'object')
  34. {
  35. debug?console.log(element.children):null;
  36. [].slice.call(element.children || []).forEach(function(node){
  37. if(node && node.name && node.name.toLowerCase() == 'wmode')
  38. {
  39. node.parentElement.removeChild(node);
  40. }
  41. });
  42. var e = document.createElement('param');
  43. e.name = 'wmode';
  44. e.value = wmode_value;
  45. element.appendChild(e);
  46. }
  47. else
  48. {
  49. element.setAttribute('wmode',wmode_value);
  50. }
  51. if(!element.getAttribute('fa-sign'))
  52. {
  53. element.setAttribute('fa-sign',1);
  54. element.parentElement.replaceChild(element.cloneNode(true),element);
  55. }
  56. }
  57. });
  58. });
  59. }
  60.  
  61. var run_time = 1;
  62. var interval = setInterval(function () {
  63. console.log('run_time', run_time, location);
  64. if (run_time == run_time_max) {
  65. clearInterval(interval);
  66. }
  67. run_time += 1;
  68. main();
  69. }, 1500);