您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Undo a craft with Ctrl + Z and redo with Ctrl + Y
当前为
// ==UserScript== // @name IC Instance Restore on Ctrl + Z // @namespace http://tampermonkey.net/ // @version 1.5.1 // @license MIT // @description Undo a craft with Ctrl + Z and redo with Ctrl + Y // @icon https://i.imgur.com/WlkWOkU.png // @author @activetutorial on discord // @match https://neal.fun/infinite-craft/ // @run-at document-end // @grant none // ==/UserScript== (function () { 'use strict'; window.controlzdata = { ingredientInstances: { deletedInstances: [], deletedInstanceIds: [] }, resultInstances: { deletedInstances: [], deletedInstanceIds: [] }, infinitecraft: null, restoreInstances: function () { if (this.ingredientInstances.deletedInstances.length > 0) { const instancePair = this.ingredientInstances.deletedInstances.pop(); instancePair.forEach(instance => { instance.left -= 10; instance.top += 10; }); const [instanceA, instanceB] = instancePair; this.infinitecraft.duplicateInstance(instanceA); const instancesAfterDuplication1 = this.infinitecraft.instances; const instanceAId = instancesAfterDuplication1[instancesAfterDuplication1.length - 1].id; this.infinitecraft.duplicateInstance(instanceB); const instancesAfterDuplication2 = this.infinitecraft.instances; const instanceBId = instancesAfterDuplication2[instancesAfterDuplication2.length - 1].id; this.ingredientInstances.deletedInstanceIds.push([instanceAId, instanceBId]); const instances = this.infinitecraft.instances; const indexToRemove = instances.findIndex(instance => instance.id === this.resultInstances.deletedInstanceIds[this.resultInstances.deletedInstanceIds.length - 1][0]); this.resultInstances.deletedInstanceIds.pop(); if (indexToRemove !== -1) { const deletedInstance = instances[indexToRemove]; this.resultInstances.deletedInstances.push({ ...deletedInstance }); instances.splice(indexToRemove, 1); } } }, unrestoreInstances: function () { if (this.ingredientInstances.deletedInstanceIds.length > 0) { const lastRestoredData = this.ingredientInstances.deletedInstanceIds.pop(); const [instanceAId, instanceBId] = lastRestoredData; const instances = this.infinitecraft.instances; const instanceAIndex = instances.findIndex(instance => instance.id === instanceAId); const instanceBIndex = instances.findIndex(instance => instance.id === instanceBId); const instancePair = [ instances[instanceAIndex], instances[instanceBIndex] ]; this.ingredientInstances.deletedInstances.push(instancePair); if (instanceAIndex !== -1) { instances.splice(instanceAIndex, 1); } if (instanceBIndex !== -1) { instances.splice(instanceBIndex - 1, 1); } if (this.resultInstances.deletedInstances.length > 0) { const deletedInstance = this.resultInstances.deletedInstances.pop(); deletedInstance.left -= 10; deletedInstance.top += 10; deletedInstance.isNew = false; this.infinitecraft.duplicateInstance(deletedInstance); this.resultInstances.deletedInstanceIds.push([instances[instances.length - 1].id]); } } } }; function start() { if (window.$nuxt && window.$nuxt.$root && window.$nuxt.$root.$children[1] && window.$nuxt.$root.$children[1].$children[0]) { window.controlzdata.infinitecraft = window.$nuxt.$root.$children[1].$children[0].$children[0]; const ogGCR = window.controlzdata.infinitecraft.getCraftResponse; window.controlzdata.infinitecraft.getCraftResponse = async function (instanceA, instanceB) { const response = await ogGCR.apply(this, arguments); if(instanceA.elem && instanceB.elem){ window.controlzdata.ingredientInstances.deletedInstances.push([{ ...instanceA }, { ...instanceB }]); window.controlzdata.resultInstances.deletedInstanceIds.push([this.instanceId += 2]); window.controlzdata.resultInstances.deletedInstances = []; window.controlzdata.ingredientInstances.deletedInstanceIds = []; } return response; }; document.addEventListener("keydown", function(event) { if (event.ctrlKey && event.key === "z") { window.controlzdata.restoreInstances(); } if (event.ctrlKey && event.key === "y") { window.controlzdata.unrestoreInstances(); } }); } else { setTimeout(start, 2000); } } start(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址