firefox历史文件的路径包含一个配置文件编号,我如何在C#中动态获取这个编号
C:\Users\AppData\Roaming\Mozilla\Firefox\Profiles\.default ormhistory.sqlite
您需要读取profiles.ini文件并捕获默认配置文件
using System;
using System.Linq;
using System.IO;
namespace Firefox
{
class Reader
{
public static string ReadFirefoxProfile()
{
string apppath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string mozilla = System.IO.Path.Combine(apppath, "Mozilla");
bool exist = System.IO.Directory.Exists(mozilla);
if (exist)
{
string firefox = System.IO.Path.Combine(mozilla, "firefox");
if (System.IO.Directory.Exists(firefox))
{
string prof_file = System.IO.Path.Combine(firefox, "profiles.ini");
bool file_exist = System.IO.File.Exists(prof_file);
if (file_exist)
{
StreamReader rdr = new StreamReader(prof_file);
string resp = rdr.ReadToEnd();
string[] lines = resp.Split(new string[] { "\r\n" }, StringSplitOptions.None);
string location = lines.First(x => x.Contains("Path=")).Split(new string[] { "=" }, StringSplitOptions.None)[1];
string prof_dir = System.IO.Path.Combine(firefox, location);
return prof_dir;
}
}
}
return "";
}
}
}
您可以读出以下ini文件,其中包含每个firefox配置文件的配置文件名称:
"C:\Users\Username\AppData\Roaming\Mozilla\Firefox\profiles.ini"
您好,在浏览器 url 窗口中查看历史记录 输入ctrl h
输入 ctrl Shift j
输入windowRoot.ownerGlobal[0].location.href
复制新窗口打开的网址输入
如果无法进入 windowRoot.. 控制台日志未显示,请按照以下步骤操作 在 Firefox 中,console.log 没有显示任何内容
在 Firefox 中转到 chrome://browser/content/places/historySidebar.xhtml
单击 Windows“开始”按钮,然后在“开始”菜单底部的搜索框中键入
%APPDATA%\Mozilla\Firefox\Profiles\
,无需按 Enter 键。配置文件列表将出现在“开始”菜单的顶部。