Yet another CLI for buaaStudentNcov, powered by Puppeteer.
This implementation relys only on the DOM structure of the page, trying to be agnostic of frontend details and the request specs, hence less likely to post any malformed requests. Request interception provided by Puppeteer is useful for doing faster and more stable geolocation, without injecting scripts into AMap API.
- Node.js
- Chromium (optional)
To use with your custom Chromium/Chrome installation, export the environment variables before npm install
:
$ export PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable # your Chromium/Chrome executable
Otherwise, one will be downloaded automatically during the installation.
$ npm install
$ cp config.example.json config.json
$ vi config.json # Fill with your information
config.json
must be present in the working directory. At the first run, a new file cookies.json
will be created for caching the login cookies. Please keep the two files confidential.
$ node main.js
config.json
should represent a JSON Object with the following fields:
username
: stringpassword
: string
The optional fields are below:
longitude
: stringlatitude
: string- Your position in GCJ-02. If unspecified, the original AMap geolocation will be used, which can be slow and often fails.
check_on_campus
: boolean, defaults tofalse
- Explicitly click the answer to the first question. Use this if simply inheriting fails to submit (usually when not on campus).
timeout
: number, defaults to30000
- Timeout before waiting for page elements, in milliseconds.
browser
: object- Passed to puppeteer.launch, useful for specifying
executablePath
of Chromium.
- Passed to puppeteer.launch, useful for specifying
dry
: boolean, defaults tofalse
- Stop before clicking the final submit button. Useful for checking the actual address of your given position.
hang
: boolean, defaults tofalse
- Wait for signals rather than close the browser immediately after finished. Useful for debugging with
browser.headless
set tofalse
.
- Wait for signals rather than close the browser immediately after finished. Useful for debugging with
shifted
: boolean, defaults tofalse
The following browser
configuration is tested to work in TermuxArch, a Termux proot distro:
"browser": {
"executablePath": "/usr/bin/chromium", // provided by your distro
"args": [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage"
]
}
A wrapper script is provided for notification support (requires Termux:API), handy for usage with cronie
.