您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Drop two random elements into Infinite Craft play area with one click
当前为
// ==UserScript== // @name Infinite Craft Random Button (2025 Fixed Version) // @namespace http://your-namespace.example // @version 2025.04.09 // @description Drop two random elements into Infinite Craft play area with one click // @author You // @match https://neal.fun/infinite-craft/ // @grant none // @license MIT // ==/UserScript== (async function () { 'use strict'; const wait = (ms) => new Promise((r) => setTimeout(r, ms)); // Wait for Vue app to load while (!document.querySelector('.container')?.__vue__) { await wait(100); } const app = document.querySelector('.container').__vue__; const main = app.$children[0] || app; const getItems = () => Array.from(document.querySelectorAll('.items .item')); const getRandomItem = () => { const items = getItems(); return items[Math.floor(Math.random() * items.length)]; }; const getCenterCoords = (offsetY = 0) => { const x = window.innerWidth / 2; const y = window.innerHeight / 2 + offsetY; return [x, y]; }; // Create the button const randomButton = document.createElement('img'); randomButton.src = 'https://api.iconify.design/ic:outline-question-mark.svg'; randomButton.style.width = '24px'; randomButton.style.cursor = 'pointer'; randomButton.style.margin = '8px'; const controls = document.querySelector('.side-controls'); controls.insertBefore(randomButton, controls.firstChild); randomButton.addEventListener('click', async () => { const item1 = getRandomItem(); const item2 = getRandomItem(); const simulateDrop = async (item, offsetY) => { // Simulate dragging the element item.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })); await wait(50); const [x, y] = getCenterCoords(offsetY); document.dispatchEvent(new MouseEvent('mousemove', { bubbles: true, clientX: x, clientY: y })); await wait(50); document.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, clientX: x, clientY: y })); await wait(100); }; await simulateDrop(item1, -40); await simulateDrop(item2, 40); }); })();