TTRS Helper (Answer Overlay)

Shows answers for times table questions

このスクリプトは単体で利用できません。右のようなメタデータを含むスクリプトから、ライブラリとして読み込まれます: // @require https://update.sleazyfork.org/scripts/576729/1816395/TTRS%20Helper%20%28Answer%20Overlay%29.js

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         TTRS Helper (Answer Overlay)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Shows answers for times table questions
// @match        *://play.ttrockstars.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function getAnswer(text) {
        // Match patterns like "7 x 8"
        const match = text.match(/(\d+)\s*[x×]\s*(\d+)/i);
        if (!match) return null;

        const a = parseInt(match[1], 10);
        const b = parseInt(match[2], 10);

        return a * b;
    }

    function createOverlay() {
        const box = document.createElement("div");
        box.id = "ttrs-helper-box";
        box.style.position = "fixed";
        box.style.bottom = "20px";
        box.style.right = "20px";
        box.style.background = "black";
        box.style.color = "lime";
        box.style.padding = "10px 15px";
        box.style.fontSize = "20px";
        box.style.borderRadius = "8px";
        box.style.zIndex = "9999";
        box.textContent = "Answer: ?";
        document.body.appendChild(box);
        return box;
    }

    const overlay = createOverlay();

    function scanQuestion() {
        // Try to find question text on page
        const bodyText = document.body.innerText;

        const answer = getAnswer(bodyText);

        if (answer !== null) {
            overlay.textContent = "Answer: " + answer;
        }
    }

    // Check repeatedly (game updates fast)
    setInterval(scanQuestion, 500);

})();