xrsh-buildroot/buildroot-v86/board/v86/rootfs_overlay/root/bin/wget

30 lines
823 B
Text
Raw Normal View History

2025-06-24 12:49:55 +02:00
#!/bin/sh
# this is a wget stub which directly interfaces with the browsers javascript fetch()
# REASON: way less overhead / complexity compared to the v86 linux networking stack
url="$1"
filename="$(basename "$url")"
tmp=/mnt/$$
test -z "$1" && { echo "usage: $0 <url> [-o outfile]"; exit 0; }
for arg in $*; do
test $arg = "-o" && shift && filename=$*
shift
done
2025-07-01 16:17:52 +02:00
echo "$url" | grep -qE '^http' && test -f ~/.config/wget/corsproxy && {
proxy="$(cat ~/.config/wget/corsproxy)"
url="${proxy}${url}"
echo "[i] using CORS proxy: $url" 1>&2
}
2025-06-24 12:49:55 +02:00
js '$("[isoterminal]").emit("create_file_from_url",["'$tmp'","'$url'"])'
while sleep 0.5s; do
printf "." 1>&2
2025-07-01 16:17:52 +02:00
test -f $tmp && {
test "$(awk '{ print $1 }' $tmp)" = 0 && retcode=1 || retcode=0
mv $tmp "$filename" && printf "\n" && exit $retcode
}
2025-06-24 12:49:55 +02:00
done