Better Buzz Maths

Fixes the weird math test images in Agilix Buzz

  1. // ==UserScript==
  2. // @name Better Buzz Maths
  3. // @namespace https://greasyfork.org/users/1359538
  4. // @version 1.5
  5. // @description Fixes the weird math test images in Agilix Buzz
  6. // @license MIT
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=agilixbuzz.com
  8. // @homepage https://greasyfork.org/scripts/505681
  9. // @match https://legacy.agilixbuzz.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const url = /cdn\.flvs\.net\/.*math_.*/;
  17.  
  18. function fixImg(img) {
  19. if (url.test(img.src)) {
  20. img.style.filter = 'brightness(0.5) invert(1)';
  21. }
  22. }
  23.  
  24. document.querySelectorAll('img').forEach(img => fixImg(img));
  25.  
  26. const observer = new MutationObserver((mutationsList) => {
  27. for (const mut of mutationsList) {
  28. if (mut.type === 'childList') {
  29. for (const n of mut.addedNodes) {
  30. if (n.tagName === 'IMG') {
  31. fixImg(n);
  32. } else if (n.nodeType === Node.ELEMENT_NODE) {
  33. n.querySelectorAll('img').forEach(img => fixImg(img));
  34. }
  35. }
  36. }
  37. }
  38. });
  39.  
  40. observer.observe(document.body, {childList: true, subtree: true});
  41. }());