Adding twitter -> nitter script to modify clipboard

This commit is contained in:
Siina Mashek 2022-04-25 04:44:21 +03:00
parent 997c937320
commit 691e68d90a

20
common/twitnit.sh Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
# Requires xsel
if ! xsel --version &>/dev/null || ! notify-send --version &>/dev/null; then
echo "Make sure this machien has xsel and notify-send"
exit
fi
# Make sure naked domain is at end
m=("mobile.twitter.com" "m.twitter.com" "twitter.com")
r="nitter.eu"
clip=$(xsel -p -l /tmp/xsel.log)
for f in ${m[@]}; do
echo "looking for $f"
if echo "$clip" | grep "$f"; then
echo "Found!"
clip=$(echo $clip | sed -e "s/${f}/${r}/g" | tr -d '\n' | xsel -ib)
notify-send -a TwitNit "Changed $f to $r"
fi
done