Insert elements

Insert random elements to space

当前为 2025-02-23 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Insert elements
// @description  Insert random elements to space
// @match        https://neal.fun/infinite-craft/
// @license      MIT
// @version 0.0.1.20250223131321
// @namespace https://greasyfork.org/users/1438939
// ==/UserScript==

// Creating UI for selecting the number of clicks
function createClickUI() {
    let uiContainer = document.createElement('div');
    uiContainer.style.position = 'fixed';
    uiContainer.style.top = '10px';
    uiContainer.style.right = '10px';
    uiContainer.style.background = 'rgba(0, 0, 0, 0.8)';
    uiContainer.style.color = 'white';
    uiContainer.style.padding = '10px';
    uiContainer.style.borderRadius = '8px';
    uiContainer.style.zIndex = '9999';
    uiContainer.style.fontFamily = 'Arial, sans-serif';
    uiContainer.innerHTML = `<h3 style="margin: 0 0 10px;">How many times would you like to click?</h3><div id="click-options"></div>`;

    document.body.appendChild(uiContainer);

    let clickOptions = document.getElementById('click-options');
    let values = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024];

    values.forEach(value => {
        let btn = document.createElement('button');
        btn.innerText = value;
        btn.style.display = 'block';
        btn.style.width = '100%';
        btn.style.marginBottom = '5px';
        btn.style.padding = '5px';
        btn.style.background = '#444';
        btn.style.color = 'white';
        btn.style.border = 'none';
        btn.style.borderRadius = '5px';
        btn.style.cursor = 'pointer';

        btn.addEventListener('click', () => {
            startClicking(value);
        });

        clickOptions.appendChild(btn);
    });
}

// Function to click a random item
function clickRandomItem() {
    let items = document.querySelectorAll('.sidebar .item'); // Get the items list on the right
    if (items.length === 0) return;

    let randomIndex = Math.floor(Math.random() * items.length);
    items[randomIndex].click();
}

// Start clicking the selected number of times
function startClicking(times) {
    let counter = 0;

    let interval = setInterval(() => {
        if (counter >= times) {
            clearInterval(interval);
        } else {
            clickRandomItem();
            counter++;
        }
    }, 100); // Click every 100ms
}

// Start the script
createClickUI();