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

Open web links in browser #149

Merged
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
1 change: 1 addition & 0 deletions Core/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 27 additions & 1 deletion Lists/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}}}");
Expand Down Expand Up @@ -1151,6 +1153,30 @@ public List<string> 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.");
}
Expand All @@ -1165,4 +1191,4 @@ public List<string> SetSetting(string sKey, string sValue = "", bool bShowExcept
}
}
}
}
}