Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Saroumane opened this issue May 13, 2024 · 5 comments

Comments

@Saroumane
Copy link

Saroumane commented May 13, 2024

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 :

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

@Saroumane
Copy link
Author

Saroumane commented May 14, 2024

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}`)

@Saroumane
Copy link
Author

For the record, opening a random page like above was not effective.
Now I use "dotool" to force a "Hard Reload" (Control Shift R) of the page, with a fresh cookie generated !


// script can freeze if chromium is not already started !
const myurl = `https://steamcommunity.com/`;
// open steamcommunity.com, trigger a Hard Reload to refresh cookies, close window
// to install dotool : $ yay -Suy dotool
exec(`chromium --app=${myurl} && (echo key ctrl+shift+R | dotool) & sleep 3 && (echo key ctrl+W | dotool)`)

I have now 0 manual setup, the script is fully automated !
The only thing I'd like to improve, is to auto-close the chromium window after 3 seconds. For now it does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants