michael-n0813 / linux-idle-master

Linux version of idle-master, a simple script that emulates being in a steam game to unlock trading cards.
GNU General Public License v2.0
26 stars 8 forks source link

Feature request : automatically retrieve steamLoginSecure from the chromium browser #23

Open Saroumane opened 4 months ago

Saroumane commented 4 months ago

For the record : with a bit of JavaScript and a quick-and-dirty 1-line addition to start.py, it is possible to automatically retrieve steamLoginSecure from a chromium browser :

https://github.com/michael-n0813/linux-idle-master/compare/master...Saroumane:linux-idle-master:master

Prerequisites :

Node.js must be installed. For example with : $ sudo pacman -Suy nodejs

Install rookie from https://github.com/thewh1teagle/rookie/tree/main For example with : $ npm install @rookie-rs/api

Caveat : this js script is intended only for chromium browsers, but rookie supports also other browsers.

michael-n0813 commented 4 months ago

Oh that seems cool, but why use java and not python-pip?? and then pip install rookiepy

We can import the library directly into start.py import rookiepy

The main issue is how do we know what browser to select and if that cookie data is valid or not. Seems more complicated the more I think about it.

Saroumane commented 4 months ago

Sure, it's probably better to do all with python. In my case, I already had npm installed, not python-pip, so why not try js ? :)

You are right, it seems complicated to have a browser-agnostic solution. Regarding cookie data, your code already detects if it's invalid, no ? In my case, I'll have to reload steamcommunity page, or worst case : log in again.

michael-n0813 commented 4 months ago

OK, will have a play and see what I can do, will add it to the v2.3 TODO list.

Saroumane commented 4 months ago

I added some lines in getSteamLoginSecure.mjs to deal with the "invalid cookie data" case (because the cookie is too old). It should force a refresh before extracting the cookie. I guess the same can be done in python.

// open in browser steamcommunity.com/xxxx where xxxx is random, so as to force a refresh of the page and cookie
const varRandom = Math.floor(Math.random()*10000);
const myurl = `https://steamcommunity.com/${varRandom}`;
exec(`xdg-open ${myurl}`)