Better Buzz Maths

Fixes the dumb math test images in Agilix Buzz so you can actually read them

目前为 2024-08-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         Better Buzz Maths
// @namespace    https://greasyfork.org/users/1359538
// @version      2024-08-29
// @description  Fixes the dumb math test images in Agilix Buzz so you can actually read them
// @author       Deniz
// @license      MIT
// @icon         https://www.google.com/s2/favicons?sz=64&domain=agilixbuzz.com
// @match        https://legacy.agilixbuzz.com/student/*/activity/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const urlCheck = 'https://cdn.flvs.net/assessment_images/educator_mjgr7math_v22/';

    function fixImg(img) {
        img = img.target
        img.style.filter = 'invert(1)';
    }

    function checkImg(img) {
        if (img.src.startsWith(urlCheck)) {
            if (img.complete) {
                fixImg(img);
            } else {
                img.addEventListener('load', fixImg, {once:true});
            }

        }
    }

    const observer = new MutationObserver((mutationsList) => {
        for (const mut of mutationsList) {
            if (mut.type === 'childList') {
                for (const n of mut.addedNodes) {
                    if (n.tagName === 'IMG') {
                        checkImg(n);
                    }
                }
            }
        }
    });

    observer.observe(document.body, {childList:true, subtree:true});

}());