Greasy Fork is available in English.

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.

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. // ==UserScript==
  2. // @name Infinite Craft Element Cheat
  3. // @namespace https://duckwithsunglasses.com
  4. // @version 1.02
  5. // @description Adds a visual GUI for quickly editing your browser's local storage, allowing you to add whatever custom object you want.
  6. // @author You
  7. // @match https://neal.fun/infinite-craft/
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. console.log("Script starting...");
  16.  
  17. // Function to parse and stringify JSON data from/to local storage
  18. function getCraftData() {
  19. console.log("Fetching craft data...");
  20. return JSON.parse(localStorage.getItem('infinite-craft-data') || '{"elements":[]}');
  21. }
  22.  
  23. function setCraftData(data) {
  24. console.log("Setting craft data...");
  25. localStorage.setItem('infinite-craft-data', JSON.stringify(data));
  26. }
  27.  
  28. // Function to add a new element to the data
  29. function addElement(text, emoji, discovered) {
  30. console.log("Adding new element...");
  31. var data = getCraftData();
  32. data.elements.push({ text: text, emoji: emoji, discovered: discovered });
  33. setCraftData(data);
  34. }
  35.  
  36. // Function to create and append GUI elements
  37. function createGUI() {
  38. console.log("Creating GUI...");
  39.  
  40. var container = document.createElement('div');
  41. container.innerHTML = `
  42. <style>
  43. #container {
  44. padding-top: 50px;
  45. padding-left: 10px;
  46. position: absolute;
  47. }
  48. </style>
  49. <div id="container">
  50. <h2>Add New Element:</h2>
  51. <input type="text" id="element-text" placeholder="Element Name"><br>
  52. <input type="text" id="element-emoji" placeholder="Emoji"><br>
  53. <label for="element-discovered">New Discovery?:</label>
  54. <input type="checkbox" id="element-discovered"><br>
  55. <button id="add-element-btn">Add Element</button>
  56. </div>
  57. `;
  58. document.body.appendChild(container);
  59.  
  60. // Add event listener to the "Add Element" button
  61. document.getElementById('add-element-btn').addEventListener('click', function() {
  62. console.log("Add Element button clicked...");
  63. var text = document.getElementById('element-text').value.trim();
  64. var emoji = document.getElementById('element-emoji').value.trim();
  65. var discovered = document.getElementById('element-discovered').checked;
  66.  
  67. if (text && emoji) {
  68. console.log("Element name and emoji entered...");
  69. addElement(text, emoji, discovered);
  70. console.log("Reloading page...");
  71. // Reload the page to reflect changes
  72. window.location.reload();
  73. } else {
  74. console.error('Please enter both element name and emoji.');
  75. alert('Please enter both element name and emoji.');
  76. }
  77. });
  78. }
  79.  
  80. // Call the function to create the GUI when the page is loaded
  81. console.log("Waiting for page to load...");
  82. // Set a timeout to ensure the script doesn't get stuck indefinitely
  83. var timeout = setTimeout(function() {
  84. console.error("Page load timeout. Proceeding anyway...");
  85. createGUI();
  86.  
  87. // remove search cus god damn autosnap is annoying
  88. var sidebarInput = document.querySelector('.sidebar-input');
  89. if (sidebarInput) {
  90. sidebarInput.remove();
  91. } else {
  92. console.log('Element with class "sidebar-input" not found.');
  93. }
  94. }, 1000); // 5 seconds timeout
  95.  
  96. window.addEventListener('load', function() {
  97. clearTimeout(timeout); // Cancel the timeout if the page loads successfully
  98. createGUI();
  99.  
  100. var sidebarInput = document.querySelector('.sidebar-input');
  101. if (sidebarInput) {
  102. sidebarInput.remove();
  103. } else {
  104. console.log('Element with class "sidebar-input" not found.');
  105. }
  106. });
  107.  
  108. })();