Starblast Gem Drop Draggable

Draggable button, hold to drop gems automatically

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Starblast Gem Drop Draggable
// @namespace    starblast-ios
// @version      2.3
// @description  Draggable button, hold to drop gems automatically
// @match        https://starblast.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const btn = document.createElement("div");
    btn.innerText = "DROP";
    btn.style.position = "fixed";
    btn.style.left = "20px";
    btn.style.top = "50%";
    btn.style.transform = "translateY(-50%)";
    btn.style.background = "linear-gradient(145deg, #ffcc33, #ff9900)";
    btn.style.color = "white";
    btn.style.padding = "10px 14px";
    btn.style.borderRadius = "12px";
    btn.style.fontSize = "14px";
    btn.style.fontWeight = "bold";
    btn.style.zIndex = "9999";
    btn.style.userSelect = "none";
    btn.style.touchAction = "none";
    btn.style.boxShadow = "0 4px 10px rgba(0,0,0,0.3)";
    btn.style.textAlign = "center";
    btn.style.cursor = "grab";

    document.body.appendChild(btn);

    let dropping = false;
    let dropInterval;

    function dropGem() {
        const down = new KeyboardEvent("keydown", {
            key: "v",
            code: "KeyV",
            keyCode: 86,
            which: 86,
            bubbles: true
        });
        const up = new KeyboardEvent("keyup", {
            key: "v",
            code: "KeyV",
            keyCode: 86,
            which: 86,
            bubbles: true
        });
        document.dispatchEvent(down);
        setTimeout(() => document.dispatchEvent(up), 750);
    }

    // Dragging logic
    let isDragging = false, offsetX = 0, offsetY = 0;

    btn.addEventListener("touchstart", (e) => {
        const touch = e.touches[0];
        offsetX = touch.clientX - btn.getBoundingClientRect().left;
        offsetY = touch.clientY - btn.getBoundingClientRect().top;
        isDragging = false;
        dropping = true;

        // Start dropping after short delay
        dropInterval = setInterval(() => {
            if(dropping) dropGem();
        }, 800);

        // Detect drag after 200ms
        setTimeout(() => {
            if(e.touches[0] && e.touches[0].clientX !== undefined) {
                isDragging = true;
            }
        }, 200);
    });

    btn.addEventListener("touchmove", (e) => {
        if(isDragging){
            const touch = e.touches[0];
            btn.style.left = (touch.clientX - offsetX) + "px";
            btn.style.top = (touch.clientY - offsetY) + "px";
        }
    });

    btn.addEventListener("touchend", () => {
        dropping = false;
        clearInterval(dropInterval);
        isDragging = false;
    });

})();