Force Flash Wmode GPU

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

  1. // ==UserScript==
  2. // @name Force Flash Wmode GPU
  3. // @namespace edsgerlin.com
  4. // @description Force flash video playback to use wmode=gpu to allow hardware acceleration, based on Mikhoul's userscripts.
  5. // @author Chin-Yuan Lin
  6. // @version 0.0.2
  7. // @include *
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (() => {
  12. 'use strict';
  13. if (!Element.prototype.matches) {
  14. Element.prototype.matches =
  15. Element.prototype.matchesSelector ||
  16. Element.prototype.mozMatchesSelector ||
  17. Element.prototype.msMatchesSelector ||
  18. Element.prototype.oMatchesSelector ||
  19. Element.prototype.webkitMatchesSelector ||
  20. function(s) {
  21. const matches = (this.document || this.ownerDocument).querySelectorAll(s);
  22. let i = matches.length;
  23. while (--i >= 0 && matches.item(i) !== this) {}
  24. return i > -1;
  25. };
  26. }
  27. new MutationObserver(mutations => {
  28. mutations.forEach(mutation => {
  29. const addedNodes = Array.from(mutation.addedNodes||[]);
  30. addedNodes.forEach(addedNode => {
  31. if (addedNode.nodeType !== Node.ELEMENT_NODE) {
  32. return;
  33. }
  34. if (addedNode.matches('object[type=\'application/x-shockwave-flash\']')) {
  35. addedNode.querySelector("object>param[name='wmode']").value = 'gpu';
  36. }
  37. });
  38. });
  39. }).observe(document.body, {
  40. childList: true,
  41. subtree: true
  42. });
  43. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址