Flash Accelerate

开启FlashPlayer硬件渲染加速

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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 = false;
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);