-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathindex.js
124 lines (111 loc) · 2.78 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"use strict";
/*
* IMPORTS: Libraries that steam-yellow uses.
*/
const SteamUser = require('steam-user');
const inquirer = require('inquirer');
const client = new SteamUser();
const argv = require('minimist')(process.argv.slice(2));
// Verbosing info to user
console.log("Welcome to yellow-steam!");
console.log("Join our discord and steam group!");
console.log("WEBSITE: https://drakewitt.github.io/steam-yellow/");
let flags;
let counter = 0;
let flagList = [
1,
256,
512,
1024
];
// Overwrite the SteamUser library's persona flags to make it yellow
SteamUser.prototype.setPersona = function (state, name) {
if (flags > 0) {
this._send(SteamUser.EMsg.ClientChangeStatus, {
"persona_state": state,
"persona_state_flags": flags,
"player_name": name
});
} else {
let flags = 0;
let update = function() {
flags |= flagList[Math.floor(counter / 2)];
let finalFlags = flags;
if (counter % 2 == 1) {
finalFlags |= 4;
}
console.log("Applying flags " + finalFlags);
this._send(SteamUser.EMsg.ClientChangeStatus, {
"persona_state": state,
"persona_state_flags": finalFlags,
"player_name": name
});
counter++;
if (counter >= flagList.length * 2) {
counter = 0;
flags = 0;
}
}.bind(this);
setInterval(update, 750);
}
};
client.on('loggedOn', () => {
client.setPersona(SteamUser.Steam.EPersonaState.Online);
console.log("Logged In! Press CTRL and C to stop.\nProgram must be left Open to Have Flash");
});
/** (<Function callback>) => <Promise ({flags: <Number>, ...})> */
function getLogin(callback) {
if (argv.user && argv.pass) { // command line
return Promise.resolve({
flags: argv.flags || 2820,
accountName: argv.user,
password: argv.pass
});
} else if (argv._.length) { // JSON file
let data = require(argv._[0]);
data.flags = data.flags || 2820;
return Promise.resolve({
flags: data.flags,
accountName: data.username,
password: data.password
});
} else { // prompt
return inquirer.prompt([
{
name: 'accountName',
message: 'Steam username:',
type: 'input'
},
{
name: 'password',
message: 'Steam password:',
type: 'password'
},
{
name: 'flags',
message: 'If "Cycling" is checked, it overrides all other options.\nPlease select which flags to enable:',
type: 'checkbox',
choices: [
{name: "VR online indicator",
value: 2048,
checked: true},
{name: "Mobile online indicator",
value: 512},
{name: "Web online indicator",
value: 256},
{name: "Cycling",
value: -10000}
]
}
]).then(data => {
data.flags = data.flags.reduce((v,p)=>v+p, 0);
return data;
})
}
}
// Get our login data, then login
getLogin().then(data => {
flags = data.flags;
delete data.flags;
client.logOn(data)
});