Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛫 Version 1.3.3 #26

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
This issue form is for reporting bugs only!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: >-
A clear and concise description of the bug.
validations:
required: true
- type: dropdown
id: client
attributes:
label: Channel
multiple: false
description: Which Edge channel do you use?
options:
- Stable (default)
- Beta
- Dev
- Canary
validations:
required: true
- type: dropdown
id: browser
attributes:
label: Search Engine
multiple: false
description: Which search engine do you use?
options:
- Google
- Bing
- DuckDuckGo
- Yahoo
- Yandex
- Ecosia
- Ask
- Qwant
- Perplexity
- Others
validations:
required: true
- type: textarea
id: custom-search-engine
attributes:
label: If you selected “Others”, what is the request URL?
description: >-
You can find it in the registry under "HKEY_LOCAL_MACHINE\SOFTWARE\valnoxy\GoAwayEdge\CustomQueryUrl".
validations:
required: false
- type: textarea
id: repro-steps
attributes:
label: How to reproduce
description: >-
Minimal and precise steps to reproduce this bug.
validations:
required: true
- type: textarea
id: additional-info
attributes:
label: Additional information
description: |
Please attach the installation log using the field below. The log file is located under “C:\Users\Username\AppData\Local\Temp\GoAwayEdge\Logs”.

You may also include any additional information, screenshots, or files that helpful in describing the issue.
188 changes: 95 additions & 93 deletions GoAwayEdge/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ namespace GoAwayEdge
public partial class App
{
private static string? _url;
public static bool Debug = false;

public void Application_Startup(object sender, StartupEventArgs e)
{
#if DEBUG
Debug = true;
#endif
// Initialize the logging system
Logging.Initialize();

// Load Language
LocalizationManager.LoadLanguage();

Expand Down Expand Up @@ -64,8 +63,6 @@ public void Application_Startup(object sender, StartupEventArgs e)
{
if (args.Contains("-ToastActivated")) // Clicked on notification, ignore it.
Environment.Exit(0);
if (args.Contains("-debug"))
Debug = true;
if (args.Contains("-s")) // Silent Installation
{
foreach (var arg in args)
Expand Down Expand Up @@ -114,18 +111,32 @@ public void Application_Startup(object sender, StartupEventArgs e)

// Check for app update
var updateAvailable = Updater.CheckForAppUpdate();

var updateSkipped = RegistryConfig.GetKey("SkipVersion");
if (updateAvailable == updateSkipped)
Environment.Exit(0);

if (!string.IsNullOrEmpty(updateAvailable))
{
var updateMessage = LocalizationManager.LocalizeValue("NewUpdateAvailable", updateAvailable);
var remindMeLaterBtn = LocalizationManager.LocalizeValue("RemindMeLater");
var installUpdateBtn = LocalizationManager.LocalizeValue("InstallUpdate");
var skipUpdateUpdateBtn = LocalizationManager.LocalizeValue("SkipUpdate");

var updateDialog = new MessageUi("GoAwayEdge", updateMessage, installUpdateBtn, remindMeLaterBtn, true);
var updateDialog = new MessageUi("GoAwayEdge", updateMessage, installUpdateBtn, remindMeLaterBtn, skipUpdateUpdateBtn, true);
updateDialog.ShowDialog();
if (updateDialog.Summary == "Btn1")
switch (updateDialog.Summary)
{
var updateResult = Updater.UpdateClient();
if (!updateResult) Environment.Exit(0);
case "Btn1":
{
var updateResult = Updater.UpdateClient();
if (!updateResult) Environment.Exit(0);
break;
}
case "Btn3":
RegistryConfig.SetKey("SkipVersion", updateAvailable);
Environment.Exit(0);
break;
}
}

Expand Down Expand Up @@ -219,119 +230,98 @@ public static void RunParser(string[] args)
{
var argumentJoin = string.Join(" ", args);
var isFile = false;
var isCopilot = false;
var parsedData = false;
var ignoreStartup = false;
var collectSingleArgument = false;
var singleArgument = string.Empty;
var p = new Process();
p.StartInfo.UseShellExecute = true;
p.StartInfo.RedirectStandardOutput = false;
#if DEBUG
var w = new MessageUi("GoAwayEdge",
$"The following args are redirected (CTRL+C to copy):\n\n{argumentJoin}", "OK", isMainThread: true);
w.ShowDialog();
#endif
Console.WriteLine("Command line args:\n\n" + argumentJoin + "\n", ConsoleColor.Gray);

if (Debug)
{
var w = new MessageUi("GoAwayEdge",
$"The following args are redirected (CTRL+C to copy):\n\n{argumentJoin}", "OK", null, true);
w.ShowDialog();
}

// Filter command line args
foreach (var arg in args)
{
if (collectSingleArgument)
{
// Concatenate all remaining arguments into a single string
singleArgument += (singleArgument.Length > 0 ? " " : "") + arg;
continue;
}

// Check for Copilot
if (arg.Contains("microsoft-edge://?ux=copilot&tcp=1&source=taskbar")
|| arg.Contains("microsoft-edge:///?ux=copilot&tcp=1&source=taskbar"))
if (arg.Contains("microsoft-edge:"))
{
_url = arg;
isCopilot = true;
break;
}

// User want to parse data
if (arg.Contains("microsoft-edge:"))
if (collectSingleArgument)
{
_url = ParseUrl(arg);
parsedData = true;
break;
// Concatenate all remaining arguments into a single string
singleArgument += (singleArgument.Length > 0 ? " " : "") + arg;
continue;
}

// Check if the argument contains a file (like PDF)
if (arg.Contains("msedge.exe"))
isFile = false;
else if (File.Exists(arg))
isFile = true;

// Check for blacklisted arguments
if (arg.Contains("--no-startup-window")
|| arg.Contains("--profile-directory"))
ignoreStartup = true;

// Check for the single argument flag
if (arg == "--single-argument")
{
collectSingleArgument = true;
}
}

// Validate single argument
if (File.Exists(singleArgument))
isFile = true;
if (!args.Contains("--profile-directory") && !ContainsParsedData(args) && args.Length != 1) continue; // Start Edge (default browser on this system)

// Open Edge normally
if ((!parsedData || isCopilot || isFile || args.Contains("--profile-directory")) && !ignoreStartup)
{
if (Debug)
{
if (isCopilot)
{
var copilotMessageUi = new MessageUi("GoAwayEdge",
$"Opening Windows Copilot with following url:\n{_url}", "OK", null, true);
copilotMessageUi.ShowDialog();
}
else
{
var messageUi = new MessageUi("GoAwayEdge",
"Microsoft Edge will now start normally via IFEO application.", "OK", null, true);
messageUi.ShowDialog();
}
}
var parsedArgs = args.Skip(1);
#if DEBUG
var messageUi = new MessageUi("GoAwayEdge",
"Microsoft Edge will now start normally via IFEO application.", "OK", isMainThread: true);
messageUi.ShowDialog();
#endif
var parsedArgs = args.Skip(2);
p.StartInfo.FileName = FileConfiguration.NonIfeoPath;
p.StartInfo.Arguments = string.Join(" ", parsedArgs);
p.Start();
Environment.Exit(0);
}

// Open default Browser with parsed data
if (parsedData)
// Validate single argument
if (File.Exists(singleArgument))
isFile = true;

// Open URL in default browser
if (_url != null)
{
if (Debug)
// Windows Copilot
if (_url.Contains("microsoft-edge://?ux=copilot&tcp=1&source=taskbar")
|| _url.Contains("microsoft-edge:///?ux=copilot&tcp=1&source=taskbar"))
{
p.StartInfo.FileName = FileConfiguration.NonIfeoPath;
p.StartInfo.Arguments = _url;
Console.WriteLine($"Opening Windows Copilot with following url:\n{_url}", ConsoleColor.Gray);
#if DEBUG
var copilotMessageUi = new MessageUi("GoAwayEdge",
$"Opening Windows Copilot with following url:\n{_url}", "OK", isMainThread: true);
copilotMessageUi.ShowDialog();
#endif
}
else
{
var parsed = ParseUrl(_url);
Console.WriteLine("Opening URL in default browser:\n\n" + parsed + "\n", ConsoleColor.Gray);
#if DEBUG
var defaultUrlMessageUi = new MessageUi("GoAwayEdge",
"Opening URL in default browser:\n\n" + _url + "\n", "OK", null, true);
"Opening URL in default browser:\n\n" + parsed + "\n", "OK", isMainThread: true);
defaultUrlMessageUi.ShowDialog();
#endif
p.StartInfo.FileName = parsed;
p.StartInfo.Arguments = "";
}
p.StartInfo.FileName = _url;
p.StartInfo.Arguments = "";
p.Start();
Environment.Exit(0);
}

if (ignoreStartup)
// Is File
else if (isFile)
{
if (Debug)
{
var defaultUrlMessageUi = new MessageUi("GoAwayEdge",
"Edge was called with a blacklisted argument. Edge won't be launched.", "OK", null, true);
defaultUrlMessageUi.ShowDialog();
}
Environment.Exit(0);
p.StartInfo.FileName = FileConfiguration.NonIfeoPath;
p.StartInfo.Arguments = $"--single-argument {singleArgument}";
#if DEBUG
var copilotMessageUi = new MessageUi("GoAwayEdge",
$"Opening '{singleArgument}' with Edge.", "OK", isMainThread: true);
copilotMessageUi.ShowDialog();
#endif
p.Start();
}
}

Expand Down Expand Up @@ -365,6 +355,19 @@ private static SearchEngine ParseSearchEngine(string argument)
};
}

private static bool ContainsParsedData(IEnumerable<string> args)
{
var contains = false;
var engineUrl = DefineEngine(Configuration.Search);

foreach (var arg in args)
{
if (arg.Contains(engineUrl))
contains = true;
}
return contains;
}

private static string ParseUrl(string encodedUrl)
{
// Remove URI handler with url argument prefix
Expand All @@ -387,12 +390,11 @@ private static string ParseUrl(string encodedUrl)
// Replace Search Engine
encodedUrl = encodedUrl.Replace("https://www.bing.com/search?q=", DefineEngine(Configuration.Search));

if (Debug)
{
var uriMessageUi = new MessageUi("GoAwayEdge",
"New Uri: " + encodedUrl, "OK", null, true);
uriMessageUi.ShowDialog();
}
#if DEBUG
var uriMessageUi = new MessageUi("GoAwayEdge",
"New Uri: " + encodedUrl, "OK", isMainThread: true);
uriMessageUi.ShowDialog();
#endif
var uri = new Uri(encodedUrl);
return uri.ToString();
}
Expand Down
Loading