利用 elinks(需要自行安裝, apt-get install elinks) 來讀小說,相當方便,同時也可以翻譯成繁中
平常我是這樣用
nob URL
如果離開後想續讀,可以直接打 nob
至於下一頁,通常我是按兩次 q, 一次是離開 elinks, 一次是翻下一頁
如果要前一頁,則先 q, 再按 p
請自行翻閱 shell scripts
URL=$1
[ "x$URL" = "x" ] && URL=$(cat $HOME/no.url)
read_current() {
if [ -e '/tmp/no.txt' ]; then
HEAD=$(cat /tmp/no.txt | grep "章節列表")
P=$(echo "$HEAD" | cut -d "[" -f2 | cut -d "]" -f1)
H=$(echo "$HEAD" | cut -d "[" -f3 | cut -d "]" -f1)
N=$(echo "$HEAD" | cut -d "[" -f4 | cut -d "]" -f1)
URL=$(grep "${N}. https" /tmp/no.txt | sed -e 's/.*https/https/')
# less /tmp/no.txt
else
echo "Usage: $0 {URL}"
exit 1
fi
}
[ "x$URL" = "x" ] && read_current
while [[ $URL == "https:"* ]]; do
echo "$URL" > /tmp/no.txt
echo "$URL" > $HOME/no.url
elinks -dump "$URL" | cconv -f UTF8-CN -t UTF8-TW - >> /tmp/no.txt
less /tmp/no.txt
read_current
PREV=$(grep "${P}. https" /tmp/no.txt | sed -e 's/.*https/https/')
BM=$(grep "${H}. https" /tmp/no.txt | sed -e 's/.*https/https/')
NEXT=$(grep "${N}. https" /tmp/no.txt | sed -e 's/.*https/https/')
echo "Press ESC key to quit, others to continue..."
Q=0
# read a single character
while read -r -n1 key; do
[[ $key == $'\e' ]] && Q=1 && break
# echo -e -n "KEY='${key}'\nPREV=$PREV\nBM=$BM\nNEXT=$NEXT\n"
if [ "x${key}" = "xp" -o "x${key}" = "xP" ]; then
URL="${PREV}"
elif [ "${key}" = "q" -o "${key}" = "Q" -o "${key}" = "n" -o "${key}" = "N" -o "${key}" = "" ]; then
URL="${NEXT}"
else
URL="${BM}"
fi
break
done
[ $Q = "1" ] && break
done