Skip to content

Instantly share code, notes, and snippets.

@moritz
Last active May 31, 2018 15:38
Show Gist options
  • Select an option

  • Save moritz/97aa186cd99daee2b63c82bc9a20bb5a to your computer and use it in GitHub Desktop.

Select an option

Save moritz/97aa186cd99daee2b63c82bc9a20bb5a to your computer and use it in GitHub Desktop.
Tau station navigation extension
// ==UserScript==
// @name taustation_extended_nav
// @namespace https://github.com/moritz/
// @description Navigationi extension for taustation.space
// @match https://alpha.taustation.space/*
// @version 1
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
function gs_taustation_enhance() {
$('#game_navigation_areas a[href="/travel/area/inn"]').parent('li').after('<li class="area "> <a style="padding-left: 2em" href="/travel/area/bar">Bar</a> / <a href="/area/hotel-rooms/enter-room">Room</a> / <a href="/travel/area/lounge">Lounge</a> </li>');
$('#game_navigation_areas a[href="/travel/area/market"]').parent('li').after('<li class="area "> <a style="padding-left: 2em" href="/travel/area/vendors">Vendors</a> / <a href="/travel/area/storage">Storage</a> / <a href="/travel/area/electronic-market">Public</a> </li>');
$('#game_navigation_areas a[href="/travel/area/port"]').parent('li').after('<li class="area "> <a style="padding-left: 2em" href="/travel/area/shipping-bay">Shipping</a> / <a href="/travel/area/docks">Docks</a> / <a href="/travel/area/local-shuttles">Shuttles</a> </li>');
// The following line removes the "bonds to credits" conversion option in the bank, if you remove the // at the start
// $('.bond-to-credits').hide();
// bribe for rations:
// $('a.btn-buy-rations').hide();
// CORETECHS learning enhancer (Hotel Room):
// $('form.coretechs-learning-enhancer').hide();
// Personal Trainer (Gym)
// $('.personal-trainer').hide();
// Buy a Round (Lounge)
// $('.buy-a-round').hide();
// Express shuttles (might have some undesired side effects, so use with caution):
// $('.shuttle-schedule-t').parent('div').hide()
}
//document.addEventListener('DOMContentLoaded', gs_taustation_enhance, false);
$(document).ready(gs_taustation_enhance);
@wbiker
Copy link

wbiker commented May 12, 2018

Hi, you might be interested in two more links. One to the Brig and one to the Security Tasks:

$('#game_navigation_areas a[href="/travel/area/brig"]').parent('li').after('<li class="area "> <a style="padding-left: 2em" href="/travel/area/brig#/jobs">Jobs</a> </li>');

$('#game_navigation_areas a[href="/travel/area/security"]').parent('li').after('<li class="area "> <a style="padding-left: 2em" href="/travel/area/security#/jobs">Jobs</a> </li>');

I am at the moment doing the Security carrier :-)

@duelafn
Copy link

duelafn commented May 27, 2018

Here's a function for storage compaction – merges adjacent rows of like objects (per station) and removes empty storage units.

Update: Don't remove header row

function taustation_bin_packing() {
    if (window.location.href.endsWith("/coretechs/storage")) {
        var table = document.querySelector('.content-section > table');

        var last_qtd;
        var last_row = ['',NaN];
        table.querySelectorAll("tr").forEach(
            function(tr, idx, rs) {
                var this_qtd;
                var this_row = ['',NaN];

                // Extract current row key and quantity
                tr.querySelectorAll("td").forEach(
                    function(td, i, r) {
                        if (i < 3) {
                            this_row[0] += ";;;" + td.textContent;
                        } else if (i == 3) {
                            this_qtd = td;
                            this_row[1] = parseInt(td.textContent, 10);
                        }
                    }
                );

                if (!isNaN(last_row[1]) && !isNaN(this_row[1])) {
                    // If star, station, and item all same, combine with previous row
                    if (this_row[0] === last_row[0]) {
                        last_row[1] += this_row[1];
                        last_qtd.textContent = last_row[1]
                        tr.style.display = 'none';
                        return; // Don't update last_*
                    }
                }

                // This else block optional: it hides all empty storage units
                else if (isNaN(this_row[1]) && idx > 0) {
                    tr.style.display = 'none';
                }

                last_qtd = this_qtd;
                last_row = this_row;
            }
        );
    }
}

@dot-sent
Copy link

dot-sent commented May 27, 2018

Just made myself another one, given the current state of affairs on YoG.

function taustation_presence() {
    var ppl = $('.tab-content-people h2');
    var info = '';
    if (ppl.length == 0) {
        info = ' (NOBODY ELSE HERE)';
    } else {
        info = ' (';
        for (var i=0; i<ppl.length; i++) {
            if (i>0) {
                info += ", ";
            }
            var header = ppl[i].innerHTML;
            var count = $(ppl[i]).next().children('tbody').children('tr').length;
            info += header + ':' + count;
        }
        info += ')';
    }
    $('h1')[0].innerHTML = $('h1')[0].innerHTML + info;
}

@dot-sent
Copy link

dot-sent commented May 28, 2018

Another ugly script, for compactifying info in the left column:

function taustation_compact_stats() {
    $('<div class="collapsed-info-1 player-info--row"><div class="player-info--col--1-of-2"></div><div class="player-info--col--2-of-2"></div></div>' +
     '<div class="collapsed-info-2 player-info--row"><div class="player-info--col--1-of-2"></div><div class="player-info--col--2-of-2"></div></div>' +
     '<div class="collapsed-info-3 player-info--row"><div class="player-info--col--1-of-1"></div></div>').insertAfter('.player-info--row--player');
		var current_row = $('.collapsed-info-3').next();
    for (var i=0; i<4; i++){
        current_row.hide();
        current_row = current_row.next();
    }
  	$('.bonds-text').hide();
    $('.player-info--icon').attr('height', 19).attr('width', 19);
    $('.level-container').detach().appendTo('.collapsed-info-1 .player-info--col--1-of-2').attr('style', 'border-left: none;');
    $('.credit-container').detach().appendTo('.collapsed-info-1 .player-info--col--2-of-2').attr('style', 'border-left: none;');
    $('.experience-container').detach().attr('style', 'padding-left: .563em; padding-right: .563em;').appendTo('.collapsed-info-2 .player-info--col--1-of-2');
    $('.bonds-container').detach().appendTo('.collapsed-info-2 .player-info--col--2-of-2').attr('style', 'border-left: none;');
    $('.toxins-container').detach().appendTo('.collapsed-info-3 .player-info--col--1-of-1').attr('style', 'border-left: none;');

    var stat_labels = { 'strength': 'STR', 'agility': 'AGI', 'stamina': 'STA', 'intelligence': 'INT', 'social': 'SOC' };
    var info_line = '<table class="collapsed-stats"><tbody><tr><td colspan="6">Unit(s) to next tick: <span id="units_to_next_tick">???</span></td></tr><tr>';
    var info_type = ' physical';
  	for (var stat in stat_labels){
        info_line += '<td>' + stat_labels[stat] + '</td><td class="collapsed-stat-value' + info_type + ' ' + stat + '">' + $('.' + stat + ' .pc')[0].innerHTML + '%</td>';
        if (stat == 'stamina'){ // Line break - ugly, I know
            info_line += '</tr><tr>';
            info_type = ' mental';
        }
    }
    info_line += '<td>F</td><td class="collapsed-stat-value focus">' + $('.focus .percentage')[0].innerHTML + '</td></tr></tbody></table>';
    var units_to_update = null;
    setInterval(function(){
        if (units_to_update != null) {
            units_to_update -= 1;
            if (units_to_update < 0){
                units_to_update = null;
                $('#units_to_next_tick')[0].innerHTML = "0 (stats full)";
            } else {
                $('#units_to_next_tick')[0].innerHTML = units_to_update;
            }
        }
        for (var stat in stat_labels){
            var cur_val = $('.' + stat + ' .pc')[0].innerHTML + '%';
            if (cur_val != $('.collapsed-stat-value.' + stat)[0].innerHTML){
                $('.collapsed-stat-value.' + stat)[0].innerHTML = cur_val;
                units_to_update = 347; // 5 minutes to units
            }
        }
        var focus_value = $('.focus .percentage')[0].innerHTML;
        if ($('.collapsed-stat-value.focus')[0].innerHTML != focus_value){
            $('.collapsed-stat-value.focus')[0].innerHTML = focus_value;
                units_to_update = 347; // 5 minutes to units
        }
    }, 864);
    $('<div class="player-info--row">' + info_line + '</div>').insertBefore($('.player-stats'));
    $('.player-stats').hide();
    $('.collapsed-stats').mouseenter(function(){
        $('.player-stats').show();
    }).mouseleave(function(){
        $('.player-stats').hide();
    });
    $('.employment-title').hide();
    var employment_link_titles = {
      '/mission': 'Mission | ',
      '/travel/area/discreet-work': 'Discreet | ',
      '/travel/area/side-jobs': 'Side jobs | ',
      '/career': 'Career'
    };
    var employment_links = $('#employment_panel a');
    for (var emp_link in employment_link_titles){
        $('#employment_panel a[href="' + emp_link + '"]')[0].innerHTML = employment_link_titles[emp_link];
    }
    $('<div class="employment-links" style="padding-left: .563em; padding-top: .563em; padding-bottom: .563em;"></div>').appendTo('#employment_panel');
    $('#employment_panel a').detach().appendTo('div.employment-links');
    $('#employment_panel ul.list-reset').hide();
}

@moritz
Copy link
Author

moritz commented May 31, 2018

@duelafn I've created a separate repository for user scripts; would you care to add your snippet as a script there? I think that scales better than comments on gist :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment