L

make an ectension that plays infinite craft

Kodari AI
KodariJul 1 at 5:13 pm 1

I’ll create an extension that automates Infinite Craft by systematically combining elements to discover new ones.

InfiniteCraftAutoPlayer
A Chrome extension that automatically plays Infinite Craft (neal.fun) by systematically combining elements. Features automated element discovery through breadth-first search of all combinations, real-time progress tracking showing element count and combinations tried, start/stop controls, and a clean popup UI with statistics and activity log. Uses DOM interaction to simulate drag-and-drop combinations and MutationObserver to detect new discoveries.
L

so how to install it

Kodari AI
KodariJul 1 at 5:15 pm 1

Here’s how to install it:

Install Infinite Craft Auto Player

1. Save the files

I’ve already created all the files in your project. The ZIP export is ready — download and extract it to a folder on your computer (not in a ZIP).

2. Open Chrome Extensions page

Type this in your Chrome address bar:

Plain Text
chrome://extensions

3. Enable Developer mode

  • Toggle “Developer mode” on (top-right corner)

4. Load the extension

  • Click “Load unpacked”

  • Select the folder you extracted

5. Try it

The extension will automatically drag elements from the sidebar onto the workspace to discover new combinations. It tracks how many elements you’ve found and how many combinations you’ve tried.

Tip: If you want a fresh start, check “Use fresh workspace” before starting — it will clear the current board and work from Fire + Water. Otherwise it works with whatever elements are already in your sidebar.

Kodari can make mistakes. Review important code before using.
Files
background.js
content.js
manifest.json
popup.css
popup.html
popup.js
Code
6 862
content.js
// === Infinite Craft Automation Engine ===

const BASIC_ELEMENTS = ['Fire', 'Water', 'Earth', 'Wind'];

class InfiniteCraftPlayer {
  constructor() {
    this.elements = new Set(BASIC_ELEMENTS);
    this.tried = new Set();
    this.running = false;
    this.speed = 600;
    this.stats = { tried: 0, found: 4, startedAt: null, discoveries: 0 };
    this.observer = null;
    this.pendingCheck = false;
    this.elementCache = new Map();
    this.isProcessing = false;
    this.needsRescan = false;
    this.abortController = null;
  }

  sendState() {
    chrome.runtime.sendMessage({
      type: 'state',
      data: {
        running: this.running,
        elements: this.elements.size,
        tried: this.stats.tried,
        startedAt: this.stats.startedAt,
        discoveries: this.stats.discoveries
      }
    });
  }

  log(type, text) {
    chrome.runtime.sendMessage({ type: 'activity', data: { type, text } });
  }

  error(text) {
    chrome.runtime.sendMessage({ type: 'error', data: { text } });
  }

  findElementNodes() {
    // Try multiple strategies to find element nodes in the game
    const candidates = new Set();

    // Strategy 1: Look for elements with specific data attributes or classes
    const selectors = [
      '[class*="element-sidebar"] [class*="item"]',
      '[class*="sidebar-item"]',
      '[class*="element"] [class*="name"]',
      '[class*="craft-element"]',
      '[class*="inventory"] [class*="item"]',
      '[class*="elementList"] [class*="element"]',
      '[class*="sidebar-content"] > div',
      '[class*="element"]'
    ];

    for (const sel of selectors) {
      try {
        const nodes = document.querySelectorAll(sel);
        if (nodes.length >= 2) {
          nodes.forEach(n => candidates.add(n));
          break;
        }
      } catch (e) {}
    }

    // Strategy 2: Find all draggable elements with short text
    if (candidates.size < 2) {
      const all = document.querySelectorAll('[draggable="true"], [class*="elem"], [class*="item"], [class*="tile"]');
      all.forEach(n => {
        const text = n.textContent.trim();
        if (text && text.length < 40 && !text.includes('\n')) {
          candidates.add(n);
        }
      });
    }

    // Strategy 3: Look for any text-bearing elements that look like game elements
    if (candidates.size < 2) {
      const possibleContainers = document.querySelectorAll('main, [class*="game"], [class*="app"], [class*="craft"]');
      possibleContainers.forEach(container => {
        const textElements = container.querySelectorAll('span, div, p');
        textElements.forEach(el => {
          const text = el.textContent.trim();
          if (text && text.length < 30 && /^[A-Z][a-z]/.test(text)) {
            candidates.add(el);
          }
        });
      });
    }

    // Filter to only keep valid element nodes (has text, reasonable size)
    return Array.from(candidates).filter(n => {
      const text = n.textContent.trim();
      return text && text.length < 40 && text.length > 0;
    });
  }

  scanForNewElements() {
    const nodes = this.findElementNodes();
    const found = new Set();

    for (const node of nodes) {
      const text = node.textContent.trim();
      if (text && text.length < 40) {
        found.add(text);
        if (!this.elements.has(text)) {
          this.elementCache.set(text, node);
        }
      }
    }

    let added = 0;
    for (const name of found) {
      if (!this.elements.has(name) && !BASIC_ELEMENTS.includes(name)) {
        this.elements.add(name);
        added++;
        this.stats.discoveries++;
        this.log('found', `✦ ${name}`);
        this.sendState();
      }
    }

    // Cache the DOM nodes for elements we know
    for (const name of this.elements) {
      if (!this.elementCache.has(name)) {
        const match = nodes.find(n => n.textContent.trim() === name);
        if (match) this.elementCache.set(name, match);
      }
    }

    if (added > 0) {
      this.log('info', `Discovered ${added} new element(s)! Total: ${this.elements.size}`);
    }

    return added;
  }

  startObserver() {
    if (this.observer) this.observer.disconnect();

    this.observer = new MutationObserver(() => {
      if (!this.pendingCheck) {
        this.pendingCheck = true;
        setTimeout(() => {
          this.pendingCheck = false;
          this.scanForNewElements();
        }, 500);
      }
    });

    this.observer.observe(document.body, {
      childList: true,
      subtree: true,
      characterData: true
    });
  }

  stopObserver() {
    if (this.observer) {
      this.observer.disconnect();
      this.observer = null;
    }
  }

  async getElementNode(name) {
    // Check cache first
    if (this.elementCache.has(name)) {
      const cached = this.elementCache.get(name);
      if (document.body.contains(cached)) return cached;
    }

    // Search again
    const nodes = this.findElementNodes();
    for (const node of nodes) {
      if (node.textContent.trim() === name) {
        this.elementCache.set(name, node);
        return node;
      }
    }

    return null;
  }

  async tryCombine(a, b) {
    const key = [a, b].sort().join('|');
    if (this.tried.has(key)) return false;
    this.tried.add(key);

    const nodeA = await this.getElementNode(a);
    const nodeB = await this.getElementNode(b);
    if (!nodeA || !nodeB) return false;

    const rectA = nodeA.getBoundingClientRect();
    const rectB = nodeB.getBoundingClientRect();

    if (rectA.width === 0 || rectA.height === 0 || rectB.width === 0 || rectB.height === 0) {
      return false;
    }