From 98df42aefb465619efb1a1097052da0237193a88 Mon Sep 17 00:00:00 2001
From: Dantes Fernandes <41308047+dantesg@users.noreply.github.com>
Date: Sat, 29 Apr 2023 15:03:06 +1200
Subject: [PATCH 1/3] Add Profile support on Bookmarks for Edge browser
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 8 +++++
.../SharedCommands/SearchWeb.cs | 14 ++++++--
Flow.Launcher/PublicAPIInstance.cs | 16 +++++++--
.../ChromiumBookmarkLoader.cs | 2 +-
.../Main.cs | 35 ++++++++++++-------
5 files changed, 55 insertions(+), 20 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index d9cf68469ec..b2ceaea09c6 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -242,6 +242,14 @@ public interface IPublicAPI
///
public void OpenUrl(Uri url, bool? inPrivate = null);
+ ///
+ /// Opens the URL with the given Uri object.
+ /// The browser and mode used is based on what's configured in Flow's default browser settings.
+ /// Non-C# plugins can use this method.
+ ///
+ /// Optional Profile name
+ public void OpenUrl(string url, bool hasProfile, string profileArg);
+
///
/// Opens the URL with the given string.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
diff --git a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
index 6588132b940..34e92165eed 100644
--- a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
+++ b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
@@ -80,7 +80,7 @@ public static void NewBrowserWindow(this string url, string browserPath = "")
///
/// Opens search as a tab in the default browser chosen in Windows settings.
///
- public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "")
+ public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "", string profileArg = "")
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;
@@ -93,7 +93,15 @@ public static void OpenInBrowserTab(this string url, string browserPath = "", bo
if (!string.IsNullOrEmpty(browserPath))
{
psi.FileName = browserPath;
- psi.Arguments = (inPrivate ? $"{privateArg} " : "") + url;
+ if (inPrivate)
+ {
+ psi.Arguments = (inPrivate ? $"{privateArg} " : "") + url;
+ }
+ else
+ {
+ psi.Arguments = (!String.IsNullOrEmpty(profileArg) ? $"--profile-directory=\"{profileArg}\" " : "") + url;
+ }
+
}
else
{
@@ -118,4 +126,4 @@ public static void NewTabInBrowser(this string url, string browserPath = "")
OpenInBrowserTab(url, browserPath);
}
}
-}
\ No newline at end of file
+}
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 636699ad02e..2fdc9731fda 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -215,7 +215,7 @@ public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null
explorer.Start();
}
- private void OpenUri(Uri uri, bool? inPrivate = null)
+ private void OpenUri(Uri uri, bool? inPrivate = null, string profileArg = "")
{
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
@@ -225,7 +225,7 @@ private void OpenUri(Uri uri, bool? inPrivate = null)
if (browserInfo.OpenInTab)
{
- uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
+ uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg, profileArg);
}
else
{
@@ -243,7 +243,17 @@ private void OpenUri(Uri uri, bool? inPrivate = null)
return;
}
}
-
+ public void OpenUrl(string url, bool hasProfile, string profileArg = "")
+ {
+ if (hasProfile)
+ {
+ OpenUri(new Uri(url), profileArg: profileArg);
+ }
+ else
+ {
+ OpenUri(new Uri(url));
+ }
+ }
public void OpenUrl(string url, bool? inPrivate = null)
{
OpenUri(new Uri(url), inPrivate);
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
index e20a476c51f..6c56935516c 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs
@@ -23,7 +23,7 @@ protected List LoadBookmarks(string browserDataPath, string name)
Main.RegisterBookmarkFile(bookmarkPath);
- var source = name + (Path.GetFileName(profile) == "Default" ? "" : $" ({Path.GetFileName(profile)})");
+ var source = name + $" ({Path.GetFileName(profile)})";
bookmarks.AddRange(LoadBookmarksFromFile(bookmarkPath, source));
}
return bookmarks;
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
index d9a719272b5..8cf84891312 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
@@ -48,15 +48,10 @@ public List Query(Query query)
var returnList = cachedBookmarks.Select(c => new Result()
{
Title = c.Name,
- SubTitle = c.Url,
+ SubTitle = !String.IsNullOrEmpty(c.Source) ? $"{c.Source}: {c.Url}" : c.Url,
IcoPath = @"Images\bookmark.png",
Score = BookmarkLoader.MatchProgram(c, param).Score,
- Action = _ =>
- {
- context.API.OpenUrl(c.Url);
-
- return true;
- },
+ Action = _ => ActionOpenUrl(_, c),
ContextData = new BookmarkAttributes
{
Url = c.Url
@@ -69,14 +64,10 @@ public List Query(Query query)
return cachedBookmarks.Select(c => new Result()
{
Title = c.Name,
- SubTitle = c.Url,
+ SubTitle = !String.IsNullOrEmpty(c.Source) ? $"{c.Source}: {c.Url}" : c.Url,
IcoPath = @"Images\bookmark.png",
Score = 5,
- Action = _ =>
- {
- context.API.OpenUrl(c.Url);
- return true;
- },
+ Action = _ => ActionOpenUrl(_, c),
ContextData = new BookmarkAttributes
{
Url = c.Url
@@ -85,6 +76,24 @@ public List Query(Query query)
}
}
+ private static bool ActionOpenUrl(ActionContext _, Bookmark c)
+ {
+ string profileArg = GetProfileArg(c);
+ context.API.OpenUrl(c.Url, true, profileArg);
+ return true;
+ }
+
+ private static string GetProfileArg(Bookmark c)
+ {
+ try
+ {
+ return c.Source.Split('(', ')')[1];
+ }
+ catch (Exception e)
+ {
+ return "";
+ }
+ }
private static Channel refreshQueue = Channel.CreateBounded(1);
From 2fd646979c4047d112705fc7b2acf7c01bf302e9 Mon Sep 17 00:00:00 2001
From: Vic <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Sat, 13 May 2023 00:20:17 +0800
Subject: [PATCH 2/3] Add additional args to OpenUri()
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 12 ++-------
.../SharedCommands/SearchWeb.cs | 24 +++++++----------
Flow.Launcher/PublicAPIInstance.cs | 26 ++++++-------------
3 files changed, 19 insertions(+), 43 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index b2ceaea09c6..a805dc93b38 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -240,22 +240,14 @@ public interface IPublicAPI
/// Opens the URL with the given Uri object.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
///
- public void OpenUrl(Uri url, bool? inPrivate = null);
-
- ///
- /// Opens the URL with the given Uri object.
- /// The browser and mode used is based on what's configured in Flow's default browser settings.
- /// Non-C# plugins can use this method.
- ///
- /// Optional Profile name
- public void OpenUrl(string url, bool hasProfile, string profileArg);
+ public void OpenUrl(Uri url, bool? inPrivate = null, string additionalArgs = "");
///
/// Opens the URL with the given string.
/// The browser and mode used is based on what's configured in Flow's default browser settings.
/// Non-C# plugins should use this method.
///
- public void OpenUrl(string url, bool? inPrivate = null);
+ public void OpenUrl(string url, bool? inPrivate = null, string additionalArgs = "");
///
/// Opens the application URI with the given Uri object, e.g. obsidian://search-query-example
diff --git a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
index 34e92165eed..15a8c75fad4 100644
--- a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
+++ b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
@@ -1,4 +1,4 @@
-using Microsoft.Win32;
+using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
@@ -35,7 +35,7 @@ private static string GetDefaultBrowserPath()
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome.
///
- public static void OpenInBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "")
+ public static void OpenInBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "", string additionalArgs = "")
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;
@@ -47,9 +47,10 @@ public static void OpenInBrowserWindow(this string url, string browserPath = "",
.Last();
var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath;
-
// Internet Explorer will open url in new browser window, and does not take the --new-window parameter
- var browserArguements = (browserExecutableName == "iexplore.exe" ? "" : "--new-window ") + (inPrivate ? $"{privateArg} " : "") + url;
+ var newWindowArg = browserExecutableName == "iexplore.exe" ? "" : "--new-window ";
+ privateArg = inPrivate && !string.IsNullOrEmpty(privateArg) ? $"{privateArg} " : "";
+ var browserArguements = $"{newWindowArg}{privateArg}{additionalArgs} {url}";
var psi = new ProcessStartInfo
{
@@ -80,10 +81,10 @@ public static void NewBrowserWindow(this string url, string browserPath = "")
///
/// Opens search as a tab in the default browser chosen in Windows settings.
///
- public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "", string profileArg = "")
+ public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "", string additionalArgs = "")
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;
-
+
var psi = new ProcessStartInfo()
{
UseShellExecute = true
@@ -93,15 +94,8 @@ public static void OpenInBrowserTab(this string url, string browserPath = "", bo
if (!string.IsNullOrEmpty(browserPath))
{
psi.FileName = browserPath;
- if (inPrivate)
- {
- psi.Arguments = (inPrivate ? $"{privateArg} " : "") + url;
- }
- else
- {
- psi.Arguments = (!String.IsNullOrEmpty(profileArg) ? $"--profile-directory=\"{profileArg}\" " : "") + url;
- }
-
+ privateArg = inPrivate && !string.IsNullOrEmpty(privateArg) ? $"{privateArg} " : "";
+ psi.Arguments = $"{privateArg}{additionalArgs} {url}";
}
else
{
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 2fdc9731fda..84fbbf01bcf 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -215,7 +215,7 @@ public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null
explorer.Start();
}
- private void OpenUri(Uri uri, bool? inPrivate = null, string profileArg = "")
+ private void OpenUri(Uri uri, bool? inPrivate = null, string additionalArgs = "")
{
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
@@ -225,11 +225,11 @@ private void OpenUri(Uri uri, bool? inPrivate = null, string profileArg = "")
if (browserInfo.OpenInTab)
{
- uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg, profileArg);
+ uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg, additionalArgs);
}
else
{
- uri.AbsoluteUri.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
+ uri.AbsoluteUri.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg, additionalArgs);
}
}
else
@@ -243,25 +243,15 @@ private void OpenUri(Uri uri, bool? inPrivate = null, string profileArg = "")
return;
}
}
- public void OpenUrl(string url, bool hasProfile, string profileArg = "")
- {
- if (hasProfile)
- {
- OpenUri(new Uri(url), profileArg: profileArg);
- }
- else
- {
- OpenUri(new Uri(url));
- }
- }
- public void OpenUrl(string url, bool? inPrivate = null)
+
+ public void OpenUrl(string url, bool? inPrivate = null, string additionalArgs = "")
{
- OpenUri(new Uri(url), inPrivate);
+ OpenUri(new Uri(url), inPrivate, additionalArgs);
}
- public void OpenUrl(Uri url, bool? inPrivate = null)
+ public void OpenUrl(Uri url, bool? inPrivate = null, string additionalArgs = "")
{
- OpenUri(url, inPrivate);
+ OpenUri(url, inPrivate, additionalArgs);
}
public void OpenAppUri(string appUri)
From 56c2eb02667b13105b2c7f5f2f610466d27afb9b Mon Sep 17 00:00:00 2001
From: Vic <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Sat, 13 May 2023 00:53:44 +0800
Subject: [PATCH 3/3] Add word
---
.github/actions/spelling/expect.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt
index 78ae8476bc6..aedfa0804a8 100644
--- a/.github/actions/spelling/expect.txt
+++ b/.github/actions/spelling/expect.txt
@@ -95,3 +95,4 @@ keyevent
KListener
requery
vkcode
+Firefox