mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-11 05:52:19 +02:00
Add bookmarks support for Chromium / ChromeSxS and multiple profiles
This commit is contained in:
@@ -55,16 +55,14 @@ namespace Wox.Plugin.System
|
|||||||
{
|
{
|
||||||
bookmarks.Clear();
|
bookmarks.Clear();
|
||||||
LoadChromeBookmarks();
|
LoadChromeBookmarks();
|
||||||
|
|
||||||
bookmarks = bookmarks.Distinct().ToList();
|
bookmarks = bookmarks.Distinct().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadChromeBookmarks()
|
private void ParseChromeBookmarks(String path, string source)
|
||||||
{
|
{
|
||||||
String platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
if (!File.Exists(path)) return;
|
||||||
string path = global::System.IO.Path.Combine(platformPath, @"Google\Chrome\User Data\Default\Bookmarks");
|
|
||||||
|
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
string all = File.ReadAllText(path);
|
string all = File.ReadAllText(path);
|
||||||
Regex nameRegex = new Regex("\"name\": \"(?<name>.*?)\"");
|
Regex nameRegex = new Regex("\"name\": \"(?<name>.*?)\"");
|
||||||
MatchCollection nameCollection = nameRegex.Matches(all);
|
MatchCollection nameCollection = nameRegex.Matches(all);
|
||||||
@@ -95,11 +93,30 @@ namespace Wox.Plugin.System
|
|||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
Url = url,
|
Url = url,
|
||||||
Source = "Chrome"
|
Source = source
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadChromeBookmarks(string path, string name)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(path)) return;
|
||||||
|
var paths = Directory.GetDirectories(path);
|
||||||
|
|
||||||
|
foreach (var profile in paths)
|
||||||
|
{
|
||||||
|
if (File.Exists(Path.Combine(profile, "Bookmarks")))
|
||||||
|
ParseChromeBookmarks(Path.Combine(profile, "Bookmarks"), name + (Path.GetFileName(profile) == "Default" ? "" : (" (" + Path.GetFileName(profile) + ")")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadChromeBookmarks()
|
||||||
|
{
|
||||||
|
String platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||||
|
LoadChromeBookmarks(Path.Combine(platformPath, @"Google\Chrome\User Data"), "Google Chrome");
|
||||||
|
LoadChromeBookmarks(Path.Combine(platformPath, @"Google\Chrome SxS\User Data"), "Google Chrome Canary");
|
||||||
|
LoadChromeBookmarks(Path.Combine(platformPath, @"Chromium\User Data"), "Chromium");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String DecodeUnicode(String dataStr)
|
private String DecodeUnicode(String dataStr)
|
||||||
|
|||||||
Reference in New Issue
Block a user