Flash Accelerate

开启FlashPlayer硬件渲染加速

当前为 2016-11-06 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Flash Accelerate
// @namespace   [email protected]
// @description 开启FlashPlayer硬件渲染加速
// @include     http://*
// @include     https://*
// @exclude     http://www.imdb.com/*
// @exclude     http://www.xiami.com/play*
// @version     1.16
// @grant       none
// ==/UserScript==
//创意来自 gpu-accelerated-flash-player 扩展!
//是否有加速效果作者也不知道。
//关于wmode参数的解释:http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html
//如果你使用的是firefox,可以在about:config将plugins.force.wmode修改(新建)为 gpu 或 direct
//如果你发现平时正常浏览的网页无法正常使用,请优先禁用此脚本以排查问题
//
var run_time_max = 2; //最大运行次数
var wmode_value = 'gpu'; //默认 gpu,可以是 direct。一般不需要更改

var debug = true;
function main(){
	['object','embed'].forEach(function(tagname){
		[].slice.call(document.querySelectorAll(tagname) || []).forEach(function(element){
			//debug?console.log(element):null;
			if( !element || element.type != 'application/x-shockwave-flash' || (element.clientWidth<300 || element.clientHeight<300))
			{
				return;
			}
			else
			{
				debug?console.log(element):null;
				if(tagname == 'object')
				{
					debug?console.log(element.children):null;
					[].slice.call(element.children || []).forEach(function(node){
						if(node && node.name && node.name.toLowerCase() == 'wmode')
						{
							node.parentElement.removeChild(node);
						}
					});
					var e = document.createElement('param');
					e.name = 'wmode';
					e.value = wmode_value;
					element.appendChild(e);
				}
				else
				{
					element.setAttribute('wmode',wmode_value);
				}
				if(!element.getAttribute('fa-sign'))
				{
					element.setAttribute('fa-sign',1);
					element.parentElement.replaceChild(element.cloneNode(true),element);
				}
			}
		});
	});
}

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 += 1;
  main();
  
}, 1500);