Flash Accelerate

开启FlashPlayer硬件渲染加速

As of 2015-04-09. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Flash Accelerate
// @namespace   [email protected]
// @description 开启FlashPlayer硬件渲染加速
// @include     *
// @exclude     http://www.imdb.com/*
// @version     1.10
// @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 find_wmode = function (t) {
  for (var i=0;i<t.length;i++) {
    if (t[i].name == 'wmode' || t[i].name == 'wMode') {
      return t[i];
    }
  }
  return null;
};
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 d = find_wmode(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);