Implement Extensions #5

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

View File

@ -4,26 +4,37 @@ echo "Loading extensions..."
INPUT=$(echo $1)
for EXT in /etc/xdg-sanity/extensions/*.sh
for EXT in etc/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" ]
echo "Found $TYPE extension $EXT"
if [ "$TYPE" = "replace" ]
then
MOD=$($EXT "$INPUT")
INPUT=$(echo $MOD)
fi
INPUT=$($EXT "$INPUT")
echo "Modifying $INPUT..."
echo "Got $INPUT"
fi
if [ "$TYPE" = "mime" ]
then
MIME=$($EXT "$INPUT")
echo $MIME
fi
done
echo "Determining MIME type of $INPUT:"
if [ "$MIME" = "$1" ]
then
MIME=$(curl -I -s "$INPUT" | sed -ne 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//g' | tr -d '\r')
fi
echo $MIME
BROWSER=$(cat /etc/xdg-sanity.conf | sed -ne 's/^browser = //p' )
BROWSER=$(cat /etc/xdg-sanity/xdg-sanity.conf | sed -ne 's/^browser = //p' )
if [ "$MIME" = "text/html" ]
then

View File

@ -0,0 +1,12 @@
#!/bin/sh
# EXT-TYPE=mime
TEST=$(echo $1 | sed -ne 's/^h.\+\/\///p' | sed -ne 's/\/.*\+//p')
if [ $TEST = "teddit.net" ]
then
echo "text/html"
else
echo $1
fi

View File

@ -1,5 +1,13 @@
#!/bin/sh
# EXT-TYPE=pre
# EXT-TYPE=replace
TEST=$(echo $1 | sed -ne 's/^h.\+\/\///p' | sed -ne 's/\/.*\+//p')
if [ $TEST = "youtube.com" ]
then
echo $1 | sed -ne 's/youtube.com/piped.mint.lgbt/p'
else
echo $1
fi