Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

cass-dlcm/PeanutButteredSalmon

Repository files navigation

Peanut Buttered Salmon

Peanut Buttered Salmon is a program that downloads data from the SplatNet 2 app ("Nintendo Switch Online"), stat.ink, or salmon-stats to find personal bests in the Splatoon 2 Salmon Run game mode.

Depreciation Notice

This version is depreciated and is no longer under active development. Please see the v3 page and use that instead.

Usage

If running using a Go install

$ go run main.go [-stage ""] [-event ""] [-tide ""] [-weapon ""] [-save] [-load] [-splatnet] [-statink ""] [-salmonstats ""]

If running a binary

$ ./peanutButteredSalmon [-stage ""] [-event ""] [-tide ""] [-weapon ""] [-save] [-load] [-splatnet] [-statink ""] [-salmonstats ""]

The -stage flag takes in a string with the set of stages to include like such: "spawning_grounds marooners_bay lost_outpost salmonid_smokeyard ruins_of_ark_polaris"

The -event flag takes in a string with the set of events to include like such: "water_levels rush fog goldie_seeking griller cohock_charge mothership"

The -tide flag takes in a string with the set of tides to include like such: "LT NT HT"

The -weapon flag takes in a string with the set of weapon types to include like such: "set single_random four_random random_gold"

The -save flag saves the downloaded data to a folder called shifts, statink_shifts/{server}, or salmonstats/{server} in the current working directory.

The -load flag loads the data from a folder called shifts, statink_shifts/{server}, or salmonstats/{server} in the current working directory.

The -splatnet flag signals to download data from SplatNet 2.

The -statink flag signals to download data from a stat.ink instance. Use -statink "official" to use the https://stat.ink instance.

The -salmonstats flag downloads data from a salmon-stats instance. Use -salmonstats "official" to use the https://salmon-stats-api.yuki.games instance.

Example usage

Running go run main.go -save -splatnet -monitor 900 from the command line launches the program in monitoring mode, checking on Splatnet 2 for new results, saving them, and finding personal bests every 15 minute.

Running go run main.go --statink finds all personal bests from your data on stat.ink

Features

Finds personal bests for the following records

  • Total Golden Eggs
  • Total Golden Eggs <= 2 Nights
  • Total Golden Eggs <= 1 Nights
  • Total Golden Eggs No Night
  • All valid combinations of events and tides

Output features:

  • outputs as valid JSON
  • structured with record as top level, stage as middle level, and weapon schedule as bottom level of hierarchy
  • saving shift data to JSON files

Input features:

  • reading from SplatNet 2
  • reading from stat.ink
  • reading from local files
  • reading from salmon-stats.yuki.games

Setup instructions

These instructions are meant to be accessible and easy-to-follow for all users, and this is the recommended way to run the script. If you run into trouble, please reach out! However, an alternative simple version is also available.

  1. Download and install Go. On Windows, download the installer from the official website. On macOS, install Homebrew and then run brew install go.

  2. If you're on Windows, install Git (pre-installed on macOS).

  3. Download the program from the command line (macOS: Terminal; Windows: Command Prompt/PowerShell) by running git clone https://github.com/cass-dlcm/PeanutButteredSalmon.git.

  4. You will be prompted to enter your language code (locale).

  • Running the script for the first time with the -statink flag will prompt you to enter your stat.ink API key, which can be found in your profile settings.
  • Running the script for the first time with the -splatnet flag will start the cookie generation.

NOTE: Read the "Cookie generation" section below before proceeding.

You will then be asked to navigate to a specific URL on Nintendo.com, log in, and follow simple instructions to obtain your session_token; this will be used to generate an iksm_session cookie. If you are opting against automatic cookie generation, enter "skip" for this step, at which point you will be asked to manually input your iksm_session cookie instead (see the mitmproxy instructions).

This cookie (used to access your SplatNet battle results) along with your stat.ink API key and language will automatically be saved into config.txt for you. You're now ready to upload battles!

Have any questions, issues, or suggestions? Feel free to message me on Twitter or create an issue here.

Accessing SplatNet 2 from your browser

If you wish to access SplatNet 2 from your computer rather than via the phone app, navigate to https://app.splatoon2.nintendo.net/home (it should show a forbidden error). Use a cookie editor – such as EditThisCookie for Chrome – to change iksm_session to the value you obtained previously (automatically or via mitmproxy, stored as cookie in config.txt), and refresh the page. If you only want to access SplatNet and don't have a stat.ink API key, simply enter "skip" for this step during setup.

Splatoon 2 stage rotation information (including Salmon Run) and current SplatNet gear are viewable at splatoon2.ink.


Cookie generation

For Peanut Buttered Salmon to work with SplatNet, a cookie known as iksm_session is required. This cookie may be obtained automatically, using the program, or manually via the app. Please read the following sections carefully to decide whether or not you want to use automatic cookie generation.

Automatic

Automatic cookie generation involves making a secure request to two non-Nintendo servers with minimal, non-identifying information. We aim to be 100% transparent about this and provide in-depth information on security and privacy below. Users who feel uncomfortable with this may opt to manually acquire their cookie instead.

The v1.1.0 update to the Nintendo Switch Online app, released in September 2017, introduced the requirement of a message authentication code (known as f), thereby complicating the ability to generate cookies within the script. After figuring out the key previously used to generate f tokens, the calculation method was changed in September 2018's v1.4.1 update, heavily obfuscating the new process. As a workaround, an Android server was set up to emulate the app, specifically to generate f tokens.

Generation now requires a hash value to further verify the authenticity of the request. The algorithm to calculate this, originally done within the app, is sensitive; to prevent sharing it publicly (i.e. distributing it in the script's source code), github user frozenpandaman created a small API which generates a hash value given a valid input. This can be passed to the Android server to generate the corresponding f token, which is then used to retrieve an iksm_session cookie.

Privacy statement: No identifying information is ever sent to the API server. Usernames and passwords are far removed from where the API comes into play and are never readable by anyone but you. Returned hash values are never logged or stored and do not contain meaningful information. It is not possible to use either sent or stored data to identify which account/user performed a request, to view any identifying information about a user, or to gain access to an account.

See the API documentation wiki page for more information.

Manual

Users who decide against automatic cookie generation via their computer may instead generate/retrieve iksm_session cookies from the SplatNet app.

In this case, users must obtain their cookie from their phone by intercepting their device's web traffic and inputting it into Peanut Buttered Salmon when prompted (or manually adding it to config.txt). Follow the mitmproxy instructions to obtain and configure your cookie manually. To opt to manually acquire your cookie, enter "skip" when prompted to enter the "Select this account" URL.

License

AGPLv3 or any later version

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages