是否可以对我的书签列表中的所有网站自动进行全文搜索(或更好的正则表达式)?
编辑
还有其他浏览器可以实现这个功能吗?
答案1
也许您可以使用在里面找到的 .json 备份~/.mozilla/firefox/'profile name'/bookmarkbackups/
来搜索网站,然后在这些网站内搜索表达。
答案2
以下脚本将访问您书签的最新自动备份,并针对每个书签发出请求HTML链接.. 格式为纯文本.. 它使用一个名为的终端网络浏览器links
(它位于 Ubuntu 存储库中)...它还使用一个名为的轻量级文本编辑器leafpad
,因此您可以修改、添加、更改您想要的链接(它也在 Upunto 存储库中)...
它不会追踪链接..它只是为您提供链接所连接的页面...
实际捕获的网页输出被写入一个打开的文本文件gedit
(但您可以修改它以使用 grep、sed、awk、vim、less……等等……)
这是脚本:(它可能有一些错误,但它不会写入您的书签历史记录,它只会读取它们......
#!/bin/bash
#
# mame: ffhtmllinks
#
# requires: firefox ...(The source of the bookmarks, using the auto backup list)
# TODO: use current list (but where is it?)
# leafpad ...(It acts as an editable dialog)
# links ...(Terminal web browser, which can write formatted document to stdout)
bname=$(basename $0)
ffdir="$HOME/.mozilla/firefox"
[[ ! -e "$ffdir" ]] && { echo "ERROR: Could not find Firefox config directory:" ; echo "$ffdir" ; exit 1 ; }
echo -e "\n# Profile Name\tDirectory\n= ============\t================"
< "$ffdir/profiles.ini" sed -n \
-e "/^\[Profile[0-9]\]$/,/^Path=/{
:top
s/^Name=\(.*\)/\1/; t holdname
s/^Path=\(.*\)/\1/; t havepath
n; b top
:holdname
h; n; b top
:havepath
x; G; s/\(.*\)\n\(.*\)/\1:\t\2/p
}" | nl -w 1 -s ' ' > "$ffdir/$bname.names"
cat "$ffdir/$bname.names"
echo -e "\nType the Name (or line number) of the Profile" \
"\n whose bookmarks you want to search"
read name
name="${name%% /}"
name="${name## /}"
<"$ffdir/$bname.names" sed -n "/^\($name .*\)\|\([0-9]\+ $name\)$/ p" > "$ffdir/$bname.sel"
selct=$(<"$ffdir/$bname.sel" wc -l)
(( selct != 1 )) && { echo "ERROR: Could not find Profile:" ; echo "$name" ; exit 2 ; }
profdir="$ffdir/$(<"$ffdir/$bname.sel" sed -n "s/^[0-9]\+ [^"$'\t'"]\+"$'\t'"\(.*\)$/\1/p")"
bbakdir="$profdir/bookmarkbackups"
[[ ! -e "$profdir" ]] && { echo "ERROR: Could not find Firefox Profile directory:" ; echo "$profdir" ; exit 3 ; }
[[ ! -e "$bbakdir" ]] && { echo "ERROR: Could not find Firefox Bookmark Backup directory:" ; echo "S$bbakdir" ; exit 4 ; }
bbakjson="$(for f in "$bbakdir/bookmarks"* ; do echo "$f" ; done | sed -n \$p)"
[[ ! -e "$bbakjson" ]] && { echo "ERROR: Could not find Firefox Bookmark Backup .json file:" ; echo " $bbakjson" ; exit 4 ; }
bbakhtml="$ffdir/$bname.bbakhtml"
<"$bbakjson" sed -n "s/,\"uri\":\"http/\n"$'\x01'===$'\x01'"http/gp" \
|sed -n "s/^"$'\x01'"==="$'\x01'"\([^"\""]\+\)\".*/\n\1\n/p" \
|sed "/^$/ d" \
>"$bbakhtml"
echo "===="
echo "INFO: About to open the list of bookmark links in a text editor (leafpad)..."
echo " You can modify, add or remove links as you like..."
echo " It is only a temporary file, so you won't loose your bookmarks..."
echo " NB: You must actually EXIT 'leafpad' before this process can proceed."
echo
echo -n "Press Enter to open the bookmarks list in 'leafpad'... "
read x
echo
div="####################################################################################"
pagedump="$ffdir/$bname.bbakdump" ; cp /dev/null "$pagedump"
linkcnt=$(<"$bbakhtml" wc -l); linklnb=1
<"$bbakhtml" leafpad 2>/dev/null
echo "======================================="
( while IFS= read -r link ; do
echo -e "\n\n$div\n$div\n$div\n# \n# Link $((linklnb++)) of $linkcnt\n# \n"
links -dump "$link"
done <"$bbakhtml" ) |tee >( sed -n p >>"$pagedump" ) | sed -n p
wait 2 # TODO need a wait loop here for asynchronous process-substitution (sleep will have to do for now)
gedit "$pagedump"
exit
#