Force Flash Wmode GPU

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

Stan na 13-02-2017. 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==
// jshint esversion: 6
// @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.1
// @include http://www.youtube.com/watch*
// @include http://youtube.com/watch*
// @include https://www.youtube.com/watch*
// @include https://youtube.com/watch*
// @include	http://dailymotion.com*
// @include	http://www.dailymotion.com*
// @include	https://dailymotion.com*
// @include	https://www.dailymotion.com*
// @include	http://vimeo.com*
// @include	http://www.vimeo.com*
// @include	https://vimeo.com*
// @include	https://www.vimeo.com*
// @include	http://metacafe.com*
// @include	http://www.metacafe.com*
// @include	https://metacafe.com*
// @include	https://www.metacafe.com*
// @include	http://funnyordie.com*
// @include	http://www.funnyordie.com*
// @include	https://funnyordie.com*
// @include	https://www.funnyordie.com*
// @include	http://videojug.com*
// @include	http://www.videojug.com*
// @include	https://videojug.com*
// @include	https://www.videojug.com*
// @include	http://blip.tv*
// @include	http://www.blip.tv*
// @include	https://blip.tv*
// @include	https://www.blip.tv*
// @include	http://vevo.com*
// @include	http://www.vevo.com*
// @include	https://vevo.com*
// @include	https://www.vevo.com*
// @include http://megavideo.com/*v=*
// @include	http://www.megavideo.com/*v=*
// @include	http://megaporn.com/video/*v=*
// @include	http://www.megaporn.com/video/*v=*
// @include	http://facebook.com/*video*
// @include	http://www.facebook.com/*video*
// @include	http://www.collegehumor.com/video/*
// @include	http://redtube.com/*
// @include	http://www.redtube.com/*
// @include	http://youporn.com/*watch*
// @include	http://www.youporn.com/*watch*
// @include	http://pornhub.com/*video*
// @include	http://www.pornhub.com/*video*
// @include	http://pornotube.com/*media*
// @include	http://www.pornotube.com/*media*
// @include	http://pornotube.com/*m=*
// @include	http://www.pornotube.com/*m=*
// @include	http://xvideos.com/*video*
// @include	http://www.xvideos.com/*video*
// @include	http://www.keezmovies.com/*
// @include	http://keezmovies.com/*
// @include	http://www.tube8.com/*
// @include	http://www.twitch.tv/*
// @include http://*.bilibili.com/*
// @include http://*.acfun.cn/*
// @include http://www.iqiyi.com/*
// @include https://v.qq.com/*
// @include http://v.qq.com/*
// @grant none
// ==/UserScript==

(() => {
    'use strict';

    const targetNode = document.body;
    const matchSelector = "object[type='application/x-shockwave-flash']";
    const onMatch = node => {
        const wmodeParam = node.querySelector("object>param[name='wmode']");
        if(wmodeParam){
            wmodeParam.value="gpu";
            return true;
        }
    };
    const MutationObserver=window.MutationObserver;
    // Polyfill for Element.matches().
    if (!Element.prototype.matches) {
        Element.prototype.matches =
            Element.prototype.matchesSelector ||
            Element.prototype.mozMatchesSelector ||
            Element.prototype.msMatchesSelector ||
            Element.prototype.oMatchesSelector ||
            Element.prototype.webkitMatchesSelector ||
            s => {
            const matches = (this.document || this.ownerDocument).querySelectorAll(s);
            let i = matches.length;
            while (--i >= 0 && matches.item(i) !== this) {}
            return i > -1;
        };
    }
    const observer = new MutationObserver(mutations => {
        mutations.some(mutation => {
            const addedNodes=Array.from(mutation.addedNodes||[]);
            return addedNodes.some(node => {
                if(node.nodeType!==Node.ELEMENT_NODE){
                    return;
                }
                else if(!node.matches(matchSelector)) {
                    return;
                }
                return onMatch(node);
            });
        });
    });
    const options={childList: true, subtree: true};
    observer.observe(targetNode, options);
})();