2048 with huge tiles, new tiles as huge value, and smart auto merge
目前為
// ==UserScript==
// @name 2048 Smart Auto Merge + Super Huge
// @namespace https://github.com/PatheticMustan/HackingGames
// @version 1.0
// @description 2048 with huge tiles, new tiles as huge value, and smart auto merge
// @author PatheticMustan
// @match https://2048game.com/*
// @icon https://gabrielecirulli.github.io/2048/meta/og_image.png
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const MAX_VALUE = "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
// Set initial board only once
function setSuperHugeBoard() {
if (!localStorage.getItem("hugeBoardSet")) {
const gameState = {
grid: {
size: 4,
cells: [
[{"position":{"x":0,"y":0},"value":MAX_VALUE},{"position":{"x":0,"y":1},"value":MAX_VALUE},{"position":{"x":0,"y":2},"value":MAX_VALUE},{"position":{"x":0,"y":3},"value":MAX_VALUE}],
[{"position":{"x":1,"y":0},"value":MAX_VALUE},{"position":{"x":1,"y":1},"value":MAX_VALUE},{"position":{"x":1,"y":2},"value":MAX_VALUE},{"position":{"x":1,"y":3},"value":MAX_VALUE}],
[{"position":{"x":2,"y":0},"value":MAX_VALUE},{"position":{"x":2,"y":1},"value":MAX_VALUE},{"position":{"x":2,"y":2},"value":MAX_VALUE},{"position":{"x":2,"y":3},"value":MAX_VALUE}],
[{"position":{"x":3,"y":0},"value":MAX_VALUE},{"position":{"x":3,"y":1},"value":MAX_VALUE},{"position":{"x":3,"y":2},"value":MAX_VALUE},{"position":{"x":3,"y":3},"value":MAX_VALUE}]
]
},
score: MAX_VALUE,
over: false,
won: true,
keepPlaying: true
};
localStorage.setItem("gameState", JSON.stringify(gameState));
localStorage.setItem("hugeBoardSet", "true");
location.reload();
}
}
// Override tile spawn so all new tiles are MAX_VALUE
function overrideTileSpawn() {
const interval = setInterval(() => {
if (window.game && game.grid) {
clearInterval(interval);
const originalInsertTile = game.grid.insertTile.bind(game.grid);
game.grid.insertTile = function(tile) {
tile.value = MAX_VALUE;
originalInsertTile(tile);
};
}
}, 100);
}
// Smart auto-merge: only moves that actually change the board
function smartAutoMerge() {
const moves = {37:'left', 38:'up', 39:'right', 40:'down'};
setInterval(() => {
if (!window.game || !game.grid) return;
const currentGrid = game.grid.cells;
for (let key in moves) {
const clonedGrid = game.grid.clone();
clonedGrid.prepareTiles();
clonedGrid.move(moves[key]);
if (!gridsEqual(clonedGrid.cells, currentGrid)) {
const event = new KeyboardEvent('keydown', { keyCode: parseInt(key), which: parseInt(key) });
document.dispatchEvent(event);
break; // make one move per interval
}
}
}, 50); // fast interval for quick merging
}
function gridsEqual(a, b) {
for (let y = 0; y < a.length; y++) {
for (let x = 0; x < a[y].length; x++) {
const valA = a[y][x] ? a[y][x].value : null;
const valB = b[y][x] ? b[y][x].value : null;
if (valA !== valB) return false;
}
}
return true;
}
setSuperHugeBoard();
setTimeout(overrideTileSpawn, 2000);
setTimeout(smartAutoMerge, 3000);
})();