Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 1cef8d8

Browse files
committed
Added search divert
1 parent 9cf383e commit 1cef8d8

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

EdgeDeflector/Program.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Security.Principal;
55
using System.Text.RegularExpressions;
6+
using System.Windows.Forms;
67

78
namespace EdgeDeflector
89
{
@@ -26,6 +27,21 @@ private static void ElevatePermissions()
2627

2728
private static void RegisterProtocolHandler()
2829
{
30+
RegistryKey engine_key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Clients\EdgeUriDeflector", true);
31+
if (engine_key == null)
32+
{
33+
engine_key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Clients\EdgeUriDeflector", true);
34+
}
35+
36+
DialogResult res = MessageBox.Show("Would you like to divert Bing to a different search engine?", "Edge Deflector",MessageBoxButtons.YesNo);
37+
if(res==DialogResult.Yes)
38+
{
39+
DialogResult res2 = MessageBox.Show("Press Yes for Google and No for DuckDuckGo", "Edge Deflector", MessageBoxButtons.YesNo);
40+
if (res2 == DialogResult.Yes) engine_key.SetValue("SearchEngine", "Google");
41+
else engine_key.SetValue("SearchEngine", "DuckDuckGo");
42+
}
43+
else engine_key.SetValue("SearchEngine", "Bing");
44+
2945
RegistryKey uriclass_key = Registry.ClassesRoot.OpenSubKey("EdgeUriDeflector", true);
3046
if (uriclass_key == null)
3147
{
@@ -110,11 +126,30 @@ static bool IsMsEdgeUri(string uri)
110126

111127
static string RewriteMsEdgeUriSchema(string uri)
112128
{
129+
RegistryKey engine_key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Clients\EdgeUriDeflector", true);
130+
131+
string engine = (string) engine_key.GetValue("SearchEngine");
113132
string msedge_protocol_pattern = "^microsoft-edge:/*";
114133

115134
Regex rgx = new Regex(msedge_protocol_pattern);
116135
string new_uri = rgx.Replace(uri, string.Empty);
117136

137+
if (engine == "Bing") ;
138+
else if (engine == "Google")
139+
{
140+
int index = new_uri.IndexOf("&");
141+
if (index > 0)
142+
new_uri = new_uri.Substring(0, index);
143+
new_uri = new_uri.Replace("bing.com/search?q=", "google.com/search?q=");
144+
}
145+
else if (engine == "DuckDuckGo")
146+
{
147+
int index = new_uri.IndexOf("&");
148+
if (index > 0)
149+
new_uri = new_uri.Substring(0, index);
150+
new_uri = new_uri.Replace("bing.com/search?q=", "duckduckgo.com/?q=");
151+
}
152+
118153
if (IsHttpUri(new_uri))
119154
{
120155
return new_uri;

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
*EdgeDeflector* is a small helper application that intercepts URIs that force-open web links in Microsoft Edge and redirects it to the system’s default web browser. This allows you to use Windows features like the Cortana assistant and built-in help links with the browser of your choice instead of being forced to use Microsoft Edge.
44

5+
It can also convert Bing searches to other engines. Currently, Google and DuckDuckGo are supported.
6+
57
You’ll never see EdgeDeflector ever again after installing it. It does its thing transparently in the background and only runs when a link needs to be deflected away from Microsoft Edge.
68

79
System requirements: Windows 10, and your favorite web browser.

0 commit comments

Comments
 (0)