Flash Accelerate

开启FlashPlayer硬件渲染加速

Stan na 15-02-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Flash Accelerate
// @namespace   [email protected]
// @description 开启FlashPlayer硬件渲染加速
// @include     *
// @version     1.05
// @grant       none
// ==/UserScript==

//创意来自 gpu-accelerated-flash-player 扩展!
//是否有加速效果作者也不知道。
//只有当不存在 wmode 参数时才会开启加速
//关于wmode参数的解释:http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html
//
//以下是脚本可选项:
var force_all = false; //默认 false,当为true时始终开启加速,忽略wmode是否存在,会覆盖下一个选项
var force_direct_gpu = false; //默认 false,当存在且wmode = direct 时开启加速
var wmodeValue = 'gpu'; //默认 gpu,可以是 direct。

setTimeout(function () {
  var objects = document.getElementsByTagName('object');
  var embeds = document.getElementsByTagName('embed');
  var has_wmode;
  var toggle = function (o) {
    //console.log(o.id);
    if (o) {
      o.style.display = 'none';
      setTimeout(function () {
        o.style.display = 'block';
      }, 0);
    }
  };
  //console.log(objects);
  if (objects.length > 0) {
    for (var i = 0; i < objects.length; i++) {
      has_wmode = false;
      for (var ii = 0; ii < objects[i].childNodes.length; ii++) {
        if (objects[i].childNodes[ii].name && objects[i].childNodes[ii].name.toLowerCase() == 'wmode') {
          has_wmode = true;
          if (force_all) {
            objects[i].childNodes[ii].value = wmodeValue;
            toggle(objects[i]);
          } 
          else if (force_direct_gpu && objects[i].childNodes[ii].value == 'direct') {
            objects[i].childNodes[ii].value = wmodeValue;
            toggle(objects[i]);
          }
          break;
        }
      }
      if (!has_wmode) {
        var param = document.createElement('param');
        param.name = 'wmode';
        param.value = wmodeValue;
        objects[i].appendChild(param);
        toggle(objects[i]);
      }
    }
  }
  if (embeds.length > 0) {
    for (var i = 0; i < embeds.length; i++) {
      if (force_all) {
        embeds[i].setAttribute('wmode', wmodeValue);
        toggle(embeds[i]);
      }
      else if (force_direct_gpu && embeds[i].getAttribute('wmode') == 'direct') {
        embeds[i].setAttribute('wmode', wmodeValue);
        toggle(embeds[i]);
      }
      else if (!embeds[i].getAttribute('wmode')) {
        embeds[i].setAttribute('wmode', wmodeValue);
        toggle(embeds[i]);
      }
    }
  }
}, 1024); //延时时间可能存在问题。