From 2ce3349fb6e5b1d3cb2ef1843995a2ae63c7c260 Mon Sep 17 00:00:00 2001 From: digitalnyc1 <32007357+digitalnyc1@users.noreply.github.com> Date: Sat, 4 Feb 2023 17:36:11 +0000 Subject: [PATCH] Open web links in browser. --- Core/Command.cs | 1 + Forms/FormMain.cs | 8 ++++++++ Lists/Config.cs | 28 +++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Core/Command.cs b/Core/Command.cs index ed898478..42b3f8d0 100644 --- a/Core/Command.cs +++ b/Core/Command.cs @@ -2891,6 +2891,7 @@ private void ListSettings() EchoText("checkforupdates=" + oGlobals.Config.CheckForUpdates.ToString() + System.Environment.NewLine); EchoText("autoupdate=" + oGlobals.Config.AutoUpdate.ToString() + System.Environment.NewLine); EchoText("automapperalpha=" + oGlobals.Config.AutoMapperAlpha.ToString() + System.Environment.NewLine); + EchoText("weblinksafety=" + oGlobals.Config.bWebLinkSafety.ToString() + System.Environment.NewLine); } private void ListColors() diff --git a/Forms/FormMain.cs b/Forms/FormMain.cs index 7698b4c3..f965ba77 100644 --- a/Forms/FormMain.cs +++ b/Forms/FormMain.cs @@ -7901,6 +7901,14 @@ private void FormSkin_LinkClicked(string link, LinkClickedEventArgs e) TextBoxInput_SendText(m_oGlobals.ParseGlobalVars(sLink)); TextBoxInput.Focus(); } + if (link.StartsWith("http://") || link.StartsWith("https://")) + { + if (m_oGlobals.Config.bWebLinkSafety) + { + link = "https://www.play.net/bounce/redirect.asp?URL=" + link; + } + Utility.OpenBrowser(link); + } } private void FormMain_SizeChange(object sender, EventArgs e) diff --git a/Lists/Config.cs b/Lists/Config.cs index 396c5ed8..094c308f 100644 --- a/Lists/Config.cs +++ b/Lists/Config.cs @@ -48,6 +48,7 @@ public class Config public string sConfigDirProfile = "Config"; public bool bShowLinks = false; public string sLogDir = "Logs"; + public bool bWebLinkSafety = true; public bool PromptBreak { get; set; } = true; public bool PromptForce { get; set; } = true; @@ -401,6 +402,7 @@ public bool Save(string sFileName = "settings.cfg") oStreamWriter.WriteLine("#config {usertimeout} {" + iUserActivityTimeout + "}"); oStreamWriter.WriteLine("#config {usertimeoutcommand} {" + sUserActivityCommand + "}"); oStreamWriter.WriteLine("#config {showlinks} {" + bShowLinks + "}"); + oStreamWriter.WriteLine("#config {weblinksafety} {" + bWebLinkSafety + "}"); oStreamWriter.WriteLine($"#config {{rubypath}} {{{RubyPath}}}"); oStreamWriter.WriteLine($"#config {{cmdpath}} {{{CmdPath}}}"); oStreamWriter.WriteLine($"#config {{lichpath}} {{{LichPath}}}"); @@ -1151,6 +1153,30 @@ public List SetSetting(string sKey, string sValue = "", bool bShowExcept break; } + + case "weblinksafety": + { + var switchExpr13 = sValue.ToLower(); + switch (switchExpr13) + { + case "on": + case "true": + case "1": + { + bWebLinkSafety = true; + break; + } + + default: + { + bWebLinkSafety = false; + break; + } + } + + break; + } + default: throw new Exception($"Config {switchExpr} was not recognized."); } @@ -1165,4 +1191,4 @@ public List SetSetting(string sKey, string sValue = "", bool bShowExcept } } } -} \ No newline at end of file +}