Greasy Fork is available in English.

Heasley's Egg Navigator

Traverse every page in Torn in search for eggs

// ==UserScript==
// @name         Heasley's Egg Navigator
// @namespace    egg.traverse
// @version      1.2.1
// @description  Traverse every page in Torn in search for eggs
// @author       Heasleys4hemp [1468764]
// @match        https://www.torn.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @grant        GM.addStyle
// @run-at       document-start
// @license      MIT
// @require      https://www.torn.com/js/script/lib/jquery-1.8.2.js
// ==/UserScript==
'use strict';
var linkIndex = localStorage.getItem('eeh-index') || 0;
var pressTimer;

if (typeof GM == 'undefined') {
  window.GM = {};
}

if (typeof GM.addStyle == "undefined") {
    GM.addStyle = function (aCss) {
      'use strict';
      let head = document.getElementsByTagName('head')[0];
      if (head) {
        let style = document.createElement('style');
        style.setAttribute('type', 'text/css');
        style.textContent = aCss;
        head.appendChild(style);
        return style;
      }
      return null;
    };
}

GM.addStyle(`
// Styles omitted for brevity. Please ensure you include the entire CSS from your original script here.
`);

const easteregg_svg = `// SVG data omitted for brevity. Ensure to include the complete SVG markup from your original script.`;

// Note: Removed "page.php?sid=crimes2" from the array. Make sure all other entries are included correctly.
const EVERY_LINK = [
    "", "index.php", "city.php", "jobs.php", "gym.php", "properties.php",
    "education.php", "crimes.php", "loader.php?sid=missions", "newspaper.php",
    // Add all other pages from your original list here, excluding "page.php?sid=crimes2".
];

const eeeh_observer = new MutationObserver(function(mutations) {
    if (document.getElementById("eggTraverse")) {
        return;
    }

    // Desktop view
    if (document.querySelector('#sidebar > div:first-of-type')) {
        insertNormal(); // Insert normal sidebar version
        return;
    }
});

eeeh_observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});

function insertNormal() {
  console.log("[Heasley][Egg Navigator] Inserting normally...");
    if (!document.getElementById("eggTraverse")) {
        let href = EVERY_LINK[linkIndex];

        let easterspans = `
            <div class="eeh-link"><a href="${href}" id="eggTraverse"><span class="eeh-icon">${easteregg_svg}</span><span class="eeh-name">Egg Navigator (${linkIndex})</span></a></div>
            `;

        const sidebar = document.getElementById('sidebar');
        if (sidebar.firstChild) {
            $('#sidebar > *').first().after(easterspans);
            $('#eggTraverse').on('mouseup touchend', function(e){
                clearTimeout(pressTimer);
            }).on('mousedown touchstart', function(e) {
                pressTimer = window.setTimeout(function() {
                    linkIndex = 0;
                    localStorage.setItem("eeh-index", linkIndex);
                    $('#eggTraverse').attr('href', EVERY_LINK[0]);
                    $('#eggTraverse .eeh-name').text('Egg Navigator (0)');
                },2500);
                return false; // To prevent default behaviour
            }).contextmenu(function(e) {
                e.preventDefault();
                e.stopPropagation();
                e.stopImmediatePropagation();
                return false;
            }).on('click', function(e) {
                linkIndex++;
                if (linkIndex >= EVERY_LINK.length) linkIndex = 0;
                localStorage.setItem("eeh-index", linkIndex);
                $('#eggTraverse').attr('href', EVERY_LINK[linkIndex]);
                $('#eggTraverse .eeh-name').text(`Egg Navigator (${linkIndex})`);
                return false; // To prevent default link behaviour
            });
        }
    }
}