Skip to content

Commit

Permalink
SLBr 2022.3.20.0 Code
Browse files Browse the repository at this point in the history
  • Loading branch information
SLT-World committed Mar 20, 2022
1 parent 73bc36f commit 3dc5c31
Show file tree
Hide file tree
Showing 43 changed files with 1,267 additions and 432 deletions.
6 changes: 3 additions & 3 deletions SLBr/SLBr/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>
2 changes: 1 addition & 1 deletion SLBr/SLBr/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using System;
using System.Collections.Generic;
using System.Configuration;
Expand Down
37 changes: 33 additions & 4 deletions SLBr/SLBr/Favourite.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SLBr
{
public class Favourite
public class Favourite : INotifyPropertyChanged
{
public string Name { get; set; }
public string Arguments { get; set; }
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged = delegate { };

private void RaisePropertyChanged(string Name)
{
PropertyChanged(this, new PropertyChangedEventArgs(Name));
}
#endregion

public string Name
{
get { return DName; }
set
{
DName = value;
RaisePropertyChanged("Name");
}
}
public string Arguments
{
get { return DArguments; }
set
{
DArguments = value;
RaisePropertyChanged("Arguments");
}
}

public string DName { get; set; }
public string DArguments { get; set; }
}
}
2 changes: 1 addition & 1 deletion SLBr/SLBr/FileAssociation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using Microsoft.Win32;
using System;
using System.Collections.Generic;
Expand Down
53 changes: 38 additions & 15 deletions SLBr/SLBr/Handlers/ContextMenuHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.

using CefSharp;
using CefSharp.Wpf;
Expand All @@ -22,23 +22,31 @@ public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser
{
if (!string.IsNullOrEmpty(parameters.SelectionText))
{
model.AddItem((CefMenuCommand)26501, "Search for text in new tab");
model.AddSeparator();
model.AddItem(CefMenuCommand.NotFound, "Close Menu");
/*model.AddItem(CefMenuCommand.NotFound, "Close Menu");
model.AddSeparator();
model.Clear();
model.AddItem(CefMenuCommand.Copy, "Copy");
model.AddItem((CefMenuCommand)26501, "Save as");*/
if (Utils.IsHttpScheme(parameters.SelectionText) || Utils.IsSchemeNotHttp(parameters.SelectionText))
{
//model.Clear();
model.AddItem((CefMenuCommand)26501, "Open in new tab");
model.AddSeparator();
model.AddItem(CefMenuCommand.NotFound, "Cancel");
}
else
{
model.AddItem((CefMenuCommand)26501, "Search for text in new tab");
model.AddSeparator();
model.AddItem(CefMenuCommand.NotFound, "Cancel");
/*model.AddItem(CefMenuCommand.NotFound, "Close Menu");
model.AddSeparator();
model.Clear();
model.AddItem(CefMenuCommand.Copy, "Copy");
model.AddItem((CefMenuCommand)26501, "Save as");*/
}
}
else
{
model.Remove(CefMenuCommand.Print);
model.Remove(CefMenuCommand.ViewSource);
model.AddItem(CefMenuCommand.Reload, "Refresh");
model.AddSeparator();
model.AddItem(CefMenuCommand.NotFound, "Close Menu");
model.AddSeparator();
model.AddItem((CefMenuCommand)26501, "Zoom In");
model.AddItem((CefMenuCommand)26502, "Zoom Out");
model.AddItem((CefMenuCommand)26503, "Reset Zoom Level");
Expand All @@ -59,15 +67,17 @@ public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser
model.AddItem((CefMenuCommand)26507, "Search page on SafeBrowsing");
model.AddItem((CefMenuCommand)26504, "View page source");
model.AddItem((CefMenuCommand)26505, "Inspect");
model.AddSeparator();
model.AddItem(CefMenuCommand.NotFound, "Cancel");
}
}
else
{
model.AddItem(CefMenuCommand.NotFound, "Close Menu");
model.AddSeparator();
model.Clear();
model.AddItem(CefMenuCommand.Copy, "Copy");
model.AddItem((CefMenuCommand)26501, "Save as");
model.AddSeparator();
model.AddItem(CefMenuCommand.NotFound, "Cancel");
//model.AddItem((CefMenuCommand)26502, "Open in paintbrush");
}
}
Expand All @@ -83,8 +93,21 @@ public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browse
{
if (!string.IsNullOrEmpty(SelectedText))
{
if (commandId == (CefMenuCommand)26501)
MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(string.Format(MainWindow.Instance.MainSave.Get("Search_Engine"), SelectedText.Trim().Replace(" ", "+"))));
if (Utils.IsHttpScheme(SelectedText) || Utils.IsSchemeNotHttp(SelectedText))
{
if (commandId == (CefMenuCommand)26501)
MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(SelectedText));
}
else
{
if (commandId == (CefMenuCommand)26501)
MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(string.Format(MainWindow.Instance.MainSave.Get("Search_Engine"), SelectedText.Trim().Replace(" ", "+"))));
/*model.AddItem(CefMenuCommand.NotFound, "Close Menu");
model.AddSeparator();
model.Clear();
model.AddItem(CefMenuCommand.Copy, "Copy");
model.AddItem((CefMenuCommand)26501, "Save as");*/
}
}
else
{
Expand Down
8 changes: 5 additions & 3 deletions SLBr/SLBr/Handlers/DownloadHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using CefSharp;
//using Microsoft.Win32;
using System;
Expand Down Expand Up @@ -81,11 +81,13 @@ public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser,
{
if (downloadItem.IsComplete)
{
MainWindow.Instance.DownloadProgressText.Visibility = Visibility.Collapsed;
/*MainWindow.Instance.DownloadProgressText.Visibility = Visibility.Collapsed;
MainWindow.Instance.DownloadProgressBar.Visibility = Visibility.Collapsed;
//browser.CloseBrowser(true);
MainWindow.Instance.DownloadOpenFileButton.Visibility = Visibility.Visible;
MainWindow.Instance.DownloadOpenFileButton.Tag = $"13<,>{downloadItem.FullPath}";
MainWindow.Instance.DownloadOpenFileButton.Tag = $"13<,>{downloadItem.FullPath}";*/
MainWindow.Instance.DownloadContainer.Visibility = Visibility.Collapsed;
MainWindow.Instance.Prompt($"The file \"{Path.GetFileName(downloadItem.FullPath)}\" finished downloading.", true, "Open In Explorer", $"13<,>{downloadItem.FullPath}", downloadItem.FullPath, true, "\xE896");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion SLBr/SLBr/Handlers/JSBindingHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using CefSharp;
using System;
using System.Collections.Generic;
Expand Down
40 changes: 40 additions & 0 deletions SLBr/SLBr/Handlers/JsDialogHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using CefSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SLBr
{
public class JsDialogHandler : IJsDialogHandler
{
public bool OnBeforeUnloadDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string messageText, bool isReload, IJsDialogCallback callback)
{
return false;
}

public void OnDialogClosed(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}

public bool OnJSDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
{
//Plan to override default dialog

//Remove dialog from showing
//callback.Continue(true);
//return true;

//Surpress dialog
//suppressMessage = true;
//return false;

return false;
}

public void OnResetDialogState(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}
}
}
2 changes: 1 addition & 1 deletion SLBr/SLBr/Handlers/KeyboardHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using CefSharp;
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion SLBr/SLBr/Handlers/LifeSpanHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using CefSharp;
using System;
using System.Collections.Generic;
Expand Down
4 changes: 2 additions & 2 deletions SLBr/SLBr/Handlers/RequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using CefSharp;
using System;
using System.Collections.Generic;
Expand All @@ -24,7 +24,7 @@ public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFr
{
if (request.Url.Contains("roblox.com"))
return true;
if ((isRedirect || userGesture || frame.IsMain) && !Utils.IsSystemUrl(request.Url) && !Utils.IsProgramUrl(request.Url))
if (Utils.CanCheck(request.TransitionType) && !Utils.IsSystemUrl(request.Url) && !Utils.IsProgramUrl(request.Url))//(isRedirect || userGesture || frame.IsMain)
{
string Response = MainWindow.Instance._SafeBrowsing.Response(request.Url.Replace("https://googleweblight.com/?lite_url=", ""));
Utils.SafeBrowsing.ThreatType _ThreatType = Utils.CheckForInternetConnection() ? MainWindow.Instance._SafeBrowsing.GetThreatType(Response) : Utils.SafeBrowsing.ThreatType.Unknown;
Expand Down
15 changes: 14 additions & 1 deletion SLBr/SLBr/Handlers/ResourceRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright © 2022 SLT World. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
// Use of this source code is governed by a GNU license that can be found in the LICENSE file.
using CefSharp;
using Newtonsoft.Json.Linq;
using System;
Expand Down Expand Up @@ -37,6 +37,19 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,

public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
/*try
{
if (Utils.CanCheck(request.TransitionType))
{
if (Utils.CleanUrl(request.Url).Contains("facebook.com"))
request.SetHeaderByName("user-agent", MainWindow.Instance.UserAgent.Replace($"Chromium", "Chrome"), true);
else if (Utils.CleanUrl(request.Url).Contains("web.whatsapp.com"))
request.SetHeaderByName("user-agent", MainWindow.Instance.UserAgent.Replace($"Chromium", "Chrome"), true);
else if (Utils.CleanUrl(request.Url).Contains("mail.google.com") || Utils.CleanUrl(request.Url).Contains("web.whatsapp.com"))
request.SetHeaderByName("user-agent", MainWindow.Instance.UserAgent.Replace($"SLBr {MainWindow.Instance.ReleaseVersion}", "").Replace($"Chromium", "Chrome"), true);
}
}
catch { }*/
//Chrome Web Store Experiment
//request.SetHeaderByName("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 Edg/98.0.1108.62", false);
//request.SetHeaderByName("sec-ch-ua", "\" Not A; Brand\";v=\"99\", \"Chromium\";v=\"98\", \"Microsoft Edge\";v=\"98\"", false);
Expand Down
Loading

0 comments on commit 3dc5c31

Please sign in to comment.