I think this is FANTASTIC. thank you On Wed, May 1, 2019, 3:04 PM wrote: > mothra's great, don't get me wrong. > > #!/bin/rc > # webshittery for use with the following plumb rule: > # data matches 'https?://.+|/tmp/webshit.*|[₀-₉]+|hpost.*' > # plumb to webshit > # plumb client window webshit > rfork e > history = `{seq -w 02 99; echo 01} > fmtopts = $* > mkdir -p /tmp/webshit > cd /tmp/webshit > w = `{ls -t | sed 1q} > if(! ~ $w $history) > w = $#history > label webshit > echo scroll >/dev/wctl > fn focus{ > echo unhide >/dev/wctl >[2]/dev/null > echo current >/dev/wctl > if(test -f /dev/kbdin) > echo -n  >/dev/kbdin > } > fn pleaseexcusemetheoutflow{ > read -c 6000 > incoming > mime = `{file -m incoming} > switch($mime){ > case text/html > w = $history($w) > >$w{ > echo /tmp/webshit/$w $plumb > echo > if(~ $plumb(2) -u) # hpost output > plumb = $plumb(3) > plumb = `{echo $plumb | sed > 's,(https?://.*)/[^/]*,\1,'} > root = `{echo $plumb | sed > 's,(https?://[^/]*).*,\1,'} > cat incoming /fd/0 | htmlfmt -l 4294967295 -a | > awk ' > /\[formfield\]/{ > gsub("\\[formfield\\]", "") > print "§ hpost §" > } > /\[#[^\]]+\]/{ > gsub("\\[#[^\\]]+\\]", "") > } > { > while(match($0, "\\[(image )?[^ \\]]*[^0-9 \\]][^ \\]]*\\]")){ > ref = utf(8320 + links / 1000 % 10) > ref = ref utf(8320 + links / 100 % 10) > ref = ref utf(8320 + links / 10 % 10) > ref = ref utf(8320 + links % 10) > url[links++] = sprintf("%s%s", ref, substr($0, RSTART + 1, > RLENGTH - 2)) > if(index($0, "[image ") == RSTART) > sub("\\[image [^ \\]]+\\]", "{ " ref " }") > else > sub("\\[[^ \\]]*[^0-9 \\]][^ \\]]*\\]", ref) > } > print > } > END{ > print "\nlinks:" > for(i = 0; i < links; i++){ > sub("image ", "", url[i]) > if(match(url[i], "^[₀-₉]+//")) > sub("^[₀-₉]+", "&http:", url[i]) > else if(match(url[i], "^[₀-₉]+/")) > sub("^[₀-₉]+", "&" ENVIRON["root"], url[i]) > else if(!match(url[i], "^[₀-₉]+https?://")) > sub("^[₀-₉]+", "&" ENVIRON["plumb"] "/", url[i]) > print url[i] > } > }' | fmt -j $fmtopts > } > cat $w > /dev/text > focus > case text/* > if(test -s incoming){ > w = $history($w) > >$w{ > echo /tmp/webshit/$w $plumb > echo > cat incoming /fd/0 > } > cat $w > /dev/text > focus > } > case image/* application/^(troff postscript pdf ghostscript) > w = $history($w) > cat incoming /fd/0 > $w > echo plumbing $mime > echo ' plumb -d image' $w > plumb -d image $w > case audio/* > echo playing $mime > echo ' window -scroll -hide play' $plumb > window -scroll -hide play $plumb > case * > echo 'don''t know what to do with' $mime > } > rm incoming > } > plumb = `{syscall -o read 0 buf 1048575 >[2]/dev/null | tail -1} > switch($plumb){ > case http* > echo fetching $plumb > hget $plumb | pleaseexcusemetheoutflow > case hpost > plumb = `{sed 's,.*(https?://[^ '']+).*,\1,;q' /dev/text} > hpost $"plumb | awk '{print};END{printf "%c", 8}' > case hpost* > echo posting to $plumb(3) > rc -c $"plumb | pleaseexcusemetheoutflow > case [₀-₉][₀-₉][₀-₉][₀-₉] > plumb = `{sed -n '/^'^$plumb^'http/{s/[₀-₉]+//p;q;}' > /dev/text} > if(~ $#plumb 1){ > echo fetching $plumb > hget $plumb | pleaseexcusemetheoutflow > } > case /tmp/webshit* > if(test -s $plumb){ > if(~ `{file -m $plumb} image/* application/^(troff > postscript pdf ghostscript)){ > echo plumbing $plumb to image port > plumb -d image $plumb > } > if not{ > cat $plumb > /dev/text > focus > } > } > if not > >/dev/text for(i in `{ls -rt}){ > mime = `{file -m $i} > if(~ $mime image/* application/^(troff > postscript pdf ghostscript)) > echo /tmp/webshit/$i `{basename > $mime} > if not > sed 1q $i > } > } > } >