"Auto nuaa.portal" is a project for automatically login to "nuaa.portal" (南京航空航天大学校园无线网) without input username and password manually.
The Shortcuts for iOS can be downloaded from here.
Following is a Hammerspoon
(which is "a tool for powerful automation of OS X") config which can be also found at auto-nuaa.portal.lua. This config file allow your Mac automatically run login.py
whenever it is connected to nuaa.portal
.
nuaaSSID = "nuaa.portal"
lastSSID = hs.wifi.currentNetwork()
function ssidChangedCallback()
newSSID = hs.wifi.currentNetwork()
if newSSID == nuaaSSID then
command = "<directory of Python> '<directory of login.py>'"
local handle = io.popen(command)
local result = handle:read("*a")
handle:close()
hs.notify.new({title="Hammerspoon", informativeText=result}):send()
end
lastSSID = newSSID
end
wifiWatcher = hs.wifi.watcher.new(ssidChangedCallback)
wifiWatcher:start()
NOTICE:
-
DO NOT FORGET to replace
<directory of Python>
and<directory of login.py>
; -
To use this config file, "username" and "password" must be set in
config.py
.
The Alfred workflow for MacOS can be deployed by following steps.
- Install Python with "Requests" library.
- Install Miniconda Python.
- Install Requests.
- Install Alfred 4 (this workflow may also compatible with Alfred 3 and Alfred 2, not tested) with a Powerpack licence.
- Download workflow source file from release page and double-click.
- Set the "Workflow Environment Variables" in which
- UNAME is your ID for login to nuaa.portal, like
BX9999999
. - PASSWORD is your password, like
123456
. - PYTHON_ENV is a python environment with "Requests" library installed, it would be like
/Users/{your mac user name}/miniconda3/bin/python
if you follow step 0 to install Python and "Requests". - LOGIN_IP is for users at different campus, the Jiangning campus ip is
211.65.106.6
.
- UNAME is your ID for login to nuaa.portal, like
- Click on "import" to import "Auto nuaa.portal" into your Alfred workflows.
- Disable the "Captive Network Support" in MacOS using
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.captive.control Active -boolean false
This step is required due to terminal can not access to the network when there is a captive network popup for inputting username and password, see this discussion for detail. In case you want to remove this setting use
sudo defaults delete /Library/Preferences/SystemConfiguration/com.apple.captive.control Active
- Connect to "nuaa.portal".
- Using with Alfred keyword "nuaa login" to login to "nuaa.portal".
- Using with Alfred keyword "nuaa logout" to log out.
For the versions available, see releases on this repository.
-
v1.1 - Jun. 05, 2021
-
v1.0.1 - May 01, 2021
- Add: Added a Hammerspoon config file
auto-nuaa.portal.lua
.
- Add: Added a Hammerspoon config file
-
v1.0 - May 21, 2020
- Update: This workflow will not work till the WebView popup for captive portal is closed, fixed this by disable the "Captive Network Support" in MacOS.
- Add: Added an optional
config.py
file to store username and password. - Update: Modified the request URL.
-
v0.9 - May 8, 2020
- Add: Using keyword "nuaa login" to login to "nuaa.portal".
- Add: Using keyword "nuaa logout" to log out.
- Get SSID of current WiFi connection.
This project is licensed under the MIT License, see the LICENSE file for details.
This project referred to