Low-Quality Lottery Machine

A simple, low-quality lottery machine with an admin panel

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Low-Quality Lottery Machine
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  A simple, low-quality lottery machine with an admin panel
// @author       Alex Howard
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let score = 100;
    let modifyer = 1;
    let adminPanelVisible = false;
    let audioMuted = false;

    // Create the lottery container
    let lotteryBox = document.createElement("div");
    lotteryBox.style.position = "fixed";
    lotteryBox.style.top = "50%";
    lotteryBox.style.right = "10px";
    lotteryBox.style.transform = "translateY(-50%)";
    lotteryBox.style.width = "150px";
    lotteryBox.style.height = "230px";
    lotteryBox.style.backgroundColor = "black";
    lotteryBox.style.color = "white";
    lotteryBox.style.padding = "10px";
    lotteryBox.style.textAlign = "center";
    lotteryBox.style.border = "2px solid white";
    lotteryBox.style.fontFamily = "Arial, sans-serif";
    lotteryBox.style.zIndex = "9999";
    document.body.appendChild(lotteryBox);

    let title = document.createElement("div");
    title.innerText = "🎰 Lottery Machine 🎰";
    title.style.fontSize = "14px";
    title.style.marginBottom = "10px";
    lotteryBox.appendChild(title);

    let resultDisplay = document.createElement("div");
    resultDisplay.innerText = "Press Draw!";
    resultDisplay.style.fontSize = "20px";
    resultDisplay.style.marginBottom = "10px";
    resultDisplay.style.fontWeight = "bold";
    lotteryBox.appendChild(resultDisplay);

    let scoreDisplay = document.createElement("div");
    scoreDisplay.innerText = "Score: " + score + " | Current Winrate:" + (modifyer * 0.05);
    scoreDisplay.style.fontSize = "16px";
    scoreDisplay.style.marginBottom = "10px";
    lotteryBox.appendChild(scoreDisplay);

    let soundButton = document.createElement("button");
    soundButton.innerText = "Mute/Unmute";
    soundButton.style.marginTop = "5px";
    soundButton.style.padding = "5px 10px";
    soundButton.style.cursor = "pointer";
    soundButton.style.border = "none";
    soundButton.style.backgroundColor = "white";
    soundButton.style.color = "black";
    soundButton.onclick = function() {
        if (audioMuted == false) {
            audioMuted = true;
        } else {
            audioMuted = false;
        };
    };

    let drawButton = document.createElement("button");
    drawButton.innerText = "Draw!";
    drawButton.style.padding = "5px 10px";
    drawButton.style.fontSize = "14px";
    drawButton.style.cursor = "pointer";
    drawButton.style.border = "none";
    drawButton.style.backgroundColor = "gold";
    drawButton.style.color = "black";
    drawButton.onclick = function() {
        if (score <= 0) return;

        score -= 10;
        let isWin = Math.random() < (0.05 * modifyer);
        resultDisplay.innerText = isWin ? "💰 JACKPOT! 💰" : "😢 Try Again";

        if (isWin) {
            score += 50;
            if (audioMuted == false) {
                let winSound = new Audio("https://www.myinstants.com/media/sounds/i-cant-stop-winning.mp3");
                winSound.play();
            };
        } else {
            if (audioMuted == false) {
                let loseSound = new Audio("https://www.myinstants.com/media/sounds/baby-laughing-meme.mp3");
                loseSound.play();
            };
        }

        scoreDisplay.innerText = "Score: " + score + " | Current Winrate:" + (modifyer * 0.05);

        if (score <= 0) {
            resultDisplay.innerText = "❌ You Lose!";
            lotteryBox.style.transition = "top 1s ease-out, opacity 10s ease-out";
            lotteryBox.style.top = "100%";
            lotteryBox.style.opacity = "0";
            setTimeout(() => lotteryBox.remove(), 1000);
        }
    };
    lotteryBox.appendChild(drawButton);
    lotteryBox.appendChild(soundButton);

    let keysPressed = new Set();

    document.addEventListener("keydown", (event) => {
        keysPressed.add(event.key.toLowerCase());
        checkCombination();
    });

    document.addEventListener("keyup", (event) => {
        keysPressed.delete(event.key.toLowerCase());
    });

    function checkCombination() {
        if (keysPressed.has("shift") && keysPressed.has("a") && keysPressed.has("k")) {
            triggerAdminPanel();
        }
    }

    function triggerAdminPanel() {
        if (adminPanelVisible) return;
        adminPanelVisible = true;

        if (audioMuted == false) {
            let SFX = new Audio("https://www.myinstants.com/media/sounds/ding-sound-effect-1.mp3");
            SFX.play();
        };

        let adminPanel = document.createElement("div");
        adminPanel.style.position = "fixed";
        adminPanel.style.top = "50%";
        adminPanel.style.left = "50%";
        adminPanel.style.transform = "translate(-50%, -50%)";
        adminPanel.style.width = "300px";
        adminPanel.style.height = "200px";
        adminPanel.style.backgroundColor = "rgba(0, 0, 0, 0.9)";
        adminPanel.style.color = "white";
        adminPanel.style.padding = "15px";
        adminPanel.style.textAlign = "center";
        adminPanel.style.border = "2px solid white";
        adminPanel.style.fontFamily = "Arial, sans-serif";
        adminPanel.style.zIndex = "10000";

        let adminTitle = document.createElement("div");
        adminTitle.innerText = "🔧 Admin Panel 🔧";
        adminTitle.style.fontSize = "18px";
        adminTitle.style.marginBottom = "10px";
        adminPanel.appendChild(adminTitle);

        let modifyButton = document.createElement("button");
        modifyButton.innerText = "Add '421482859835852' to Modifyer";
        modifyButton.style.marginTop = "5px";
        modifyButton.style.padding = "5px 10px";
        modifyButton.style.cursor = "pointer";
        modifyButton.style.border = "none";
        modifyButton.style.backgroundColor = "white";
        modifyButton.style.color = "black";
        modifyButton.onclick = function() {
            modifyer += 421482859835852;
        };

        let closeButton = document.createElement("button");
        closeButton.innerText = "Close";
        closeButton.style.marginTop = "15px";
        closeButton.style.padding = "5px 10px";
        closeButton.style.cursor = "pointer";
        closeButton.style.border = "none";
        closeButton.style.backgroundColor = "red";
        closeButton.style.color = "white";
        closeButton.onclick = function() {
            adminPanel.remove();
            adminPanelVisible = false;
        };
        adminPanel.appendChild(closeButton);
        adminPanel.appendChild(modifyButton);

        document.body.appendChild(adminPanel);
    }
})();