Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

salien-script-js

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

salien-script-js - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

2

package.json
{
"name": "salien-script-js",
"version": "0.0.13",
"version": "0.0.14",
"description": "A easy to install, run and update Node.js script for the Steam salien mini-game.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -18,17 +18,8 @@ # salien-script-js

* 🎉 [Easy to install, run and update](#️-how-to-use-this)
* ✉️ [Update checker and log notifications](#-how-to-update-the-script)
* 👽 Same logic as the [PHP version](https://github.com/SteamDatabase/SalienCheat) (we almost have parity)
* 👌 [Pick your own steam group](#-represent-your-steam-group-optional)
* 👥 [Works well with multiple tokens/scripts](#-multiple-tokensscripts)
* 👀 [Name your running scripts](#-multiple-tokensscripts)
* ☁️ [Heroku support](#advanced-️-deploying-to-heroku)
* 🐳 [Docker support](#advanced--running-as-a-docker-container)
* 📦 [npm package export](#advanced--usage-as-an-npm-package)

@@ -102,3 +93,3 @@

```js
const { SalienScript } = require('salien-script-js');
const SalienScript = require('salien-script-js');

@@ -130,122 +121,2 @@ const config = {

## Advanced: ☁️ Deploying to heroku
### Deploying with web-console
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
1. Click the button above.
2. Set SALIEN_CONFIG_V2 ([see note below](#heroku-configuration)).
3. That's all!
To check if it works, visit logs at https://dashboard.heroku.com/apps/[YOUR_APP_NAME]/logs
If you see "Application Error" when going to the webpage of your app, it's okay - the script will still run anyway.
### Deploying with Heroku CLI
```bash
$ git clone https://github.com/South-Paw/salien-script-js -o upstream
$ cd salien-script-js
$ heroku create [APP_NAME]
$ heroku config:set "SALIEN_CONFIG_V2=[APP_CONFIG]"
$ git push heroku master
$ heroku ps:scale web=0 salien=1
```
And to check if it works:
```bash
$ heroku logs --tail
```
### Heroku configuration
`SALIEN_CONFIG_V2` is just an array of config that will be passed to `SalienScript` constructor.
If you only have one account, then your config will look like this:
```JSON
[
{
"token": "12345"
}
]
```
The only mandatory key for each account is `token` and you can add extra keys to this config such as `clan`, `name` or `selectedPlanetId`:
```JSON
[
{
"token": "12345",
"clan": "67890",
"name": "first_acc",
"selectedPlanetId": "28"
}
]
```
If you had two accounts for example;
* one named `first_acc` with a token of `123` and a group of `98712`
* one named `second_acc` with a token of `456` and a group of `67890`
then you would make your config look like this:
```JSON
[
{
"token": "123",
"clan": "98712",
"name": "first_acc"
},
{
"token": "456",
"clan": "67890",
"name": "second_acc"
}
]
```
### Updating
#### Easy
The easiest way to update script on heroku is to just delete your old app and create new.
You can also link your Heroku app to your Dropbox account. To do that, [download this repository](https://github.com/South-Paw/salien-script-js/archive/master.zip) as a zip archive, and unpack it to the folder created on your Dropbox.
For more info on this, visit: https://devcenter.heroku.com/articles/dropbox-sync
#### Medium
1. Fork this repo on github.
2. In your heroku app control panel, at Deploy tab, connect your app to a forked repository and enable automatic deploys.
3. When update comes, merge changes into your repo on github:
1. Create new pull request.
2. Select your repo's master branch as base fork, and South-Paw/salien-script-js master branch as head fork.
3. Click on a big green button "Merge pull request".
For more info on connecting github account, visit: https://devcenter.heroku.com/articles/github-integration
For more info on syncing fork using web interface, check this tutorial: https://www.sitepoint.com/quick-tip-sync-your-fork-with-the-original-without-the-cli/
#### Hard
If you created your app using web-console, you need to clone heroku repo first
```bash
$ git clone https://git.heroku.com/[APP_NAME].git -o heroku
$ cd [APP_NAME]
$ git remote add upstream https://github.com/South-Paw/salien-script-js.git
```
And then, fetch, merge and push
```bash
$ git fetch upstream
$ git merge remotes/upstream/master
$ git push heroku master
```
---

@@ -252,0 +123,0 @@

@@ -25,7 +25,3 @@ const chalk = require('chalk');

headers: {
Accept: '*/*',
Origin: 'https://steamcommunity.com',
Referer: 'https://steamcommunity.com/saliengame/play/',
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36',
'User-Agent': 'salien-script-js (https://github.com/South-Paw/salien-script-js)',
},

@@ -47,2 +43,5 @@ ...requestOptions,

response = await request.json();
// Create a unique key in the response object that we can use to get `x-eresult` from.
response.response.___headers = request.headers; // eslint-disable-line no-underscore-dangle
} catch (e) {

@@ -143,2 +142,36 @@ logger(`${chalk.bgRed(`${e.name}:`)} ${chalk.red(`For ${method}`)}`, e);

const joinBossZone = async (token, zoneId, logger, silent, maxRetries = MAX_RETRIES, retryDelayMs = RETRY_DELAY_MS) => {
const method = 'ITerritoryControlMinigameService/JoinBossZone/v0001';
const params = [`access_token=${token}`, `zone_position=${zoneId}`];
const options = { method: 'POST' };
const response = await doFetch(method, params, options, logger, silent, maxRetries, retryDelayMs);
return response;
};
const reportBossDamage = async (
token,
useHeal,
damageToBoss,
damageTaken,
logger,
silent,
maxRetries = MAX_RETRIES,
retryDelayMs = RETRY_DELAY_MS,
) => {
const method = 'ITerritoryControlMinigameService/ReportBossDamage/v0001';
const params = [
`access_token=${token}`,
`use_heal_ability=${useHeal}`,
`damage_to_boss=${damageToBoss}`,
`damage_taken=${damageTaken}`,
];
const options = { method: 'POST' };
const response = await doFetch(method, params, options, logger, silent, maxRetries, retryDelayMs);
return response;
};
const reportScore = async (token, score, logger, silent, maxRetries = MAX_RETRIES, retryDelayMs = RETRY_DELAY_MS) => {

@@ -163,3 +196,5 @@ const method = 'ITerritoryControlMinigameService/ReportScore/v0001';

joinZone,
joinBossZone,
reportBossDamage,
reportScore,
};

@@ -83,6 +83,6 @@ const chalk = require('chalk');

planet.zones.forEach(zone => {
const { capture_progress: captureProgress, captured, type, difficulty } = zone;
const { capture_progress: captureProgress, captured, type, difficulty, gameid } = zone;
// disregard this zone if its close to being captured or already captured
if ((captureProgress && captureProgress > completionCutoff) || captured) {
// disregard this zone if there is no gameid, it's close to being captured or already captured
if (!gameid || (captureProgress && captureProgress > completionCutoff) || captured || captureProgress === 0) {
return;

@@ -89,0 +89,0 @@ }

@@ -38,2 +38,4 @@ /**

joinZone,
joinBossZone,
reportBossDamage,
reportScore,

@@ -111,2 +113,17 @@ } = require('./api/index');

async apiJoinBossZone(zoneId) {
return joinBossZone(this.token, zoneId, (m, e) => this.logger(m, e), this.isSilentRequest);
}
async apiReportBossDamage(useHeal, damageToBoss, damageTaken) {
return reportBossDamage(
this.token,
useHeal,
damageToBoss,
damageTaken,
(m, e) => this.logger(m, e),
this.isSilentRequest,
);
}
async apiReportScore(score) {

@@ -127,3 +144,4 @@ return reportScore(this.token, score, (m, e) => this.logger(m, e), this.isSilentRequest);

const activePlanet = playerInfo.active_planet;
const newPlayerInfo = await this.apiGetPlayerInfo();
const activePlanet = newPlayerInfo.active_planet;

@@ -187,2 +205,70 @@ if (requestedPlanetId > 0 && requestedPlanetId !== activePlanet) {

async playBossZone() {
const min = 120;
const max = 180;
let nextHeal = Math.floor(new Date().getTime() / 1000) + Math.floor(Math.random() * (max - min + 1) + min);
let allowedBossFails = 10;
// eslint-disable-next-line no-constant-condition
while (true) {
let useHeal = 0;
const damageToBoss = 1;
const damageTaken = 0;
if (Math.floor(new Date().getTime() / 1000) >= nextHeal) {
useHeal = 1;
nextHeal = Math.floor(new Date().getTime() / 1000) + 120;
this.logger('@@ Boss -- Using heal ability');
}
const report = await this.apiReportBossDamage(useHeal, damageToBoss, damageTaken);
// eslint-disable-next-line no-underscore-dangle
if (report.___headers.get('x-eresult') !== 1) {
allowedBossFails -= 1;
if (allowedBossFails < 1) {
throw new SalienScriptRestart('Boss battle had too may errors!');
}
}
if (!report.boss_status) {
this.logger('@@ Boss -- Waiting...');
await delay(3000);
continue; // eslint-disable-line no-continue
}
// TODO: support logging of boss_status and players
// https://github.com/SteamDatabase/SalienCheat/blob/master/cheat.php#L203
if (report.game_over) {
this.logger('@@ Boss -- The battle is over!');
return;
}
if (report.waiting_for_players) {
this.logger('@@ Boss -- Waiting for players...');
await delay(3000);
continue; // eslint-disable-line no-continue
}
// TODO: this message could be far prettier
let bossStatusMsg = `@@ Boss -- HP: ${Number(report.boss_status.boss_hp)}`;
bossStatusMsg += `/${Number(report.boss_status.boss_max_hp)}`;
bossStatusMsg += ` - Lasers: ${report.boss_status.num_laser_uses}`;
bossStatusMsg += ` - Team Heals: ${report.boss_status.num_team_heals}`;
this.logger(bossStatusMsg);
console.log(''); // eslint-disable-line no-console
}
}
async doGameLoop() {

@@ -199,4 +285,19 @@ while (this.currentPlanetAndZone.id !== this.steamThinksPlanet) {

const zone = await this.apiJoinZone(this.currentPlanetAndZone.bestZone.zone_position);
let zone;
if (this.currentPlanetAndZone.bestZone.boss_active) {
zone = await this.apiJoinBossZone(this.currentPlanetAndZone.bestZone.zone_position);
// eslint-disable-next-line no-underscore-dangle
if (zone.___headers.get('x-eresult') !== 1) {
throw new SalienScriptRestart('!! Failed to join boss zone', zone);
}
await this.playBossZone();
return;
}
zone = await this.apiJoinZone(this.currentPlanetAndZone.bestZone.zone_position);
// rescan if we failed to join

@@ -203,0 +304,0 @@ if (!zone.zone_info) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc