Mac safari proxy automatic switcher

https://www.zhihu.com/question/20818790

 

 

作者:Liap
链接:https://www.zhihu.com/question/20818790/answer/16481541
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

tell application “Finder”
set dialog to display dialog “GoAgent switch. Please select:” buttons {“ON”, “OFF”, “Cancel”} default button “ON” with title “GoAgent”
set interface to button returned of dialog
end tell

if interface is “Cancel” then
return
end if

if interface is “ON” then
tell application “Terminal”
do script “python goagent/local/proxy.py”
end tell

do shell script “networksetup -setwebproxy Wi-Fi 127.0.0.1 8087” user name “***” password “***” with administrator privileges
do shell script “networksetup -setsecurewebproxy Wi-Fi 127.0.0.1 8087” user name “***” password “***” with administrator privileges
do shell script “networksetup -setwebproxystate Wi-Fi on” user name “***” password “***” with administrator privileges
do shell script “networksetup -setsecurewebproxystate Wi-Fi on” user name “***” password “***” with administrator privileges
end if
if interface is “OFF” then
tell application “Terminal”
do script “killall Terminal”
end tell
do shell script “networksetup -setwebproxystate Wi-Fi off” user name “***” password “***” with administrator privileges
do shell script “networksetup -setsecurewebproxystate Wi-Fi off” user name “***” password “***” with administrator privileges
end if

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注