问题描述
在Firefox中-所有选项卡之间:如何使用浏览器外部的代码列出所有打开的浏览器中所有打开的浏览器选项卡的所有打开URL?
---
如果我打开多个标签页或其他带有标签页的浏览器,然后关闭计算机,或者它崩溃或杀死所有进程(.exe),则下次启动浏览器时,所有标签页都将在其中重新打开关闭前存在一个或多个浏览器窗口。
此信息存储在哪里?具体来说,URL存储在哪里,以便可以实现?
1) 当浏览器/选项卡启动并运行时,我需要以编程方式访问所有正在运行的浏览器中所有选项卡中当前打开的所有URL的给定配置文件
2) 是否关闭:是否全部关闭(数据存储在某个文件或数据库的配置文件目录中的某个位置,以便下次启动时将打开所有URL)
---
我想通过bash(cygwin),Python,Java或Rust来访问所有打开或存储的URL,某些语言在计算机上运行,用于访问配置文件目录中的文件(在浏览器外部运行的代码)。>
解决方法
如果我打开多个标签页或其他带有标签页的浏览器,然后关闭计算机,或者它崩溃或杀死所有进程(.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,这表明会话信息存储在utf-8 encoded JSON file,compressed with lz4的sessionstore.jsonlz4
文件中。
不幸的是,使用的lz4压缩不适用于标准工具,但是关于如何在Superuser上解决该问题进行了很好的讨论(例如,跳过文件的前8个字节)。
另一种可能性是创建一个WebExtension并对可执行文件执行Native messaging。如果具有适当的权限,WebExtensions可以枚举打开的窗口和选项卡并获取其URL。