Infinite Craft Element Cheat

Adds a visual GUI for quickly editing your browser's local storage, allowing you to add whatever custom object you want.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Infinite Craft Element Cheat
// @namespace    https://duckwithsunglasses.com
// @version      1.02
// @description  Adds a visual GUI for quickly editing your browser's local storage, allowing you to add whatever custom object you want.
// @author       You
// @match        https://neal.fun/infinite-craft/
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    console.log("Script starting...");

    // Function to parse and stringify JSON data from/to local storage
    function getCraftData() {
        console.log("Fetching craft data...");
        return JSON.parse(localStorage.getItem('infinite-craft-data') || '{"elements":[]}');
    }

    function setCraftData(data) {
        console.log("Setting craft data...");
        localStorage.setItem('infinite-craft-data', JSON.stringify(data));
    }

    // Function to add a new element to the data
    function addElement(text, emoji, discovered) {
        console.log("Adding new element...");
        var data = getCraftData();
        data.elements.push({ text: text, emoji: emoji, discovered: discovered });
        setCraftData(data);
    }

    // Function to create and append GUI elements
    function createGUI() {
        console.log("Creating GUI...");

        var container = document.createElement('div');
        container.innerHTML = `
            <style>
                #container {
                    padding-top: 50px;
                    padding-left: 10px;
                    position: absolute;
                }
            </style>
            <div id="container">
                <h2>Add New Element:</h2>
                <input type="text" id="element-text" placeholder="Element Name"><br>
                <input type="text" id="element-emoji" placeholder="Emoji"><br>
                <label for="element-discovered">New Discovery?:</label>
                <input type="checkbox" id="element-discovered"><br>
                <button id="add-element-btn">Add Element</button>
            </div>
        `;
        document.body.appendChild(container);

        // Add event listener to the "Add Element" button
        document.getElementById('add-element-btn').addEventListener('click', function() {
            console.log("Add Element button clicked...");
            var text = document.getElementById('element-text').value.trim();
            var emoji = document.getElementById('element-emoji').value.trim();
            var discovered = document.getElementById('element-discovered').checked;

            if (text && emoji) {
                console.log("Element name and emoji entered...");
                addElement(text, emoji, discovered);
                console.log("Reloading page...");
                // Reload the page to reflect changes
                window.location.reload();
            } else {
                console.error('Please enter both element name and emoji.');
                alert('Please enter both element name and emoji.');
            }
        });
    }

    // Call the function to create the GUI when the page is loaded
    console.log("Waiting for page to load...");
    // Set a timeout to ensure the script doesn't get stuck indefinitely
    var timeout = setTimeout(function() {
        console.error("Page load timeout. Proceeding anyway...");
        createGUI();

            // remove search cus god damn autosnap is annoying
    var sidebarInput = document.querySelector('.sidebar-input');
    if (sidebarInput) {
        sidebarInput.remove();
    } else {
        console.log('Element with class "sidebar-input" not found.');
    }
    }, 1000); // 5 seconds timeout

    window.addEventListener('load', function() {
        clearTimeout(timeout); // Cancel the timeout if the page loads successfully
        createGUI();

            var sidebarInput = document.querySelector('.sidebar-input');
    if (sidebarInput) {
        sidebarInput.remove();
    } else {
        console.log('Element with class "sidebar-input" not found.');
    }
    });

})();