nzpost

 avatar
unknown
python
a month ago
839 B
2
No Index
#!/usr/bin/env bash

# chrome-cli list tabs

CHROMECLI="/opt/homebrew/bin/chrome-cli"

# Configuration variables
# security add-generic-password -a "nzpost_user" -s "NZPost" -w "pass"
NZPOST_PASS=$(security find-generic-password -s "NZPost" -w);
USERNAME="email"
PASSWORD="${NZPOST_PASS}"
TAB_ID="tab_id"

# Open NZ Post login page
$CHROMECLI execute "window.location.href = 'https://www.nzpost.co.nz/user/me';" -t $TAB_ID
sleep 1  # Wait for the page to load

# Fill in credentials and submit form
$CHROMECLI execute \
    "document.querySelector('#username').value='$USERNAME'; \
    document.querySelector('#password').value='$PASSWORD'; \
    document.querySelector('form[data-form-primary=true]').submit();" \
    -t "$TAB_ID"

sleep 2
$CHROMECLI execute "window.location.href = 'https://www.nzpost.co.nz/tools/tracking';" -t $TAB_ID
Editor is loading...
Leave a Comment