Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Better UI-configs 😎 Fixed #6
Browse files Browse the repository at this point in the history
Fixed crash issue that the bot was having in the latest version. ✅

Removed socket connections that wasn't being used.
Cleaned up the old socketConnect stuff.

Added more config options to the UI.
- Shared Secrets and Identity Secret
- Basic account information like username ect.

When you change the config and open the window up again you will see the changes to the config files. The window does now also close when you hit the "save" button
  • Loading branch information
ThunbergOlle committed Sep 25, 2018
1 parent c87651c commit 8d7c77a
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 24 deletions.
31 changes: 31 additions & 0 deletions WebPage/configs/configAccount.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<title>Accounts basic settings</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" type="text/css" href="../style.css">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="form-group center margintop centerdiv">
<label for="username" id="label">Username</label>
<input type="text" id ="username" class="form-control centerdiv center" style="width: 75%;" placeholder="">
<label for="password" id="label2">Password</label>
<input type="password" id ="password" class="form-control centerdiv center" style="width: 75%;" placeholder="">
<button type="button" class="btn btn-outline-success" id="btn">Save</button>
</div>
<p class="color-danger font-weight-bold" style="margin-left: 15%; margin-right: 15%; color:red; text-align: center">We strongly recommend using a seperate account for the bot.</p>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
require('./scripts/configAccount.js');

</script>
</body>
</html>
2 changes: 1 addition & 1 deletion WebPage/configs/configOwnerID.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<body>
<div class="form-group center margintop centerdiv">
<label for="ownerconfig" id="label">Set owners 64 id:</label>
<input type="text" id="id">
<input type="text" id="id" class="form-control centerdiv center" style="width: 75%;">
<button type="button" class="btn btn-outline-success" onclick="send()" id="btn">Save</button>
</div>
<!-- Optional JavaScript -->
Expand Down
25 changes: 25 additions & 0 deletions WebPage/configs/scripts/configAccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const configjs = require('../../../modules/config.js');
const config = require('../../../config.json');
const username = document.getElementById("username");
const password = document.getElementById("password");
username.value = config.username;
password.value = config.password;
if (password.value === 'Steam password') {
password.type = "text"
}
password.addEventListener("click", () => {
password.type = "password";
});
const btn = document.getElementById('btn');

btn.addEventListener('click', () => {
if (username.value !== '' && password.value !== '') {
configjs.confighandler('username', username.value);
wait = () => {
configjs.confighandler('password', password.value);
window.close();

}
setTimeout(wait, 1000);
}
});
2 changes: 1 addition & 1 deletion WebPage/configs/scripts/configGames.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ let btn = document.getElementById('btn');
btn.addEventListener('click', () => {
configjs.confighandler('game', game.value);
label.innerHTML = 'Updated to game: ' + game.value;

window.close();
});
5 changes: 4 additions & 1 deletion WebPage/configs/scripts/configOwnerID.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const configjs = require('../../../modules/config');
var id = document.getElementById('id');
const config = require('../../../config.json');
const id = document.getElementById('id');
id.value = config.ownerID;
let btn = document.getElementById('btn');
let label = document.getElementById('label');

btn.addEventListener('click', () => {
configjs.confighandler('ownerID', id.value);
label.innerHTML = 'Updated to ownerid: ' + id.value;
window.close();
});
25 changes: 25 additions & 0 deletions WebPage/configs/scripts/configSecret.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const configjs = require('../../../modules/config');
const config = require('../../../config.json');
const electron = require('electron');
const shell = electron.shell;
const iSecret = document.getElementById('iSecret');
const sSecret = document.getElementById('sSecret');
iSecret.value = config.identitySecret;
sSecret.value = config.sharedSecret;
const label = document.getElementById('label');
let btn = document.getElementById('btn');
let externalLink = document.getElementById('link');
link.addEventListener('click', () => {
shell.openExternal('https://github.com/SteamTimeIdler/stidler/wiki/Getting-your-%27shared_secret%27-code-for-use-with-Auto-Restarter-on-Mobile-Authentication#getting-shared-secret-from-steam-desktop-authenticator-windows');
});
btn.addEventListener('click', () => {
if (iSecret.value !== '') {
configjs.confighandler('identitySecret', iSecret.value);
}
if(sSecret.value !== ''){
configjs.confighandler('sharedSecret', sSecret.value);
}
window.close();
label.innerHTML = 'Updated values';

});
4 changes: 3 additions & 1 deletion WebPage/configs/scripts/configTrash.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const configjs = require('../../../modules/config');
const config = require('../../../config.json');
const trashlimit = document.getElementById('trashlimit');
trashlimit.value = config.trashlimit;
const label = document.getElementById('label');
let btn = document.getElementById('btn');

btn.addEventListener('click', () => {
configjs.confighandler('trashlimit', trashlimit.value);
label.innerHTML = 'Updated to game: ' + trashlimit.value;

window.close();
});
22 changes: 6 additions & 16 deletions WebPage/configs/secrets.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>
<html lang="en">
<head>
<title>Trash limit</title>
<title>Shh... These are secrets!</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
Expand All @@ -12,30 +12,20 @@
<body>
<div class="form-group center margintop centerdiv">
<label for="iSecret" id="label">Identity Secret</label>
<input type="number" id ="iSecret" class="form-control centerdiv center" style="width: 75%;" placeholder="" step="0.01">
<input type="text" id ="iSecret" class="form-control centerdiv center" style="width: 75%;" placeholder="">
<label for="sSecret" id="label2">Shared Secret</label>
<input type="number" id ="sSecret" class="form-control centerdiv center" style="width: 75%;" placeholder="" step="0.01">
<button type="button" class="btn btn-outline-success" onclick="send()">Save</button>
<input type="text" id ="sSecret" class="form-control centerdiv center" style="width: 75%;" placeholder="">
<button type="button" class="btn btn-outline-success" id="btn">Save</button>
</div>

<p class="color-danger font-weight-bold" style="margin-left: 15%; margin-right: 15%; color:red; text-align: center">NOTE: These values are really important and can be found <a id="link" href="#">here</a></p>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
require('./scripts/configSecret.js');
let iSecret = document.getElementById('iSecret');
let sSecret = document.getElementById('sSecret');
let label = document.getElementById('label');
let label2 = document.getElementById('label2');
send = () => {
socket.emit('config', {
iSecret: iSecret.value,
sSecret: sSecret.value
});
self.close();
}

</script>
</body>
</html>
3 changes: 1 addition & 2 deletions WebPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ <h2 id="title" class="display-4 center">Tradebot</h2>
<footer><p id="tradestoday">Trades today: </p><p id="totalprofit">Total profit: </p></footer>
</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script>
<script src="./socketConnect.js"></script>

<script>
require('./renderer.js');

Expand Down
1 change: 0 additions & 1 deletion WebPage/renderer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//Here is the javascript part of the index.html file.
const ipcRenderer = require('electron').ipcRenderer;
var socket = io.connect('http://127.0.0.1:4000');
var title = document.getElementById('title');
var status = document.getElementById('status');
var tradestoday = document.getElementById('tradestoday');
Expand Down
Empty file removed WebPage/socketConnect.js
Empty file.
26 changes: 25 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ const mainMenuTemplate = [{
{
label: 'Config',
submenu: [
{
label: 'Account',
click: function () {
smallwin = new BrowserWindow({ width: 350, height: 450 });
smallwin.loadURL(url.format({
pathname: path.join(__dirname + '/WebPage/configs/configAccount.html'),
protocol: 'file',
slashes: true,
}));
smallwin.setMenu(null);
}
},
{
label: 'Games',
click: function () { //This handles when the label is clicked.
Expand Down Expand Up @@ -139,6 +151,18 @@ const mainMenuTemplate = [{
}));
smallwin.setMenu(null);
}
},
{
label: 'Secrets',
click: function () {
smallwin = new BrowserWindow({ width: 350, height: 450 });
smallwin.loadURL(url.format({
pathname: path.join(__dirname + '/WebPage/configs/secrets.html'),
protocol: 'file',
slashes: true,
}));
smallwin.setMenu(null);
}
}
]
},
Expand Down Expand Up @@ -278,8 +302,8 @@ function processOffer(offer) {
console.log('Our Value: '.blue + ourprice);
if (ourprice <= theirprice) { //IF our value is smaller than their, if they are overpaying
if (theirprice != 0 && ourprice != 0) { //If someone is actually offering something.
acceptOffer(offer, profit); //Accepts the offer
var profitprice = theirprice - ourprice; //calculates the profit from the trade
acceptOffer(offer, profitprice); //Accepts the offer
sendStatus(ourprice, theirprice, profitprice, partner); //Goes to the function sendstatus and passes some final variables.
fs.writeFile("./trades/" + offer.id + ".txt", 'Profit from trade: ' + profitprice + "\n" + 'New items: ' + allitems, function (err) { //Adds it into trades folder.
if (err) debug(err);
Expand Down

0 comments on commit 8d7c77a

Please sign in to comment.