diff --git a/source/IEBookmarks.cs b/source/IEBookmarks.cs new file mode 100644 index 0000000..0591848 --- /dev/null +++ b/source/IEBookmarks.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Wox.Plugin.BrowserBookmark +{ + class IEBookmarks + { + public static List GetBookmarks() + { + List bookmarks = new List(); + string path = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); + foreach (var enumerateFile in Directory.GetFiles(path, "*", SearchOption.AllDirectories)) + { + Bookmark bookmark = GetBookmark(enumerateFile); + if (bookmark != null) + { + bookmarks.Add(bookmark); + } + } + + return bookmarks; + } + + private static Bookmark GetBookmark(string path) + { + FileInfo fileInfo = new FileInfo(path); + const string keyName = "URL="; + foreach (var readLine in File.ReadLines(path)) + { + if (readLine.StartsWith(keyName)) + { + string url = readLine.Substring(keyName.Length); + if (string.IsNullOrEmpty(url)) + { + continue; + } + + return new Bookmark() + { + Name = fileInfo.Name, + Url = readLine.Substring(keyName.Length), + }; + } + } + + return null; + } + + } +} diff --git a/source/Main.cs b/source/Main.cs index f0a595f..cc2bf23 100644 --- a/source/Main.cs +++ b/source/Main.cs @@ -24,7 +24,9 @@ public void Init(PluginInitContext context) cachedBookmarks.AddRange(mozBookmarks.GetBookmarks()); // Add Chrome bookmarks cachedBookmarks.AddRange(chromeBookmarks.GetBookmarks()); - + // Add IE bookmarks + cachedBookmarks.AddRange(IEBookmarks.GetBookmarks()); + cachedBookmarks = cachedBookmarks.Distinct().ToList(); } diff --git a/source/Wox.Plugin.BrowserBookmark.csproj b/source/Wox.Plugin.BrowserBookmark.csproj index 001b511..87e8ba5 100644 --- a/source/Wox.Plugin.BrowserBookmark.csproj +++ b/source/Wox.Plugin.BrowserBookmark.csproj @@ -53,6 +53,7 @@ +