shows correct answer in chrome console

Logs only the status field from /grades/partial/add responses.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         shows correct answer in chrome console
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Logs only the status field from /grades/partial/add responses.
// @match        https://login.smasheducation.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function logLastStatus(data) {
        const answers = data?.data?.answers;
        if (answers && answers.length > 0) {
            const last = answers[answers.length - 1];
            console.clear(); // Clear the console every time
            console.log("[Captured Status] Last Answer:", last.status);
        }
    }

    // Patch fetch
    const originalFetch = window.fetch;
    window.fetch = function(...args) {
        return originalFetch.apply(this, args).then(response => {
            if (args[0].includes('/services/api/grades/partial/add')) {
                response.clone().json()
                    .then(logLastStatus)
                    .catch(() => console.log("[Captured Response] Non-JSON"));
            }
            return response;
        });
    };

    // Patch XMLHttpRequest
    const originalXHR = window.XMLHttpRequest;
    function XHRProxy() {
        const xhr = new originalXHR();
        const open = xhr.open;
        xhr.open = function(method, url, ...rest) {
            this._url = url;
            return open.apply(this, [method, url, ...rest]);
        };
        const send = xhr.send;
        xhr.send = function(body) {
            this.addEventListener('load', () => {
                if (this._url.includes('/services/api/grades/partial/add')) {
                    try {
                        logLastStatus(JSON.parse(this.responseText));
                    } catch { /* ignore non-JSON responses */ }
                }
            });
            return send.apply(this, [body]);
        };
        return xhr;
    }
    window.XMLHttpRequest = XHRProxy;

})();