Force Flash Wmode GPU

Force flash video playback to use wmode=gpu to allow hardware acceleration, based on Mikhoul's userscripts.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Force Flash Wmode GPU
// @namespace edsgerlin.com
// @description Force flash video playback to use wmode=gpu to allow hardware acceleration, based on Mikhoul's userscripts. 
// @author      Chin-Yuan Lin
// @version     0.0.2
// @include *
// @grant none
// ==/UserScript==

(() => {
    'use strict';
    if (!Element.prototype.matches) {
        Element.prototype.matches =
            Element.prototype.matchesSelector ||
            Element.prototype.mozMatchesSelector ||
            Element.prototype.msMatchesSelector ||
            Element.prototype.oMatchesSelector ||
            Element.prototype.webkitMatchesSelector ||
            function(s) {
            const matches = (this.document || this.ownerDocument).querySelectorAll(s);
            let i = matches.length;
            while (--i >= 0 && matches.item(i) !== this) {}
            return i > -1;
        };
    }
    new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            const addedNodes = Array.from(mutation.addedNodes||[]);
            addedNodes.forEach(addedNode => {
                if (addedNode.nodeType !== Node.ELEMENT_NODE) {
                    return;
                }
                if (addedNode.matches('object[type=\'application/x-shockwave-flash\']')) {
                    addedNode.querySelector("object>param[name='wmode']").value = 'gpu';
                }
            });
        });
    }).observe(document.body, {
        childList: true,
        subtree: true
    });
})();