Skip to content
/ hare Public

Run nationstates scripts using a web interface

License

Notifications You must be signed in to change notification settings

Kractero/hare

Repository files navigation

Hare

Run NationStates cards scripts (and others) through your web browser.

Svelte TailwindCSS

Hare serves as a central repository for running various NationStates scripts directly in your browser. It's the latest step in my ongoing quest to make these scripts easier to use. In the past, these scripts often required downloading external dependencies like Python, along with some know-how on installing those dependencies and then using the command line to execute them. Hare aims to solve this by moving all of this to just using your browser.

If you'd like to suggest a script for inclusion, feel free to join the Discord and ask, or open an issue on the repository.

Let's be honest—Hare isn't a backronym. It doesn't stand for Humble Automated Runner for Executing NationStates Scripts or whatever mumbo jumbo I had previously. The project is named after Omagari Hare from Blue Archive.

If this tool has helped you, consider starring the repo or gifting me a leg (just kidding unless...).

Features

Hare offers a suite of tools designed to make managing NationStates puppets more efficient and user-friendly:

  1. gotIssues Streamline card farming by clearing issues and opening packs across your puppets.

  2. junkDaJunk Generate customizable links to quickly junk cards based on criteria like owner count, region, and card quantity.

  3. Finder Input card IDs to locate which of your puppets hold specific cards.

  4. Gold Retriever Get detailed stats on your puppets, including card count, bank, deck value, and junk value.

  5. Login Sheet Quickly log into new or orphaned containers using an auto-generated login sheet.

  6. Pinger Keep your nations active by "pinging" them, simulating a login.

Prerequisites

You'd be better off reading here but below is a brief look.

Mozilla Firefox

Only Firefox supports containers.

If you already use Firefox as your main browser, I suggest setting up a separate profile or using a different Firefox derivative (e.g., ESR, Nightly, Floorp, Waterfox) to avoid any mix-ups with your main nation.

Containers

Containers are a Firefox-only feature that allows you to create multiple mini profiles or sessions within one profile, each maintaining its own cookies and state. This means you can have one container for each nation, making it easy to manage many puppets.

I recommend using my Cardtainers addon, which automatically creates rules matching nations based on a puppet list. Alternatively, you can also use the Containerise addon to manually generate the necessary rules within the website.

A Userscript Manager

A userscript allows you to extend a website's functionality beyond what is available with the website's current scripts. All modern browsers support userscript managers. For ease of use, I suggest using TamperMonkey. However, if you prefer open-source software, ViolentMonkey is a good alternative.

Many scripts generate an HTML sheet that almost necessitates the use of an autocloser userscript. There are several varieties, some tailored for a specific tool, but for a general one for most card stuff I'd recommend the following:

// ==UserScript==
// @name autoclose=1
// @version 0.1
// @match *://*/*autoclose=1
// @match https://*.nationstates.net/*page=enact_dilemma*
// @exclude https://*.nationstates.net/*page=show_dilemma*
// @icon https://www.google.com/s2/favicons?sz=64&domain=nationstates.net//
// @grant window.close
// ==/UserScript==

// @match on autoclose=1 not necessary for gotissues but is for junkdajunk and others
// @match on enact_dilemma as autoclose does not carry over to the issue answered screen
// @exclude on show_dilemma since autoclose should not close the new intermediary screen

;(function () {
	'use strict'
	if (document.querySelector('.deck-loot-box')) return
	window.close()
})()

A caveat with any autocloser is that it may interfere with normal gameplay. It's recommended to enable or disable it as needed, or alternatively, use a separate browser profile or browser to avoid disruptions.

Ratelimits

All of these scripts run using your rate limit.

As stated in the NationStates API documentation:

The API is rate-limited and will temporarily lock you out if you send too many requests within a short period of time. (And return status 429: "Too Many Requests From Your IP Address.")

API Rate Limit: 50 requests per 30 seconds.

Hare will attempt to balance the rate limit to prevent you from being locked out by adhering to NationStates' rate limits using various headers returned by NationStates. However, please refrain from intentionally trying to trigger a lockout.

Attributions

"Reverse-engineering" these scripts into JavaScript and integrating them into a website is much easier than creating them from scratch.

Credit for the original source implementations goes to:

  1. 9003 for the Python versions of:
  1. upc for the initial inspiration from the Endotart and NEN cogs.

  2. Spyglass for the Python version of Spyglass.

  3. ValentineZ's Gold Retriever and Racoda's gold retriever.

Icons used from Icons8.