SS13 Idle Extensions

Utilities for SS13IDLE

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         SS13 Idle Extensions
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      2025-10-11
// @description  Utilities for SS13IDLE
// @author       DeCell
// @match        https://spacestationidle.com/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=spacestationidle.com
// @grant        none
// @require      https://code.jquery.com/jquery-3.7.1.min.js
// ==/UserScript==
'use strict';


const temporarySettings = {
    autoBossFight: false,
    bossFightInterval: null
}; // stuff that arent being saved between refreshes


const $autoBossFight = $('<button>', {
    text: 'Not Auto Fighting Bosses Now',
    class: 'btn btn-success',
});


$autoBossFight.on("click", () => {
    temporarySettings.autoBossFight = !temporarySettings.autoBossFight;
    const checked = temporarySettings.autoBossFight;

    $autoBossFight.toggleClass("btn-success btn-danger");

    if (checked) {
        $autoBossFight.text('Auto Fighting Bosses Now');
        temporarySettings.bossFightInterval = setInterval(() => {
            // get the element that haves the click trigger for the next boss fight and click it
            $('h6:contains("FIGHT ANOTHER BOSS")').first()
                .parent()
                .children().eq(1)
                .children().first()
                .trigger("click");
        }, 500);
    }
    else {
        $autoBossFight.text('Not Auto Fighting Bosses Now');
        if (temporarySettings.bossFightInterval) {
            clearInterval(temporarySettings.bossFightInterval);
            temporarySettings.bossFightInterval = null;
        }
    }
});

(function () {


    function updateVisibility() {
        const activeTab = getActiveTabString();
        if (activeTab === 'Combat') {
            $putElementToHeader($autoBossFight)
        }
    }

    updateVisibility();
    const observer = new MutationObserver(() => {
        updateVisibility();
    });

    const appContainer = document.body;
    observer.observe(appContainer, {
        childList: true,
        subtree: true,
        attributes: true,
        attributeFilter: ['style', 'class']
    });
})();


function getActiveTabString() {
    const $header = $('.content-header');
    if ($header.length) {
        const $span = $header.find('span');
        return $span.length ? $span.text().trim() : null;
    }
    return null;
}

function $getHeaderElement() {
    return $('.content-header');
}

function $putElementToHeader($element) {
    const $header = $getHeaderElement();
    if ($header && $header.length && !$element.parent().is($header)) {
        $header.append($element); // need to add it back when switching tabs cuz the whole page gets rebuilt between pages
    }
}