Implement Extensions #5

Merged
emma merged 5 commits from extensions into main 2022-09-04 19:05:10 -06:00
3 changed files with 27 additions and 6 deletions
Showing only changes of commit 2cfd97c158 - Show all commits

View File

@ -1,17 +1,33 @@
#!/bin/sh #!/bin/sh
echo "Determining MIME type of $1:" echo "Loading extensions..."
MIME=$(curl -I -s "$1" | sed -n -e 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//g' | tr -d '\r') INPUT=$(echo $1)
for EXT in xdg-sanity/extensions/*.sh
do
echo "Found extension $EXT"
TYPE=$(cat $EXT | sed -ne 's/^# EXT-TYPE=//p' | tr -d '\n')
echo "Modifying $INPUT..."
if [ "$TYPE" = "pre" ]
then
MOD=$($EXT "$INPUT")
INPUT=$(echo $MOD)
fi
echo "Got $INPUT"
done
echo "Determining MIME type of $INPUT:"
MIME=$(curl -I -s "$INPUT" | sed -ne 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//g' | tr -d '\r')
echo $MIME echo $MIME
BROWSER=$(cat /etc/xdg-sanity.conf | sed -n -e 's/^browser = //p' ) BROWSER=$(cat /etc/xdg-sanity.conf | sed -ne 's/^browser = //p' )
if [ "$MIME" = "text/html" ] if [ "$MIME" = "text/html" ]
then then
$BROWSER $1 $BROWSER $INPUT
else else
handlr launch "$MIME" -- "$1" handlr launch "$MIME" -- "$INPUT"
fi fi

View File

@ -0,0 +1,5 @@
#!/bin/sh
# EXT-TYPE=pre
echo $1 | sed -ne 's/youtube.com/piped.mint.lgbt/p'