Repository Public License
1#!/bin/zsh2# usage: dev-safari.sh file.js (file defines: async function main(){...return string}); runs in the signed-in developer.apple.com tab3osascript - "$1" <<'OSA'4on run argv5 set js to read (POSIX file (item 1 of argv)) as «class utf8»6 tell application "Safari"7 repeat with w in windows8 repeat with t in tabs of w9 if (URL of t) contains "developer.apple.com/account" then10 do JavaScript "window.__r='PENDING'; (async()=>{try{" & js & "; window.__r=String(await main())}catch(e){window.__r='ERR '+e}})();" in t11 repeat 80 times12 delay 0.513 set r to do JavaScript "window.__r" in t14 if r is not "PENDING" then return r15 end repeat16 return "TIMEOUT"17 end if18 end repeat19 end repeat20 return "NO TAB"21 end tell22end run23OSA24