Flash Accelerate

开启FlashPlayer硬件渲染加速

当前为 2015-02-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Flash Accelerate
// @namespace   [email protected]
// @description 开启FlashPlayer硬件渲染加速
// @include     *
// @exclude     http://www.imdb.com/*
// @version     1.08
// @grant       none
// ==/UserScript==
//创意来自 gpu-accelerated-flash-player 扩展!
//是否有加速效果作者也不知道。
//关于wmode参数的解释:http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html
//
//
var run_time_max = 3; //最大运行次数
var wmode_value = 'gpu'; //默认 gpu,可以是 direct。一般不需要更改
var toggle = function (o) {
  if (o) {
    o.setAttribute('fa-sign', 1);
    var display = o.style.display;
    o.style.display = 'none';
    setTimeout(function () {
      o.style.display = display;
      console.log(o);
    }, 0);
  }
};
var run_time = 1;
var interval = setInterval(function () {
  console.log('run_time', run_time, location);
  if (run_time == run_time_max) {
    clearInterval(interval);
  }
  run_time = run_time + 1;
  var embeds = document.getElementsByTagName('embed');
  if (embeds.length > 0) {
    for (var i = 0; i < embeds.length; i++) {
      if (embeds[i].getAttribute('fa-sign')) {
        continue;
      } 
      else {
        embeds[i].setAttribute('wmode', wmode_value);
        toggle(embeds[i]);
      }
    }
  }
  var objects = document.getElementsByTagName('object');
  if (objects.length > 0) {
    for (var j = 0; j < objects.length; j++) {
      if (objects[j].getAttribute('fa-sign')) {
        continue;
      }
      else{
        var loop = function(t){
          for(var k=0;k<t.length;k++){
            if(t[k].name == "wmode" || t[k].name == "wMode"){
              return t[k];
            }
          }
          return null;
        };
        var d = loop(objects[j].childNodes);
        if (d) {
          d.value = wmode_value;
        }
        else {
          var e = document.createElement('param');
          e.name = 'wmode';
          e.value = wmode_value;
          objects[j].appendChild(e);
        }
        toggle(objects[j]);
      }
    }
  }
}, 1500);