【问题标题】:In Firefox - across all tabs: How do I list all open URL's of all open browser tabs across all open browsers, using code external to the browser?在 Firefox 中 - 跨所有选项卡:如何使用浏览器外部的代码列出所有打开的浏览器中所有打开的浏览器选项卡的所有打开 URL?
【发布时间】:2021-01-23 09:28:05
【问题描述】:

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

---

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

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

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

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

---

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

【问题讨论】:

    标签: firefox browser-tab


    【解决方案1】:

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

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

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

    /**
     * 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。查找该文件时,我们会看到at this definition,这表明会话信息存储在sessionstore.jsonlz4 文件中,即utf-8 encoded JSON file, compressed with lz4

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-18
      • 2013-09-10
      • 1970-01-01
      • 2014-12-12
      • 1970-01-01
      • 2018-08-29
      • 2011-09-27
      • 2016-09-24
      相关资源
      最近更新 更多