Gartic Phone Auto Draw + Music Player + Random Fruit

Adds a GUI for auto-drawing, image upload, drag & drop, sound effects, a music player, and a random fruit drawer.

目前为 2025-03-26 提交的版本。查看 最新版本

// ==UserScript==
// @name         Gartic Phone Auto Draw + Music Player + Random Fruit
// @namespace    https://greasyfork.org/en/users/fdslalkad
// @version      2.1
// @description  Adds a GUI for auto-drawing, image upload, drag & drop, sound effects, a music player, and a random fruit drawer.
// @author       fdslalkad
// @match        *://garticphone.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let selectedImage = null;
    let hackzSequence = '';
    const hackzCode = 'HACKZ';

    // Fix Drag & Drop
    document.addEventListener('dragover', (e) => e.preventDefault());
    document.addEventListener('drop', (e) => {
        e.preventDefault();
        if (e.dataTransfer.files.length > 0) {
            let file = e.dataTransfer.files[0];
            let reader = new FileReader();
            reader.onload = (event) => {
                selectedImage = new Image();
                selectedImage.src = event.target.result;
                document.getElementById('statusMessage').textContent = "Image loaded!";
                setTimeout(() => {
                    document.getElementById('statusMessage').textContent = "Click AutoDraw to start!";
                    setTimeout(() => document.getElementById('statusMessage').textContent = "", 2000);
                }, 2000);
                new Audio('https://www.myinstants.com/media/sounds/ding.mp3').play();
            };
            reader.readAsDataURL(file);
        }
    });

    // Fix Music Player
    let audio = new Audio();
    let currentSongIndex = 0;
    const songs = [
        { name: "Monkeys Spinning Monkeys", author: "Kevin MacLeod", url: "https://incompetech.com/music/royalty-free/mp3-royaltyfree/Monkeys%20Spinning%20Monkeys.mp3" },
        { name: "New Friendly", author: "Kevin MacLeod", url: "https://incompetech.com/music/royalty-free/mp3-royaltyfree/New%20Friendly.mp3" }
    ];
    function playSong(index) {
        let song = songs[index];
        audio.src = song.url;
        audio.play();
        document.getElementById('nowPlaying').textContent = `Now Playing: ${song.name} | by ${song.author}`;
    }

    // Fix "Change Song" Button
    document.getElementById('changeSongBtn').addEventListener('click', () => {
        let songName = prompt("What would you like to listen to?");
        if (!songName) return;
        let foundSong = songs.find(s => s.name.toLowerCase().includes(songName.toLowerCase()));
        if (foundSong) {
            let confirmPlay = confirm(`Is this what you were looking for? - ${foundSong.name} - ${foundSong.author}`);
            if (confirmPlay) {
                playSong(songs.indexOf(foundSong));
            } else {
                new Audio('https://www.myinstants.com/media/sounds/sad-trombone.mp3').play();
            }
        } else {
            alert("Could not find song!");
        }
    });

    // Fix HACKZ Keybind
    document.addEventListener('keydown', (e) => {
        hackzSequence += e.key.toUpperCase();
        if (hackzSequence.endsWith(hackzCode)) {
            gui.style.display = gui.style.display === 'none' ? 'block' : 'none';
            hackzSequence = '';
        }
    });

    // Fix Random Fruit
    document.getElementById('randomFruitBtn').addEventListener('click', () => {
        let fruitImages = [
            "https://upload.wikimedia.org/wikipedia/commons/1/15/Red_Apple.jpg",
            "https://upload.wikimedia.org/wikipedia/commons/8/8a/Banana-Single.jpg"
        ];
        let img = new Image();
        img.src = fruitImages[Math.floor(Math.random() * fruitImages.length)];
        document.body.appendChild(img);
    });

    let gui = document.createElement('div');
    gui.style.position = 'fixed';
    gui.style.top = '10px';
    gui.style.right = '10px';
    gui.style.background = 'rgba(0,0,0,0.8)';
    gui.style.color = 'white';
    gui.style.padding = '10px';
    gui.style.borderRadius = '5px';
    gui.style.zIndex = '10000';
    gui.innerHTML = `
        <button id="autoDrawBtn">Auto Draw</button><br>
        <input type="file" id="uploadImage" accept="image/*"><br>
        <input type="text" id="imageUrl" placeholder="Image URL">
        <button id="loadImageBtn">Load Image</button><br>
        <button id="playMusicBtn">Play Random Music</button>
        <button id="pauseMusicBtn">Pause</button>
        <button id="resumeMusicBtn">Play</button>
        <button id="nextMusicBtn">Next</button>
        <button id="prevMusicBtn">Previous</button>
        <button id="stopMusicBtn">Stop</button>
        <button id="changeSongBtn">Change Song</button>
        <button id="randomFruitBtn">Random Fruit</button>
        <p id="statusMessage" style="color: lime; font-family: Sans-Serif; display: none;"></p>
        <p id="nowPlaying"></p>
    `;
    document.body.appendChild(gui);
})();