是否可以从命令行获取 Firefox 选项卡中网页的标题或 url?

Possibility to get titles or urls of webpages in Firefox tabs from command line?

作为机器上的根用户,从命令行。是否可以获取用户在 Firefox 选项卡中打开的网页的标题(或 url)?

是的,您必须导航到 Firefox/profiles/session/{random-string}-default/sessionstore-backups/recovery.jsonlz4

该文件包含以 LZ4 格式压缩的当前选项卡。您可以使用 cat 来了解其中的内容,但您必须使用 python 或 https://github.com/andikleen/lz4json

对其进行解压缩

这里有一个 python 脚本的更深入的答案:https://unix.stackexchange.com/questions/385023/firefox-reading-out-urls-of-opened-tabs-from-the-command-line

考虑到它已有 4 年历史,您可能需要对其进行一些修改,但 Firefox 的文件结构似乎几乎保持不变。

请注意,您必须找到每个操作系统设置文件的具体位置,例如 mac osx 它位于 /users/$USER/Library/Application\ Support/Firefox/Profiles/{随机字符串}-default/sessionstore-backups/recovery.jsonlz4

我不确定其他操作系统在哪里保存它