Greasy Fork

Greasy Fork is available in English.

Basic Math Solver

A simple calculator for addition, subtraction, and multiplication that floats on any webpage.

当前为 2024-11-23 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @version 0.2
// @name         Basic Math Solver
// @namespace    https://example.com
// @description  A simple calculator for addition, subtraction, and multiplication that floats on any webpage.
// @author       nukerboss
// @match         http://live.mathletics.com/*
// @match        *://live.mathletics.com/*
// @grant        none
// ==/UserScript==
// @license MIT
(function() {
    'use strict';

    // Create a floating calculator div
    const calculator = document.createElement('div');
    calculator.style.position = 'fixed';
    calculator.style.bottom = '20px';
    calculator.style.right = '20px';
    calculator.style.width = '300px';
    calculator.style.padding = '10px';
    calculator.style.backgroundColor = '#f0f0f0';
    calculator.style.border = '1px solid #ccc';
    calculator.style.borderRadius = '10px';
    calculator.style.boxShadow = '0px 0px 10px rgba(0,0,0,0.1)';
    calculator.style.zIndex = '9999';
    calculator.innerHTML = `
        <h3>Math Solver</h3>
        <input type="text" id="mathInput" placeholder="Enter math problem (e.g., 5+3)" style="width: 90%; padding: 5px; margin-bottom: 10px;" />
        <button id="calculateBtn" style="padding: 5px 10px;">Calculate</button>
        <div id="result" style="margin-top: 10px; font-weight: bold;"></div>
    `;
    document.body.appendChild(calculator);

    // Add event listener to the calculate button
    document.getElementById('calculateBtn').addEventListener('click', function() {
        const mathInput = document.getElementById('mathInput').value;
        const resultDiv = document.getElementById('result');

        try {
            // Evaluate the math expression
            const result = eval(mathInput);
            resultDiv.textContent = `Result: ${result}`;
        } catch (error) {
            resultDiv.textContent = "Invalid input! Please enter a valid math problem.";
        }
    });
})();