Egg Hunt Navigator Pro

AIO Enhanced Egg Navigator with built-in egg detection and navigation across 255+ pages — the largest collection available anywhere.

当前为 2025-04-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Egg Hunt Navigator Pro
// @namespace    eggHunt.Navigator.Pro
// @version      3.1.2
// @description  AIO Enhanced Egg Navigator with built-in egg detection and navigation across 255+ pages — the largest collection available anywhere.
// @author       Oo_Max_Payne_oO [2909733]
// @match        https://www.torn.com/*
// @grant        GM.addStyle
// @run-at       document-start
// @license      MIT
// ==/UserScript==

// Egg Hunt Navigator Pro
//
// Features:
// - Automatically detects eggs on the page, alerts you, and moves them to the top of the screen for easier interaction.
// - Click the egg icon to toggle the Navigator between minimized (1 line) and expanded (4 lines).
// - Drag and drop the Navigator by holding and moving the title bar ("Egg Finder").
// - Navigate through predefined links using the "Next Page" button or right arrow button.
// - Directly jump to a specific page by entering an index number in the "Nav Jump" input box.
// - The Navigator remembers its position and visibility state across sessions.
//
// Usage:
// - Egg Detection: Automatically finds and positions eggs for quick collection.
// - Minimize/Maximize: Click the egg icon to save space or reveal full functionality.
// - Move: Drag the title bar to reposition the Navigator; changes are saved automatically.
// - Navigate: Click "Next Page" or the right arrow button to visit the next link in the sequence.
// - Jump: Enter a valid page index in "Nav Jump" to navigate directly to that page.

'use strict';

let linkIndex = parseInt(localStorage.getItem("eeh-index")) || 0; // Current page index
const EVERY_LINK = [
  // Personal Pages
  "",
  "/index.php",
  "/personalstats.php?ID=1",
  "/preferences.php",
  "/page.php?sid=gallery&XID=1",
  "/page.php?sid=log",
  "/page.php?sid=ammo",
  "/playerreport.php",
  "/page.php?sid=UserList",
  "/page.php?sid=keepsakes",
  "/authenticate.php",
  "/page.php?sid=list&type=friends",
  "/page.php?sid=list&type=enemies",
  "/page.php?sid=list&type=targets",
  "/page.php?sid=events",
  "/page.php?sid=events#onlySaved=true",
  "/events.php#/step=all",
  "/messageinc.php",
  "/messageinc2.php#!p=main",
  "/messageinc2.php#!p=viewall",
  "/messages.php",
  "/messages.php#/p=inbox",
  "/messages.php#/p=compose",
  "/messages.php#/p=outbox",
  "/messages.php#/p=saved",
  "/messages.php#/p=ignorelist",
  "/awards.php",
  "/points.php",
  "/fans.php",
  "/bounties.php",
  "/usersonline.php",
  "/bringafriend.php",
  "/page.php?sid=bunker",
  "/index.php?page=rehab",
  "/index.php?page=people",

  // Item Pages
  "/item.php",
  "/amarket.php",
  "/bigalgunshop.php",
  "/shops.php?step=bitsnbobs",
  "/shops.php?step=cyberforce",
  "/shops.php?step=docks",
  "/shops.php?step=jewelry",
  "/shops.php?step=nikeh",
  "/shops.php?step=pawnshop",
  "/shops.php?step=pharmacy",
  "/pmarket.php",
  "/shops.php?step=postoffice",
  "/shops.php?step=super",
  "/shops.php?step=candy",
  "/shops.php?step=clothes",
  "/shops.php?step=recyclingcenter",
  "/shops.php?step=printstore",
  "/imarket.php",
  "/bazaar.php?userId=1",
  "/bazaar.php#/",
  "/bazaar.php#/add",
  "/bazaar.php#/personalize",
  "/displaycase.php",
  "/displaycase.php#display/",
  "/pc.php",
  "/trade.php",
  "/loader.php?sid=itemsMods",
  "/page.php?sid=ItemMarket",

  // Side Bar Pages
  "/city.php",
  "/jobs.php",
  "/companies.php",
  "/gym.php",
  "/properties.php",
  "/page.php?sid=education",
  "/education.php#/step=main",
  "/crimes.php",
  "/crimes.php#/step=main",
  "/page.php?sid=crimes2", // Moved here
  "/loader.php?sid=crimes#/searchforcash",
  "/loader.php?sid=crimes#/bootlegging",
  "/loader.php?sid=crimes#/graffiti",
  "/loader.php?sid=crimes#/shoplifting",
  "/loader.php?sid=crimes#/pickpocketing",
  "/loader.php?sid=crimes#/cardskimming",
  "/loader.php?sid=crimes#/burglary",
  "/loader.php?sid=crimes#/hustling",
  "/loader.php?sid=crimes#/disposal",
  "/loader.php?sid=crimes#/cracking",
  "/loader.php?sid=crimes#/forgery",
  "/loader.php?sid=crimes#/scamming",
  "/loader.php?sid=missions",
  "/newspaper.php#/",
  "/joblist.php#!p=main",
  "/freebies.php#!p=main",
  "/newspaper_class.php",
  "/personals.php#!p=main",
  "/bounties.php#!p=main",
  "/comics.php#!p=main",
  "/newspaper.php#/archive",
  "/messageinc2.php#!p=viewall",
  "/newspaper.php#/tell_your_story",
  "/archives.php#/TheBirthOfTorn",
  "/jailview.php",
  "/halloffame.php",
  "/hospitalview.php",
  "/page.php?sid=UserList",
  "/calendar.php",
  "/bringafriend.php",
  "/page.php?sid=hof",
  "/page.php?sid=travel",

  // City
  "/bank.php",
  "/donator.php",
  "/dump.php",
  "/loan.php",
  "/estateagents.php",
  "/forums.php",
  "/properties.php?step=rentalmarket",
  "/properties.php?step=sellingmarket",
  "/page.php?sid=ItemMarket#/market/view=category&categoryName=Most%20Popular",
  "/museum.php",
  "/church.php",
  "/church.php?step=proposals",
  "/citystats.php",
  "/committee.php",
  "/page.php?sid=stocks",
  "/archives.php#/",
  "/committee.php#/step=main",
  "/loader.php?sid=racing",
  "/chronicles.php",

  // Casino
  "/casino.php",
  "/page.php?sid=slots",
  "/page.php?sid=slotsLastRolls",
  "/page.php?sid=slotsStats",
  "/page.php?sid=roulette",
  "/page.php?sid=rouletteLastSpins",
  "/page.php?sid=rouletteStatistics",
  "/page.php?sid=highlow",
  "/page.php?sid=highlowLastGames",
  "/page.php?sid=highlowStats",
  "/page.php?sid=keno",
  "/page.php?sid=kenoLastGames",
  "/page.php?sid=kenoStatistics",
  "/page.php?sid=craps",
  "/page.php?sid=crapsLastRolls",
  "/page.php?sid=crapsStats",
  "/page.php?sid=bookie",
  "/page.php?sid=bookie#/your-bets",
  "/page.php?sid=bookie#/stats/",
  "/page.php?sid=lottery",
  "/page.php?sid=lotteryTicketsBought",
  "/page.php?sid=lotteryPreviousWinners",
  "/page.php?sid=blackjack",
  "/page.php?sid=blackjackLastGames",
  "/page.php?sid=blackjackStatistics",
  "/page.php?sid=holdem",
  "/page.php?sid=holdemStats",
  "/page.php?sid=russianRoulette",
  "/loader.php?sid=viewRussianRouletteLastGames",
  "/loader.php?sid=viewRussianRouletteStats",
  "/page.php?sid=spinTheWheel",
  "/page.php?sid=spinTheWheelLastSpins",
  "/loader.php?sid=viewSlotsStats",
  "/loader.php?sid=viewHighLowLastGames",
  "/loader.php?sid=viewCrapsStats",
  "/loader.php?sid=viewLotteryUserStats",
  "/loader.php?sid=viewLotteryStats",
  "/loader.php?sid=viewBlackjackLastGames",

  // NPCS:
  "/profiles.php?XID=1", // Moved to the top
  "/profiles.php?XID=4",
  "/bazaar.php?userId=4",
  "/displaycase.php#display/4",
  "/profiles.php?XID=15",
  "/bazaar.php?userId=15",
  "/displaycase.php#display/15",
  "/profiles.php?XID=19",
  "/bazaar.php?userId=19",
  "/profiles.php?XID=20",
  "/bazaar.php?userId=20",
  "/profiles.php?XID=21",
  "/bazaar.php?userId=21",
  "/profiles.php?XID=10",
  "/bazaar.php?userId=10",
  "/displaycase.php#display/10",
  "/profiles.php?XID=17",
  "/profiles.php?XID=23",
  "/bazaar.php?userId=23",
  "/profiles.php?XID=50",
  "/bazaar.php?userId=50",
  "/profiles.php?XID=7",
  "/bazaar.php?userId=7",
  "/displaycase.php#display/7",
  "/profiles.php?XID=104",
  "/profiles.php?XID=102",
  "/profiles.php?XID=103",
  "/profiles.php?XID=100",
  "/profiles.php?XID=101",
  "/profiles.php?XID=3",

  // Old Mission NPCs
  "/profiles.php?XID=9",
  "/profiles.php?XID=8",

  // Faction Specific
  "/factions.php",
  "/factions.php?step=your",
  "/factions.php?step=your#/tab=info",
  "/factions.php?step=your#/tab=territory",
  "/factions.php?step=your#/tab=rank",
  "/factions.php?step=your#/tab=oc",
  "/factions.php?step=your#/tab=upgrades",
  "/factions.php?step=your#/tab=armoury",
  "/factions.php?step=your#/tab=controls",
  "/page.php?sid=factionWarfare",
  "/page.php?sid=factionWarfare#/ranked",
  "/page.php?sid=factionWarfare#/territory",
  "/page.php?sid=factionWarfare#/raids",
  "/page.php?sid=factionWarfare#/chains",
  "/page.php?sid=factionWarfare#/dirty-bombs",
  "/war.php?step=chainreport&chainID=36587144", // Moved here
  "/war.php?step=warreport&warID=41189", // Moved here
  "/war.php?step=rankreport&rankID=12096", // Moved here

  // Other
  "/joblisting.php",
  "/credits.php",
  "/rules.php",
  "/loader.php?sid=attack&user2ID=1",
  "/forums.php#/p=threads&f=67&t=16326854&b=0&a=0",
  "/old_forums.php",
  "/itemuseparcel.php",
  "/index.php?page=fortune",
  "/personalstats.php?ID=1",
  "/properties.php?step=rentalmarket",
  "/properties.php?step=sellingmarket",
  "/joblist.php#/p=corpinfo&userID=1699485",
  "/newspaper.php#/tell_your_story",
  "/archives.php#/TheBirthOfTorn",
  "/page.php?sid=ItemMarket#/market/view=category&categoryName=Most%20Popular",
  "/properties.php#/p=yourProperties",
  "/properties.php#/p=spousesProperties",
  "/archives.php#/",
  "/archives.php#/Factions",
  "/archives.php#/Employment",
  "/archives.php#/TheMarkets",
  "/archives.php#/RealEstate",
  "/dump.php#/trash",
  "/userimages.php?XID=1",
  "/forums.php#/p=forums&f=1",
  "/forums.php#/p=forums&f=2",
  "/blacklist.php#p=add",
  "/friendlist.php#p=add",
  "/authenticate.php",
  "/staff.php",
  "/profiles.php?XID=1",
  "/joblist.php?step=search#!p=corpinfo&ID=79286",
  "/bazaar.php?userId=1#/",
  "/displaycase.php#display/1",
  "/loader.php?sid=attack&user2ID=17",
  "/forums.php#/p=forums&f=62&b=0&a=0",
  "/displaycase.php#display/50",
  "/loader.php?sid=attackLog&ID=62ffe20613b5b8cc8821c38989873f4b",
  "/christmas_town.php#/",
  "/christmas_town.php#/mymaps",
  "/christmas_town.php#/mapeditor",
  "/christmas_town.php#/parametereditor",
  "/christmas_town.php#/npceditor"
];
let pressTimer;

const easteregg_svg = `
<svg xmlns="http://www.w3.org/2000/svg" fill="url(#egg-gradient)" stroke="transparent" stroke-width="0" width="15" height="20" viewBox="0 0 15 20">
    <defs>
        <linearGradient id="egg-gradient" gradientTransform="rotate(90)">
            <stop offset="0%" stop-color="#FFD700" /> <!-- Gold -->
            <stop offset="100%" stop-color="#FF4500" /> <!-- Orange -->
        </linearGradient>
        <filter id="egg-shadow" x="0" y="0" width="200%" height="200%">
            <feDropShadow dx="0" dy="2" stdDeviation="3" flood-color="rgba(0, 0, 0, 0.25)" />
        </filter>
    </defs>
    <path style="filter: url(#egg-shadow);" d="M1.68,16a5.6,5.6,0,0,0,.43.41A5.72,5.72,0,0,0,3,17a4.73,4.73,0,0,0,.74.39,5.08,5.08,0,0,0,.8.3,5.35,5.35,0,0,0,.69.17,8.62,8.62,0,0,0,.87.11h.84a8.46,8.46,0,0,0,.88-.11l.69-.17a7.14,7.14,0,0,0,.81-.31q.38-.18.72-.39a6.57,6.57,0,0,0,.9-.67,5.14,5.14,0,0,0,.41-.4A6.3,6.3,0,0,0,13,11.67a8.86,8.86,0,0,0-.09-1.21c0-.31-.1-.64-.17-1s-.2-.85-.33-1.29-.3-.93-.48-1.39-.33-.81-.51-1.2c-.1-.2-.19-.39-.29-.58L11,4.72c-.18-.33-.4-.69-.64-1s-.4-.55-.62-.82A4.41,4.41,0,0,0,6.5,1,4.41,4.41,0,0,0,3.29,2.86a9.15,9.15,0,0,0-.61.82c-.24.34-.44.68-.62,1L1.87,5l-.33.66c-.16.36-.32.72-.46,1.09S.74,7.7.61,8.16a13.14,13.14,0,0,0-.34,1.3,10,10,0,0,0-.18,1A8.47,8.47,0,0,0,0,11.67a6.29,6.29,0,0,0,.89,3.25A6.63,6.63,0,0,0,1.68,16Z">
    </path>
</svg>`;


if (document.readyState === "interactive" || document.readyState === "complete") {
    console.log("Page already interactive or fully loaded, initializing...");
    setupEggDetection();
    createEggNavigatorButton();
    ensureNavigatorInBounds();
} else {
    document.addEventListener("DOMContentLoaded", function () {
        console.log("DOM fully loaded, initializing navigator and egg detection...");
        setupEggDetection();
        createEggNavigatorButton();
        ensureNavigatorInBounds();
    });
};

function createEggNavigatorButton() {
    let buttonWrapper = document.getElementById("eggNavigatorButton");
    if (buttonWrapper) return;

    buttonWrapper = document.createElement("div");
    buttonWrapper.id = "eggNavigatorButton";
    buttonWrapper.style.position = "fixed";

    const defaultTop = "10px";
    const defaultLeft = "90%";
    const storedTop = localStorage.getItem("buttonTop");
    const storedLeft = localStorage.getItem("buttonLeft");

    buttonWrapper.style.top = storedTop || defaultTop;
    buttonWrapper.style.left = storedLeft || defaultLeft;

    buttonWrapper.style.width = "150px";
    buttonWrapper.style.zIndex = "299999";
    buttonWrapper.style.padding = "10px";
    buttonWrapper.style.cursor = "move";
    buttonWrapper.style.display = "flex";
    buttonWrapper.style.flexDirection = "column";
    buttonWrapper.style.alignItems = "center";
    buttonWrapper.style.gap = "10px";
    buttonWrapper.style.backgroundColor = "var(--default-bg-panel-color)";
    buttonWrapper.style.border = "1px solid var(--default-panel-divider-outer-side-color)";
    buttonWrapper.style.borderRadius = "5px";
    buttonWrapper.style.boxShadow = "0 2px 12px rgba(0, 0, 0, 0.15)";

    document.body.appendChild(buttonWrapper);

    makeButtonDraggable(buttonWrapper);

    const titleWrapper = document.createElement("div");
    titleWrapper.style.display = "flex";
    titleWrapper.style.flexDirection = "row";
    titleWrapper.style.alignItems = "center";
    titleWrapper.style.justifyContent = "center";
    titleWrapper.style.width = "100%";
    titleWrapper.style.whiteSpace = "nowrap";
    titleWrapper.style.gap = "4px";
    titleWrapper.style.position = "relative";

    const rightArrowButton = document.createElement("button");
    rightArrowButton.innerHTML = "&#9654;";
    rightArrowButton.style.width = "30px";
    rightArrowButton.style.height = "20px";
    rightArrowButton.style.position = "absolute";
    rightArrowButton.style.top = "50%";
    rightArrowButton.style.transform = "translateY(-50%)";
    rightArrowButton.style.right = "0";
    rightArrowButton.style.padding = "0";
    rightArrowButton.style.background = "linear-gradient(00deg, #444444 0%, #222222 60%, #111111 100%)";
    rightArrowButton.style.border = "none";
    rightArrowButton.style.borderRadius = "5px";
    rightArrowButton.style.color = "#DDDDDD";
    rightArrowButton.style.cursor = "pointer";
    rightArrowButton.style.boxShadow = "0 2px 12px rgba(0, 0, 0, 0.15)";

    rightArrowButton.addEventListener("mouseover", () => {
        rightArrowButton.style.background = "linear-gradient(180deg, #333333 0%, #111111 60%, #000000 100%)";
        rightArrowButton.style.color = "#CCCCCC";
    });

    rightArrowButton.addEventListener("mouseout", () => {
        rightArrowButton.style.background = "linear-gradient(00deg, #444444 0%, #222222 60%, #111111 100%)";
        rightArrowButton.style.color = "#DDDDDD";
    });

    titleWrapper.appendChild(rightArrowButton);

    const eggImage = document.createElement("div");
    eggImage.innerHTML = easteregg_svg;
    eggImage.style.flexShrink = "0";
    eggImage.style.width = "20px";
    eggImage.style.height = "20px";
    eggImage.style.cursor = "pointer";

    const title = document.createElement("span");
    title.textContent = "Egg Finder";
    title.style.fontWeight = "bold";
    title.style.fontSize = "12px";
    title.style.overflow = "hidden";
    title.style.textOverflow = "ellipsis";
    title.style.whiteSpace = "nowrap";
    title.style.marginLeft = "5px";
    title.style.marginRight = "25px";

    titleWrapper.appendChild(eggImage);
    titleWrapper.appendChild(title);
    buttonWrapper.appendChild(titleWrapper);

    const contentWrapper = document.createElement("div");
    contentWrapper.style.display = localStorage.getItem("navigatorContentState") === "hidden" ? "none" : "flex";
    contentWrapper.style.flexDirection = "column";
    contentWrapper.style.width = "100%";
    contentWrapper.style.gap = "10px";

    rightArrowButton.style.display = localStorage.getItem("navigatorContentState") === "hidden" ? "block" : "none";

    const nextPageButton = document.createElement("button");
    nextPageButton.textContent = "Next Page";
    nextPageButton.style.padding = "5px 10px";
    nextPageButton.style.borderRadius = "3px";
    nextPageButton.style.border = "1px solid var(--default-panel-divider-outer-side-color)";
    nextPageButton.style.backgroundColor = "var(--info-msg-bg-gradient)";
    nextPageButton.style.cursor = "pointer";
    nextPageButton.style.width = "auto";
nextPageButton.style.color = "#FFFFFF";
nextPageButton.addEventListener("click", navigateToNextPage);

contentWrapper.appendChild(nextPageButton);

rightArrowButton.addEventListener("click", navigateToNextPage);


    const navLabelWrapper = document.createElement("div");
    navLabelWrapper.style.width = "100%";
    navLabelWrapper.style.textAlign = "left";
    const navLabel = document.createElement("span");
    navLabel.textContent = "Nav Jump:";
    navLabelWrapper.appendChild(navLabel);
    contentWrapper.appendChild(navLabelWrapper);

    const navJumpWrapper = document.createElement("div");
    navJumpWrapper.style.whiteSpace = "nowrap";
    navJumpWrapper.style.display = "flex";
    navJumpWrapper.style.flexDirection = "row";
    navJumpWrapper.style.alignItems = "center";
    navJumpWrapper.style.justifyContent = "center";
    navJumpWrapper.style.gap = "6px";
    navJumpWrapper.style.width = "100%";

    const navJumpInput = document.createElement("input");
    navJumpInput.type = "number";
    navJumpInput.min = "0";
    navJumpInput.max = EVERY_LINK.length - 1;
    navJumpInput.value = linkIndex;
    navJumpInput.style.width = "50px";
    navJumpInput.style.textAlign = "center";
    navJumpInput.style.flexShrink = "0";

    navJumpInput.addEventListener("change", () => {
        const newIndex = parseInt(navJumpInput.value, 10);
        if (!isNaN(newIndex) && newIndex >= 0 && newIndex < EVERY_LINK.length) {
            linkIndex = newIndex;
            localStorage.setItem("eeh-index", linkIndex);
        } else {
            navJumpInput.value = linkIndex;
        }
    });

    const pageCount = document.createElement("span");
    pageCount.textContent = ` / ${EVERY_LINK.length}`;
    pageCount.style.flexShrink = "0";
    navJumpWrapper.appendChild(navJumpInput);
    navJumpWrapper.appendChild(pageCount);

    contentWrapper.appendChild(navJumpWrapper);

    buttonWrapper.appendChild(contentWrapper);

    eggImage.addEventListener("click", function () {
        if (contentWrapper.style.display === "none") {
            contentWrapper.style.display = "flex";
            rightArrowButton.style.display = "none";
            localStorage.setItem("navigatorContentState", "visible");
        } else {
            contentWrapper.style.display = "none";
            rightArrowButton.style.display = "block";
            localStorage.setItem("navigatorContentState", "hidden");
        }
    });

    console.log("[Egg Finder] Button created with toggle functionality.");

    window.addEventListener("resize", () => {
        const rect = buttonWrapper.getBoundingClientRect();
        const viewportWidth = window.innerWidth;
        const viewportHeight = window.innerHeight;

        if (rect.right > viewportWidth) {
            buttonWrapper.style.left = `${viewportWidth - buttonWrapper.offsetWidth}px`;
        }
        if (rect.bottom > viewportHeight) {
            buttonWrapper.style.top = `${viewportHeight - buttonWrapper.offsetHeight}px`;
        }
    });
}

function navigateToNextPage() {
    linkIndex++;
    if (linkIndex >= EVERY_LINK.length) linkIndex = 0;
    localStorage.setItem("eeh-index", linkIndex);
    window.location.href = EVERY_LINK[linkIndex];
}


function ensureNavigatorInBounds() {
    const buttonWrapper = document.getElementById("eggNavigatorButton");

    if (buttonWrapper) {
        const viewportWidth = window.innerWidth;
        const viewportHeight = window.innerHeight;

        const rect = buttonWrapper.getBoundingClientRect();
        let adjusted = false;

        if (rect.right > viewportWidth) {
            buttonWrapper.style.left = `${viewportWidth - buttonWrapper.offsetWidth}px`;
            adjusted = true;
        }
        if (rect.bottom > viewportHeight) {
            buttonWrapper.style.top = `${viewportHeight - buttonWrapper.offsetHeight}px`;
            adjusted = true;
        }
        if (rect.left < 0) {
            buttonWrapper.style.left = "0px";
            adjusted = true;
        }
        if (rect.top < 0) {
            buttonWrapper.style.top = "0px";
            adjusted = true;
        }

        if (adjusted) {
            console.log("Navigator position adjusted to stay in bounds.");
        }
    }
}

function makeButtonDraggable(button) {
    let offsetX = 0;
    let offsetY = 0;
    let isDragging = false;

    function preventDefaultTouch(e) {
        e.preventDefault();
    }

    button.addEventListener("mousedown", function (e) {
        isDragging = true;
        offsetX = e.clientX - button.getBoundingClientRect().left;
        offsetY = e.clientY - button.getBoundingClientRect().top;
    });

    document.addEventListener("mousemove", function (e) {
        if (isDragging) {
            const newLeft = Math.max(0, Math.min(window.innerWidth - button.offsetWidth, e.clientX - offsetX));
            const newTop = Math.max(0, Math.min(window.innerHeight - button.offsetHeight, e.clientY - offsetY));

            button.style.left = `${newLeft}px`;
            button.style.top = `${newTop}px`;
        }
    });

    document.addEventListener("mouseup", function () {
        if (isDragging) {
            isDragging = false;
            localStorage.setItem("buttonLeft", button.style.left);
            localStorage.setItem("buttonTop", button.style.top);
        }
    });

    button.addEventListener("touchstart", function (e) {
        isDragging = true;
        const touch = e.touches[0];
        offsetX = touch.clientX - button.getBoundingClientRect().left;
        offsetY = touch.clientY - button.getBoundingClientRect().top;
        document.addEventListener("touchmove", preventDefaultTouch, { passive: false }); // Prevent scrolling
    });

    document.addEventListener("touchmove", function (e) {
        if (isDragging) {
            const touch = e.touches[0];
            const newLeft = Math.max(0, Math.min(window.innerWidth - button.offsetWidth, touch.clientX - offsetX));
            const newTop = Math.max(0, Math.min(window.innerHeight - button.offsetHeight, touch.clientY - offsetY));

            button.style.left = `${newLeft}px`;
            button.style.top = `${newTop}px`;
        }
    });

    document.addEventListener("touchend", function () {
        if (isDragging) {
            isDragging = false;
            localStorage.setItem("buttonLeft", button.style.left);
            localStorage.setItem("buttonTop", button.style.top);
            document.removeEventListener("touchmove", preventDefaultTouch);
        }
    });
}

function setupEggDetection() {
    const egg = document.getElementById('easter-egg-hunt-root');
    if (egg) {
        if (egg.classList.contains('egg-finder-found')) {
            return;
        }
        egg.classList.add('egg-finder-found');
        alert('Egg found!');
        moveEgg(egg);
    }
}

function moveEgg(egg) {
    const buttons = egg.querySelectorAll('button');
    if (buttons.length === 0) {
        setTimeout(() => moveEgg(egg), 50);
        return;
    }

    buttons.forEach(b => {
        b.style.top = '40%';
        b.style.left = '40%';
        b.style.height = '20%';
        b.style.width = '20%';
        b.style.position = 'fixed';

        const children = b.children;

        if (children.length > 0) {
            children[0].style.height = '100%';
        }

        const particles = children[children.length - 1];
        if (particles) {
            particles.style.left = '0';
            particles.style.width = '100%';
            particles.style.height = '100%';
        }
    });
}

GM.addStyle(`
    #eggNavigatorButton {
        background: linear-gradient(00deg, #555555 0%, #333333 60%, #222222 100%);
        border-radius: 5px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
        padding: 10px;
    }

    #eggNavigatorButton button {
        border: none;
        border-radius: 5px;
        padding: 5px 10px;
        cursor: pointer;
        font-weight: bold;
        background-color: #666666 !important;
        color: #FFFFFF;
    }

    #eggNavigatorButton button:hover {
    background: linear-gradient(180deg, #444444 0%, #222222 60%, #111111 100%);
    color: #DDDDDD;
}

    #eggNavigatorButton input {
        text-align: center;
        width: 50px;
    }

    #eggNavigatorButton span {
        font-weight: bold;
    }

    #eggNavigatorButton div {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    #easter-egg-hunt-root {
        position: fixed;
        top: 40%;
        left: 40%;
        width: 20%;
        height: 20%;
        z-index: 10000;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    }

@media (max-width: 768px) {
  #eggNavigatorButton button {
    all: unset; /* Resets most browser-specific styles */
    background-color: #444444;
    color: #FFFFFF;
    padding: 5px 10px;
    border: 1px solid var(--default-panel-divider-outer-side-color);
    border-radius: 3px;
    cursor: pointer;
  }

  #eggNavigatorButton button:hover {
    background: #333333;
    color: #FFFFFF;
  }
}
`);