Repository Public
1#!/bin/zsh2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : MacLustr Storage Node8# File : Scripts/portal/dev-safari.sh9# Module : Scripts10# Repository : https://git.spboucher.ai/maclustr-storage-ios11# Project Website : https://storage.spboucher.ai12# Created : 2026-12-0113# Last Modified : 2026-12-0114#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: admin@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License : None specified (no license file in this repository)33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# MacLustr Storage Node42# File: Scripts/portal/dev-safari.sh43# Description: Runs a JavaScript file inside the Safari tab the owner already signed in to on developer.apple.com44# (AppleScript "do JavaScript"). Reads no cookie, password or verification code.45#46# Author: Simon-Pierre Boucher47# Contact: contact@spboucher.ai48#49# usage: dev-safari.sh file.js [url-fragment] (file defines: async function main(){ ... return string })50osascript - "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" "${2:-developer.apple.com/account}" <<'OSA'51on run argv52 set js to read (POSIX file (item 1 of argv)) as «class utf8»53 tell application "Safari"54 repeat with w in windows55 repeat with t in tabs of w56 if (URL of t) contains (item 2 of argv) then57 do JavaScript "window.__r='PENDING'; (async()=>{try{" & js & "; window.__r=String(await main())}catch(e){window.__r='ERR '+e}})();" in t58 repeat 80 times59 delay 0.560 set r to do JavaScript "window.__r" in t61 if r is not "PENDING" then return r62 end repeat63 return "TIMEOUT"64 end if65 end repeat66 end repeat67 return "NO TAB"68 end tell69end run70OSA71