0

在 Firefox 中 - 跨所有选项卡:如何使用浏览器外部的代码列出所有打开的浏览器中所有打开的浏览器选项卡的所有打开 URL?

---

如果我打开多个选项卡或带有选项卡的其他浏览器,然后我关闭了我的机器,或者它崩溃或我杀死了所有进程(.exe),下次我启动浏览器时,所有选项卡将在一个浏览器窗口中重新打开,或多个浏览器窗口,因为它在关闭之前存在。

这些信息存储在哪里?具体来说,URL 存储在哪里以便实现这一点?

1) 当浏览器/选项卡启动并运行时,我需要以编程方式访问所有正在运行的浏览器中所有选项卡中当前打开的所有 URL,以获取给定的配置文件

2) 与否:如果它们全部关闭(数据存储在某个文件或数据库的配置文件目录中的某个位置,以便下次启动将打开所有 URL)

---

我想通过 bash (cygwin)、Python、Java 或 Rust 访问所有打开或存储的 URL,在机器上运行的一些语言访问配置文件目录中的文件(在浏览器外部运行的代码)。

4

1 回答 1

0

如果我打开多个选项卡或带有选项卡的其他浏览器然后我关闭了我的机器,或者它崩溃或我杀死了所有进程(.exe),下次我启动浏览器时,所有选项卡将在一个浏览器窗口中重新打开,或多个浏览器窗口,因为它在关闭之前存在。

这些信息存储在哪里?具体来说,URL 存储在哪里以便实现这一点?

会话恢复sessionstore组件执行。此处描述了启动恢复过程的高级概述:

/**
 * Session Storage and Restoration
 *
 * Overview
 * This service reads user's session file at startup, and makes a determination
 * as to whether the session should be restored. It will restore the session
 * under the circumstances described below.  If the auto-start Private Browsing
 * mode is active, however, the session is never restored.
 *
 * Crash Detection
 * The CrashMonitor is used to check if the final session state was successfully
 * written at shutdown of the last session. If we did not reach
 * 'sessionstore-final-state-write-complete', then it's assumed that the browser
 * has previously crashed and we should restore the session.
 *
 * Forced Restarts
 * In the event that a restart is required due to application update or extension
 * installation, set the browser.sessionstore.resume_session_once pref to true,
 * and the session will be restored the next time the browser starts.
 *
 * Always Resume
 * This service will always resume the session if the integer pref
 * browser.startup.page is set to 3.
 */

正如我们所见,它提到了SessionFile. 查找该文件时,我们会看到这个定义,它表明会话信息存储在sessionstore.jsonlz4文件中,该文件是一个utf-8 编码的 JSON 文件,用 lz4 压缩

不幸的是,使用的 lz4 压缩不适用于标准工具,但是有一些关于如何在超级用户上解决这个问题的很好的讨论(例如跳过文件的前 8 个字节)。

另一种可能性是创建一个 WebExtension 并使用您的可执行文件执行本机消息传递。如果给予适当的权限,WebExtensions 可以枚举打开的窗口和选项卡并获取它们的 URL。

于 2020-10-09T08:27:36.510 回答