diff --git a/SLBr/.editorconfig b/SLBr/.editorconfig
new file mode 100644
index 0000000..f12eadd
--- /dev/null
+++ b/SLBr/.editorconfig
@@ -0,0 +1,4 @@
+[*.cs]
+
+# CS0618: Type or member is obsolete
+dotnet_diagnostic.CS0618.severity = silent
diff --git a/SLBr/SLBr.sln b/SLBr/SLBr.sln
new file mode 100644
index 0000000..6e7385c
--- /dev/null
+++ b/SLBr/SLBr.sln
@@ -0,0 +1,45 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30907.101
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{497AA70B-948C-485D-9BDC-D4079761233F}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLBr", "SLBr\SLBr.csproj", "{7816736D-3C43-4D68-9A4D-9F0825372E97}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x64.ActiveCfg = Debug|x64
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x64.Build.0 = Debug|x64
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x86.ActiveCfg = Debug|Win32
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Debug|x86.Build.0 = Debug|Win32
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x64.ActiveCfg = Release|x64
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x64.Build.0 = Release|x64
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x86.ActiveCfg = Release|Win32
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {7816736D-3C43-4D68-9A4D-9F0825372E97} = {497AA70B-948C-485D-9BDC-D4079761233F}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {7AEF2092-FFC4-4819-97A3-CC8862806680}
+ EndGlobalSection
+EndGlobal
diff --git a/SLBr/SLBr/App.config b/SLBr/SLBr/App.config
new file mode 100644
index 0000000..5754728
--- /dev/null
+++ b/SLBr/SLBr/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/App.xaml b/SLBr/SLBr/App.xaml
new file mode 100644
index 0000000..1256a79
--- /dev/null
+++ b/SLBr/SLBr/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/SLBr/SLBr/App.xaml.cs b/SLBr/SLBr/App.xaml.cs
new file mode 100644
index 0000000..cf97143
--- /dev/null
+++ b/SLBr/SLBr/App.xaml.cs
@@ -0,0 +1,117 @@
+// 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.
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Shell;
+
+namespace SLBr
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ /*[DllImport("user32.dll")]
+ private static extern bool ShowWindow(IntPtr hWnd, int cmdShow);
+ private const int SW_MAXIMIZE = 3;
+ private const int SW_SHOWNORMAL = 1;*/
+
+ //private static Mutex SingleInstanceMutex;
+
+ private void Application_Startup(object sender, StartupEventArgs e)
+ {
+ /*if (e.Args.Count() > 0)
+ {
+ MessageBox.Show("You have the latest version.");
+ Shutdown();
+ }*/
+
+ JumpTask OpenTask = new JumpTask
+ {
+ Title = "Open",
+ Arguments = "",
+ //Description = "Open SLBr",
+ CustomCategory = "Actions",
+ ApplicationPath = Assembly.GetExecutingAssembly().Location,
+ IconResourcePath = Assembly.GetExecutingAssembly().Location
+ };
+ JumpTask PrivateOpenTask = new JumpTask
+ {
+ Title = "Open in private mode",
+ Arguments = "Private",
+ //Description = "No browsing history will be saved, in memory cache will be used (Incognito)",
+ CustomCategory = "Actions",
+ ApplicationPath = Assembly.GetExecutingAssembly().Location,
+ IconResourcePath = Assembly.GetExecutingAssembly().Location
+ };
+ JumpTask DeveloperOpenTask = new JumpTask
+ {
+ Title = "Open in developer mode",
+ Arguments = "Developer",
+ //Description = "Access to developer features of SLBr and bypass the i5 processor check",
+ CustomCategory = "Actions",
+ ApplicationPath = Assembly.GetExecutingAssembly().Location,
+ IconResourcePath = Assembly.GetExecutingAssembly().Location
+ };
+ JumpTask ChromiumOpenTask = new JumpTask
+ {
+ Title = "Open in chromium mode",
+ Arguments = "Chromium",
+ //Description = "Access to developer features of SLBr and bypass the i5 processor check",
+ CustomCategory = "Actions",
+ ApplicationPath = Assembly.GetExecutingAssembly().Location,
+ IconResourcePath = Assembly.GetExecutingAssembly().Location
+ };
+ JumpTask IEOpenTask = new JumpTask
+ {
+ Title = "Open in Internet Explorer mode",
+ Arguments = "IE",
+ //Description = "Access to developer features of SLBr and bypass the i5 processor check",
+ CustomCategory = "Actions",
+ ApplicationPath = Assembly.GetExecutingAssembly().Location,
+ IconResourcePath = Assembly.GetExecutingAssembly().Location
+ };
+
+ JumpList jumpList = new JumpList();
+ jumpList.JumpItems.Add(OpenTask);
+ jumpList.JumpItems.Add(PrivateOpenTask);
+ jumpList.JumpItems.Add(DeveloperOpenTask);
+ jumpList.JumpItems.Add(ChromiumOpenTask);
+ jumpList.JumpItems.Add(IEOpenTask);
+ jumpList.ShowFrequentCategory = false;
+ jumpList.ShowRecentCategory = false;
+
+ JumpList.SetJumpList(Current, jumpList);
+
+
+ Process _Process = Process.GetCurrentProcess();
+ List Processes = Process.GetProcesses().Where(p =>
+ p.ProcessName == _Process.ProcessName && !_Process.HasExited).ToList();
+
+ int count = Processes.Count();
+
+ if (count > 1)
+ {
+ //ShowWindow(Processes[0].MainWindowHandle, SW_MAXIMIZE);
+ MessageBox.Show("An instance is already running... Relaunch the application if you think something is wrong.");//BUG, Relaunching in SLBr shows this message
+ Current.Shutdown();
+ }
+ /*bool IsNewInstance = false;
+ SingleInstanceMutex = new Mutex(true, "SLBrSLTBrowser", out IsNewInstance);
+ if (!IsNewInstance)
+ {
+ MessageBox.Show("Already an instance is running...");
+ Current.Shutdown();
+ }*/
+ }
+ }
+}
diff --git a/SLBr/SLBr/Favourite.cs b/SLBr/SLBr/Favourite.cs
new file mode 100644
index 0000000..bab64f7
--- /dev/null
+++ b/SLBr/SLBr/Favourite.cs
@@ -0,0 +1,16 @@
+// 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.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SLBr
+{
+ public class Favourite
+ {
+ public string Name { get; set; }
+ public string Arguments { get; set; }
+ }
+}
diff --git a/SLBr/SLBr/FileAssociation.cs b/SLBr/SLBr/FileAssociation.cs
new file mode 100644
index 0000000..b9b69e0
--- /dev/null
+++ b/SLBr/SLBr/FileAssociation.cs
@@ -0,0 +1,207 @@
+// 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.
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SLBr
+{
+ public class FileAssociation
+ {
+ public string Extension { get; set; }
+ public string ProgId { get; set; }
+ public string FileTypeDescription { get; set; }
+ public string ExecutableFilePath { get; set; }
+ }
+
+ public class FileAssociations
+ {
+ // needed so that Explorer windows get refreshed after the registry is updated
+ [System.Runtime.InteropServices.DllImport("Shell32.dll")]
+ private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
+
+ private const int SHCNE_ASSOCCHANGED = 0x8000000;
+ private const int SHCNF_FLUSH = 0x1000;
+
+ public static void EnsureAssociationsSet()
+ {
+ var filePath = Process.GetCurrentProcess().MainModule.FileName;
+ EnsureAssociationsSet(
+ /*new FileAssociation
+ {
+ Extension = ".htm",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ },*/
+ new FileAssociation
+ {
+ Extension = ".html",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ }
+ /*new FileAssociation
+ {
+ Extension = ".shtml",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ },
+ /*new FileAssociation
+ {
+ Extension = ".mht",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ },
+ /*new FileAssociation
+ {
+ Extension = ".mhtml",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ },
+ /*new FileAssociation
+ {
+ Extension = ".xht",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ },
+ /*new FileAssociation
+ {
+ Extension = ".xhtml",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr HTML Document",
+ ExecutableFilePath = filePath
+ },
+ new FileAssociation
+ {
+ Extension = ".php",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr PHP Document",
+ ExecutableFilePath = filePath
+ },
+ new FileAssociation
+ {
+ Extension = ".pdf",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr PDF Document",
+ ExecutableFilePath = filePath
+ },*/
+ /*new FileAssociation
+ {
+ Extension = ".asp",
+ ProgId = "SLBr",
+ FileTypeDescription = "SLBr ASP Document",
+ ExecutableFilePath = filePath
+ },
+ new FileAssociation
+ {
+ Extension = "FTP",
+ ProgId = "SLBr",
+ FileTypeDescription = "URL:File Transfer Protocol",
+ ExecutableFilePath = filePath
+ },*/
+ /*new FileAssociation
+ {
+ Extension = "HTTP",
+ ProgId = "SLBr",
+ FileTypeDescription = "URL:HyperText Transfer Protocol",
+ ExecutableFilePath = filePath
+ },
+ new FileAssociation
+ {
+ Extension = "HTTPS",
+ ProgId = "SLBr",
+ FileTypeDescription = "URL:HyperText Transfer Protocol with Privacy",
+ ExecutableFilePath = filePath
+ }*/
+ );
+ }
+
+ public static void EnsureAssociationsSet(params FileAssociation[] associations)
+ {
+ bool madeChanges = false;
+ foreach (var association in associations)
+ {
+ madeChanges |= SetAssociation(
+ association.Extension,
+ association.ProgId,
+ association.FileTypeDescription,
+ association.ExecutableFilePath);
+ }
+
+ if (madeChanges)
+ {
+ SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero);
+ }
+ }
+
+ public static bool SetAssociation(string extension, string progId, string fileTypeDescription, string applicationFilePath)
+ {
+ /*bool madeChanges = false;
+ madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId);
+ madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription);
+ madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\shell\open\command", "\"" + applicationFilePath + "\" \"%1\"");
+ return madeChanges;*/
+ bool madeChanges = false;
+ //madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId);
+ //madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription);
+ //madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\shell\open\command", $"\"{applicationFilePath}\" %1");/*\"*//*\"*/
+ //madeChanges |= SetKeyDefaultValue($@"Software\Classes\{extension}\shell\open\command", $"\"{applicationFilePath}\" \"%1\"");
+ madeChanges |= NewSetKeyDefaultValue(".html", "SLBr");
+ return madeChanges;
+ }
+
+ private static bool NewSetKeyDefaultValue(string ExtensionName, string ApplicationName, string Value = "")
+ {
+ RegistryKey _rk = Registry.ClassesRoot.OpenSubKey(ExtensionName);
+ //string _defaultapp = _rk.GetValue("").ToString();
+ string[] _subkeys = _rk.GetSubKeyNames();
+ for (int i = 0; i < _subkeys.Length; i++)
+ {
+ if (_subkeys[i] == "OpenWithProgids")
+ {
+ RegistryKey _rkh = _rk.OpenSubKey(_subkeys[i], true);
+ _rkh.SetValue(ApplicationName, Value);
+ return true;
+ //string[] _names = _rkh.GetValueNames();
+ //for (int j = 0; j < _names.Length; j++)
+ //{
+ // if (_names[j] == "")
+ // continue;
+
+ // Microsoft.Win32.RegistryKey _rhelp = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(_names[j] + "\\shell\\open\\command");
+
+ // _ret.Add(_rhelp.GetValue("").ToString());
+ // _rhelp.Close();
+ //}
+
+ }
+ }
+ _rk.Close();
+
+ return false;
+ }
+
+ private static bool OldSetKeyDefaultValue(string keyPath, string value)
+ {
+ using (var key = Registry.CurrentUser.CreateSubKey(keyPath))
+ {
+ if (key.GetValue(null) as string != value)
+ {
+ key.SetValue(null, value);
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SLBr/SLBr/Handlers/ContextMenuHandler.cs b/SLBr/SLBr/Handlers/ContextMenuHandler.cs
new file mode 100644
index 0000000..da326f4
--- /dev/null
+++ b/SLBr/SLBr/Handlers/ContextMenuHandler.cs
@@ -0,0 +1,141 @@
+// 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.
+
+using CefSharp;
+using CefSharp.Wpf;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SLBr
+{
+ class ContextMenuHandler : IContextMenuHandler
+ {
+ public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
+ {
+ if (parameters.MediaType != ContextMenuMediaType.Image)//parameters.MediaType == ContextMenuMediaType.None
+ {
+ 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");*/
+ }
+ 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");
+ model.AddSeparator();
+ model.AddItem((CefMenuCommand)26506, "Take a screenshot");
+ model.AddSeparator();
+ IMenuModel _EditSubMenuModel = model.AddSubMenu(CefMenuCommand.NotFound, "Edit");
+ _EditSubMenuModel.AddItem(CefMenuCommand.Undo, "Undo");
+ _EditSubMenuModel.AddItem(CefMenuCommand.Redo, "Redo");
+ _EditSubMenuModel.AddSeparator();
+ _EditSubMenuModel.AddItem(CefMenuCommand.Cut, "Cut");
+ _EditSubMenuModel.AddItem(CefMenuCommand.Copy, "Copy");
+ _EditSubMenuModel.AddItem(CefMenuCommand.Paste, "Paste");
+ _EditSubMenuModel.AddItem(CefMenuCommand.Delete, "Delete");
+ _EditSubMenuModel.AddSeparator();
+ _EditSubMenuModel.AddItem(CefMenuCommand.SelectAll, "Select All");
+ model.AddSeparator();
+ model.AddItem((CefMenuCommand)26507, "Search page on SafeBrowsing");
+ model.AddItem((CefMenuCommand)26504, "View page source");
+ model.AddItem((CefMenuCommand)26505, "Inspect");
+ }
+ }
+ else
+ {
+ model.AddItem(CefMenuCommand.NotFound, "Close Menu");
+ model.AddSeparator();
+ model.Clear();
+ model.AddItem(CefMenuCommand.Copy, "Copy");
+ model.AddItem((CefMenuCommand)26501, "Save as");
+ //model.AddItem((CefMenuCommand)26502, "Open in paintbrush");
+ }
+ }
+
+ public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
+ {
+ if (commandId == CefMenuCommand.NotFound)
+ return false;
+ if (parameters.MediaType != ContextMenuMediaType.Image)//parameters.MediaType == ContextMenuMediaType.None
+ {
+ string SelectedText = parameters.SelectionText;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ 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(" ", "+"))));
+ }
+ else
+ {
+ if (commandId == (CefMenuCommand)26501)
+ MainWindow.Instance.ZoomIn();
+ else if (commandId == (CefMenuCommand)26502)
+ MainWindow.Instance.ZoomOut();
+ else if (commandId == (CefMenuCommand)26503)
+ MainWindow.Instance.ResetZoomLevel();
+ else if (commandId == (CefMenuCommand)26504)
+ MainWindow.Instance.ViewSource();
+ else if (commandId == (CefMenuCommand)26505)
+ MainWindow.Instance.DevTools();
+ else if (commandId == (CefMenuCommand)26506)
+ MainWindow.Instance.Screenshot();
+ else if (commandId == (CefMenuCommand)26507)
+ MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser($"https://transparencyreport.google.com/safe-browsing/search?url={chromiumWebBrowser.Address}"));
+ }
+ }));
+ }
+ else
+ {
+ if (commandId == CefMenuCommand.Copy)
+ Clipboard.SetText(parameters.SourceUrl);
+ else if (commandId == (CefMenuCommand)26501)
+ chromiumWebBrowser.StartDownload(parameters.SourceUrl);
+ /*else if (commandId == (CefMenuCommand)26502)
+ {
+ chromiumWebBrowser.StartDownload(parameters.SourceUrl);
+ //string DownloadPath = MainWindow.Instance.MainSave.Get("DownloadPath");
+ //string FileName = Path.Combine(DownloadPath, Path.GetFileName(parameters.SourceUrl));
+ Process.Start(FileName);
+ }*/
+ }
+ return false;
+ }
+
+ public void OnContextMenuDismissed(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame)
+ {
+ /*var webBrowser = (ChromiumWebBrowser)chromiumWebBrowser;
+
+ webBrowser.Dispatcher.Invoke(() =>
+ {
+ webBrowser.ContextMenu = null;
+ });*/
+ }
+
+ public bool RunContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback)
+ {
+ //callback.Cancel();
+ return false;
+ }
+ }
+}
diff --git a/SLBr/SLBr/Handlers/DownloadHandler.cs b/SLBr/SLBr/Handlers/DownloadHandler.cs
new file mode 100644
index 0000000..8dd291c
--- /dev/null
+++ b/SLBr/SLBr/Handlers/DownloadHandler.cs
@@ -0,0 +1,163 @@
+// 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.
+using CefSharp;
+//using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Forms;
+using System.Windows.Threading;
+
+namespace SLBr
+{
+ class DownloadHandler : IDownloadHandler
+ {
+ bool _allowDownload = true;
+
+ float DownloadUpdatePeriod = 2.5f;
+ float DownloadUpdateTime;
+
+ public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
+ {
+ if (!callback.IsDisposed)
+ {
+ using (callback)
+ {
+ if (_allowDownload)
+ {
+ bool Download = false;
+ if (bool.Parse(MainWindow.Instance.MainSave.Get("AFDP")))
+ {
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.InitialDirectory = MainWindow.Instance.MainSave.Get("DownloadPath");
+ saveFileDialog.FileName = downloadItem.SuggestedFileName;
+ saveFileDialog.Filter = "|*" + System.IO.Path.GetExtension(saveFileDialog.FileName);
+
+ if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != "")
+ {
+ downloadItem.SuggestedFileName = saveFileDialog.FileName;
+ Download = true;
+ }
+ else
+ downloadItem.IsCancelled = _allowDownload;
+ }
+ else
+ {
+ downloadItem.SuggestedFileName = Path.Combine(MainWindow.Instance.MainSave.Get("DownloadPath"), Path.GetFileName(downloadItem.SuggestedFileName));
+ Download = true;
+ }
+ if (Download)
+ {
+ MainWindow.Instance.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ string FileName = Path.GetFileName(downloadItem.SuggestedFileName);
+ MainWindow.Instance.DownloadContainer.Visibility = Visibility.Visible;
+ MainWindow.Instance.DownloadFileName.Text = FileName;
+ //MainWindow.Instance.DownloadProgressBar.Maximum = downloadItem.TotalBytes;
+ System.Windows.Controls.MenuItem DownloadMenuItem = MainWindow.CreateMenuItemForList(Path.GetFileName(downloadItem.SuggestedFileName), $"13<,>{downloadItem.SuggestedFileName}", new RoutedEventHandler(MainWindow.Instance.ButtonAction));
+ MainWindow.Instance.DownloadListMenuItem.Items.Insert(0, DownloadMenuItem);
+ if (MainWindow.Instance.DownloadListMenuItem.Items.Count > 10)
+ MainWindow.Instance.DownloadListMenuItem.Items.RemoveAt(10);
+ }));
+ }
+ }
+ else
+ downloadItem.IsCancelled = !_allowDownload;
+
+ callback.Continue(downloadItem.SuggestedFileName, showDialog: false);
+ }
+
+ }
+ }
+
+ public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
+ {
+ MainWindow.Instance.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ if (downloadItem.IsComplete)
+ {
+ 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}";
+ }
+ else
+ {
+ if ((DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).TotalSeconds > DownloadUpdateTime)
+ {
+ MainWindow.Instance.DownloadProgressText.Visibility = Visibility.Visible;
+ MainWindow.Instance.DownloadProgressBar.Visibility = Visibility.Visible;
+ MainWindow.Instance.DownloadOpenFileButton.Visibility = Visibility.Collapsed;
+ if (downloadItem.IsCancelled)
+ MainWindow.Instance.DownloadProgressText.Text = "Cancelled";
+ else if (downloadItem.IsInProgress)
+ {
+ MainWindow.Instance.DownloadProgressText.Text = $"{downloadItem.CurrentSpeed} bytes ({downloadItem.PercentComplete}%)";/*{(downloadItem.EndTime - downloadItem.StartTime).Value.TotalSeconds} seconds left.{downloadItem.ReceivedBytes}/{downloadItem.TotalBytes} bytes, */
+ MainWindow.Instance.DownloadProgressBar.Value = downloadItem.PercentComplete;
+ //MainWindow.Instance.DownloadProgressBar.Value = downloadItem.ReceivedBytes;
+ DownloadUpdateTime = ((float)(DateTime.UtcNow - Process.GetCurrentProcess().StartTime.ToUniversalTime()).TotalSeconds) + DownloadUpdatePeriod;
+ }
+
+ }
+ }
+ }));
+ }
+
+ /*public event EventHandler OnBeforeDownloadFired;
+
+ public event EventHandler OnDownloadUpdatedFired;
+
+ public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
+ {
+ if (downloadItem.IsValid)
+ {
+ Console.WriteLine("== File information ========================");
+ Console.WriteLine(" File URL: {0}", downloadItem.Url);
+ Console.WriteLine(" Suggested FileName: {0}", downloadItem.SuggestedFileName);
+ Console.WriteLine(" MimeType: {0}", downloadItem.MimeType);
+ Console.WriteLine(" Content Disposition: {0}", downloadItem.ContentDisposition);
+ Console.WriteLine(" Total Size: {0}", downloadItem.TotalBytes);
+ Console.WriteLine("============================================");
+ }
+
+ OnBeforeDownloadFired?.Invoke(this, downloadItem);
+
+ if (!callback.IsDisposed)
+ {
+ using (callback)
+ {
+ callback.Continue(
+ downloadItem.SuggestedFileName,
+ showDialog: true
+ );
+ }
+ }
+ }
+
+ public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
+ {
+ OnDownloadUpdatedFired?.Invoke(this, downloadItem);
+
+ if (downloadItem.IsValid)
+ {
+ if (downloadItem.IsInProgress && (downloadItem.PercentComplete != 0))
+ {
+ Console.WriteLine(
+ "Current Download Speed: {0} bytes ({1}%)",
+ downloadItem.CurrentSpeed,
+ downloadItem.PercentComplete
+ );
+ }
+
+ if (downloadItem.IsComplete)
+ Console.WriteLine("The download has been finished!");
+ }
+ }*/
+ }
+}
diff --git a/SLBr/SLBr/Handlers/JSBindingHandler.cs b/SLBr/SLBr/Handlers/JSBindingHandler.cs
new file mode 100644
index 0000000..ea05614
--- /dev/null
+++ b/SLBr/SLBr/Handlers/JSBindingHandler.cs
@@ -0,0 +1,69 @@
+// 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.
+using CefSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SLBr
+{
+ class JSBindingHandler
+ {
+ //Functions in this script are accessible by JS using the code `slbr.FUNCTION()`
+
+ /*public string executableLocation() =>
+ MainWindow.Instance.ExecutableLocation;
+ public string chromiumVersion =>
+ Cef.ChromiumVersion;
+
+ public bool hasDebugger() =>
+ Utils.HasDebugger();
+ public string cleanUrl(string Url) =>
+ Utils.CleanUrl(Url);*/
+
+ public string SearchProviderPrefix()
+ {
+ return MainWindow.Instance.MainSave.Get("Search_Engine");
+ //return "Bruh";
+ }
+ public string SayHello(string name) { return $"Hello {name}!"; }
+
+ public void Back()
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Undo();
+ }));
+ }
+ public void Forward()
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Redo();
+ }));
+ }
+ public void Refresh()
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Refresh();
+ }));
+ }
+
+ public void PromptExample()
+ {
+ Prompt("Example Message", "", "");
+ }
+
+ public void Prompt(string Message, string ButtonUrl, string ButtonMessage)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Prompt(Message, ButtonMessage.Trim().Length > 0 ? true : false, ButtonMessage, $"24<,>{ButtonUrl}");
+ }));
+ }
+ }
+}
diff --git a/SLBr/SLBr/Handlers/KeyboardHandler.cs b/SLBr/SLBr/Handlers/KeyboardHandler.cs
new file mode 100644
index 0000000..8c5e575
--- /dev/null
+++ b/SLBr/SLBr/Handlers/KeyboardHandler.cs
@@ -0,0 +1,74 @@
+// 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.
+using CefSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SLBr
+{
+ class HotKey
+ {
+ public HotKey(Action _Callback, int _KeyCode, bool HasControl, bool HasShift, bool HasAlt)
+ {
+ Callback = _Callback;
+ KeyCode = _KeyCode;
+ Control = HasControl;
+ Shift = HasShift;
+ Alt = HasAlt;
+ }
+
+ public int KeyCode;
+ public bool Control;
+ public bool Shift;
+ public bool Alt;
+
+ public Action Callback;//Function
+ }
+
+ class KeyboardHandler : IKeyboardHandler
+ {
+ List Keys = new List();
+
+ public void AddKey(Action Function, int _KeyCode, bool HasControl = false, bool HasShift = false, bool HasAlt = false)
+ {
+ Keys.Add(new HotKey(Function, _KeyCode, HasControl, HasShift, HasAlt));
+ }
+
+ public bool OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
+ {
+ if (type == KeyType.RawKeyDown)
+ {
+ bool HasControl = modifiers == CefEventFlags.ControlDown;
+ bool HasShift = modifiers == CefEventFlags.ShiftDown;
+ bool HasAlt = modifiers == CefEventFlags.AltDown;
+
+ //MessageBox.Show($"{windowsKeyCode},{HasControl},{HasShift},{HasAlt}");
+ foreach (HotKey Key in Keys)
+ {
+ //MessageBox.Show($"{Key.KeyCode},{Key.Control},{Key.Shift},{Key.Alt}");
+ if (Key.KeyCode == windowsKeyCode && Key.Control == HasControl && Key.Shift == HasShift && Key.Alt == HasAlt)
+ {
+ MainWindow.Instance.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ Key.Callback();
+ }));
+ }
+ }
+
+ //MessageBox.Show($"{windowsKeyCode},{HasControl},{HasShift},{HasAlt}");
+
+ }
+
+ return false;
+ }
+
+ public bool OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
+ {
+ return false;
+ }
+ }
+}
diff --git a/SLBr/SLBr/Handlers/LifeSpanHandler.cs b/SLBr/SLBr/Handlers/LifeSpanHandler.cs
new file mode 100644
index 0000000..4e0f2e6
--- /dev/null
+++ b/SLBr/SLBr/Handlers/LifeSpanHandler.cs
@@ -0,0 +1,46 @@
+// 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.
+using CefSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Threading;
+
+namespace SLBr
+{
+ public class LifeSpanHandler : ILifeSpanHandler
+ {
+ public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName,
+ WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo,
+ IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(targetUrl));
+ }));
+ //Program.Form.Invoke(new Action(() => Program.Form.newPage(targetUrl)));
+ //browser.MainFrame.LoadUrl(targetUrl);
+ newBrowser = null;
+ return true;
+ }
+
+ public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser)
+ {
+ //
+ }
+
+ public bool DoClose(IWebBrowser browserControl, IBrowser browser)
+ {
+ //if (browserControl.GetMainFrame().Url.Equals("devtools://devtools/devtools_app.html"))
+ return false;
+ }
+
+ public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser)
+ {
+ //nothing
+ }
+ }
+}
diff --git a/SLBr/SLBr/Handlers/RequestHandler.cs b/SLBr/SLBr/Handlers/RequestHandler.cs
new file mode 100644
index 0000000..2991f15
--- /dev/null
+++ b/SLBr/SLBr/Handlers/RequestHandler.cs
@@ -0,0 +1,111 @@
+// 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.
+using CefSharp;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SLBr
+{
+ public class RequestHandler : IRequestHandler
+ {
+ public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
+ {
+ return false;
+ }
+
+ public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
+ {
+ if (request.Url.Contains("roblox.com"))
+ return true;
+ if ((isRedirect || userGesture || frame.IsMain) && !Utils.IsSystemUrl(request.Url) && !Utils.IsProgramUrl(request.Url))
+ {
+ 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;
+ if (_ThreatType == Utils.SafeBrowsing.ThreatType.Malware || _ThreatType == Utils.SafeBrowsing.ThreatType.Unwanted_Software)
+ {
+ //chromiumWebBrowser.LoadHtml(File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "Malware.html")), request.Url);
+ frame.LoadUrl("slbr://malware"/* + "?url=" + request.Url*/);
+ }
+ else if (_ThreatType == Utils.SafeBrowsing.ThreatType.Social_Engineering)
+ {
+ frame.LoadUrl("slbr://deception"/* + "?url=" + request.Url*/);
+ }
+ /*else
+ {
+ if (bool.Parse(MainWindow.Instance.MainSave.Get("Weblight")) && !request.Url.Contains("googleweblight.com/?lite_url="))
+ {
+ frame.LoadUrl(Utils.FixUrl(request.Url, true));
+ }
+ }*/
+ //if (request.Url.EndsWith(".pdf"))
+ // frame.LoadUrl(request.Url + "#toolbar=0");
+ }
+ return false;
+ }
+ public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
+ {
+ return true;
+ }
+ public bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture)
+ {
+ if (targetDisposition == WindowOpenDisposition.NewBackgroundTab)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.CreateTab(MainWindow.Instance.CreateWebBrowser(targetUrl), false, MainWindow.Instance.Tabs.SelectedIndex + 1, true);
+ }));
+ return true;
+ }
+ // else
+ //{
+ // if (Utils.IsAboutUrl(targetUrl))
+ // {
+ // MessageBox.Show("slbr://" + targetUrl.Substring(6));
+ // frame.LoadUrl("slbr://" + targetUrl.Substring(6));
+ // //return true;
+ // }
+ //}
+ return false;
+ }
+
+ public void OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath)
+ {
+ }
+
+ public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
+ {
+ callback.Continue(true);
+ return true;
+ }
+
+ public void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status)
+ {
+ }
+
+ public void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser)
+ {
+ }
+
+ public IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
+ {
+ var rh = new ResourceRequestHandler();
+ return rh;
+ }
+
+ public bool OnSelectClientCertificate(IWebBrowser chromiumWebBrowser, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback)
+ {
+ return false;
+ }
+
+ public void OnDocumentAvailableInMainFrame(IWebBrowser chromiumWebBrowser, IBrowser browser)
+ {
+ }
+ }
+}
diff --git a/SLBr/SLBr/Handlers/ResourceRequestHandler.cs b/SLBr/SLBr/Handlers/ResourceRequestHandler.cs
new file mode 100644
index 0000000..46e39b7
--- /dev/null
+++ b/SLBr/SLBr/Handlers/ResourceRequestHandler.cs
@@ -0,0 +1,105 @@
+// 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.
+using CefSharp;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SLBr
+{
+ public class ResourceRequestHandler : IResourceRequestHandler
+ {
+ public void Dispose()
+ {
+ }
+
+ public ICookieAccessFilter GetCookieAccessFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request)
+ {
+ return null;
+ }
+
+ public IResourceHandler GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request)
+ {
+ return null;
+ }
+
+ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response)
+ {
+ return null;
+ }
+
+ public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
+ {
+ //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);
+ //request.SetHeaderByName("cookie", "1P_JAR=2022-02-28-01; NID=511=WF7xnRY3fmPoA8KW27PerWOTOjQrw1MMhOIK3-B1hIT0zDunpoEaSN5p4x0sTx7gPBuJ8UlVHtDvHbZTqtDop0fPvTQYKwaVDK-DfHKzTYn2BhDLM_Xmw2E6LY_G89d2WO1xYeOmfV-0vvixbyJonM-OtnhNMHyLMoAS7nDtItdu8bSI92GP_Nk_fCjldDyD0KminbX_bpVF; __utma=73091649.1413177246.1600596546.1645953634.1646110777.3; __utmc=73091649; __utmz=73091649.1646110777.3.2.utmcsr=bing|utmccn=(organic)|utmcmd=organic|utmctr=(not provided); __utmt=1; __utmb=73091649.91.9.1646112576592", false);
+ return CefReturnValue.Continue;
+ }
+
+ public bool OnProtocolExecution(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request)
+ {
+ return true;
+ }
+
+ public void OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
+ {
+ int code = response.StatusCode;
+ if (!frame.IsValid || frame.Url != request.Url)
+ return;
+ if (request.Url.StartsWith("file:///"))
+ {
+ //string _Path = request.Url/*.Substring(8)*/;
+ //if (File.Exists(_Path) || Directory.Exists(_Path))
+ // return;
+ //else
+ //{
+ // frame.LoadUrl("slbr://cannotconnect" + "?url=" + request.Url);
+ //}
+ }
+ /*else if (code == 404)
+ {
+ string Url = request.Url;
+ if (!Utils.CleanUrl(Url).StartsWith("web.archive.org"))
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.NewMessage("This page is missing, do you want to check if there's a saved version on the Wayback Machine?", $"https://web.archive.org/{Url}", "Check for saved version");*/
+ //dynamic Data = JObject.Parse(MainWindow.Instance.TinyDownloader.DownloadString($"https://archive.org/wayback/available?url={request.Url}"));
+ /*try
+ {
+ dynamic archived_snapshots = Data.archived_snapshots;
+ archived_snapshots.
+ }
+ catch { }*/
+ /*}));
+ }
+ //frame.LoadUrl("slbr://notfound" + "?url=" + request.Url);
+ }*/
+ // else if (request.Url.StartsWith("file:///"))
+ // {
+ // string _Path = request.Url.Substring(8);
+ // if (!File.Exists(_Path))
+ // frame.LoadUrl("slbr://notfound" + "?url=" + _Path);
+ // }
+ else if (code == 0 || code == 444 || (code >= 500 && code <= 599))
+ frame.LoadUrl("slbr://cannotconnect" + "?url=" + request.Url);
+ }
+
+ public void OnResourceRedirect(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl)
+ {
+ }
+
+ public bool OnResourceResponse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response)
+ {
+ return false;
+ }
+ }
+}
diff --git a/SLBr/SLBr/MainWindow.xaml b/SLBr/SLBr/MainWindow.xaml
new file mode 100644
index 0000000..49ad10f
--- /dev/null
+++ b/SLBr/SLBr/MainWindow.xaml
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/MainWindow.xaml.cs b/SLBr/SLBr/MainWindow.xaml.cs
new file mode 100644
index 0000000..5920df2
--- /dev/null
+++ b/SLBr/SLBr/MainWindow.xaml.cs
@@ -0,0 +1,2196 @@
+// 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.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.IO;
+using System.Net;
+using CefSharp.Wpf;
+using CefSharp;
+using CefSharp.SchemeHandler;
+using System.Windows.Threading;
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using HtmlAgilityPack;
+using System.Windows.Interop;
+using Microsoft.Win32;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+
+namespace SLBr
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window, INotifyPropertyChanged
+ {
+ //bool IsDevToolsOpen;
+ #region Start
+ public enum BuildType
+ {
+ Offical,/*Standard*/
+ Developer
+ }
+
+ public static MainWindow Instance;
+
+ private static Guid FolderDownloads = new Guid("374DE290-123F-4565-9164-39C4925E467B");
+
+ [DllImport("shell32.dll", CharSet = CharSet.Auto)]
+ private static extern int SHGetKnownFolderPath(ref Guid id, int flags, IntPtr token, out IntPtr path);
+
+ public static string GetDownloadsPath()
+ {
+ if (Environment.OSVersion.Version.Major < 6) throw new NotSupportedException();
+ IntPtr pathPtr = IntPtr.Zero;
+ try
+ {
+ SHGetKnownFolderPath(ref FolderDownloads, 0, IntPtr.Zero, out pathPtr);
+ return Marshal.PtrToStringUni(pathPtr);
+ }
+ finally
+ {
+ Marshal.FreeCoTaskMem(pathPtr);
+ }
+ }
+
+ public List DefaultSearchEngines = new List() {
+ "https://www.ecosia.org/search?q={0}",
+ "https://google.com/search?q={0}",
+ "https://bing.com/search?q={0}",
+ };
+ public string GoogleWeblightUserAgent = "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19 SLBr/2022.2.22";
+ public List SearchEngines;
+
+ public Utils.Saving MainSave;
+ public Utils.Saving FavouriteSave;
+ public Utils.Saving SearchEnginesSave;
+ public Utils.Saving TabsSave;
+ public Utils.Saving ATSADSEUrlsSave;
+
+ public int SettingsPages;
+
+ string SchemeName = "slbr";
+ string SchemeFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources");
+
+ List SchemeDomainNames = new List { "Urls", "Blank", "DevToolsTests", "NewTab", "License", "About"/*, "Dino", "Plans"*/, "SLBrUADetector", "Version", "WhatsNew"/*, "HTMLEditor"*/, "CannotConnect", "CdmSupport", "Copy_Icon.svg", "Malware", "Deception", "SLBr-Urls" };
+ //public List SchemeDomainUrls = new List();
+
+ public List ATSADSEUrls = new List();
+
+ List SaveNames = new List { "Save.bin", "Favourites.bin", "SearchEngines.bin", "Tabs.bin", "ATSADSEUrls.bin" };
+ List Saves = new List();
+
+ public string ReleaseVersion;
+
+ string ReleaseYear = "2022";
+ string ReleaseMonth = "3";
+ string ReleaseDay = "13";
+
+ bool IsInformationSet;
+ public string ChromiumVersion;
+ public string ExecutableLocation;
+ public string UserAgent;
+ public string JavascriptVersion;
+ //public string Revision;
+ public string BitProcess;
+ public BuildType _BuildType;
+
+ public string ProxyServer = "127.0.0.1:8088";//http://
+
+ public string ApplicationDataPath;
+ public string CachePath;
+ public string LogPath;
+ public int RemoteDebuggingPort = 8088;
+
+ public bool AddressBoxFocused;
+ public bool AddressBoxMouseEnter;
+
+ LifeSpanHandler _LifeSpanHandler;
+ DownloadHandler _DownloadHandler;
+ RequestHandler _RequestHandler;
+ ContextMenuHandler _ContextMenuHandler;
+ KeyboardHandler _KeyboardHandler;
+ JSBindingHandler _JSBindingHandler;
+ public Utils.SafeBrowsing _SafeBrowsing;
+
+ SettingsWindow _SettingsWindow;
+
+ public WebClient TinyDownloader;
+
+ string[] Args;
+ string NewTabUrl = "Empty00000";
+ public bool IsPrivateMode;
+ public bool IsDeveloperMode;
+ public bool IsChromiumMode;
+ public bool IsIEMode;
+ #endregion
+
+ #region INotifyPropertyChanged
+ public event PropertyChangedEventHandler PropertyChanged = delegate { };
+
+ private void RaisePropertyChanged(string Name)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs(Name));
+ }
+ #endregion
+
+ private ObservableCollection PrivateFavourites = new ObservableCollection();
+ public ObservableCollection Favourites
+ {
+ get { return PrivateFavourites; }
+ set
+ {
+ PrivateFavourites = value;
+ RaisePropertyChanged("Favourites");
+ }
+ }
+
+ //public List Prompts = new List();
+ //public ObservableCollection PromptsBinding { get { return new ObservableCollection(Prompts); } }
+
+ private ObservableCollection PrivatePrompts = new ObservableCollection();
+ public ObservableCollection Prompts
+ {
+ get { return PrivatePrompts; }
+ set
+ {
+ PrivatePrompts = value;
+ RaisePropertyChanged("Prompts");
+ }
+ }
+
+ public MainWindow()
+ {
+ if (Utils.HasDebugger())
+ _BuildType = BuildType.Developer;
+ else
+ _BuildType = BuildType.Offical;
+ Args = Environment.GetCommandLineArgs();
+ if (Args.Length > 1)
+ {
+ switch (Args[1])
+ {
+ case "Private":
+ IsPrivateMode = true;
+ break;
+ case "Developer":
+ IsDeveloperMode = true;
+ break;
+ case "Chromium":
+ IsChromiumMode = true;
+ break;
+ case "IE":
+ IsIEMode = true;
+ break;
+ default:
+ NewTabUrl = /*"file:\\\\\\" + */Args[1];
+ break;
+ }
+ /*else
+ //if (File.Exists(Args[1]))
+ NewTabUrl = Args[1];*/
+ }
+ if (!IsChromiumMode || !IsIEMode)
+ {
+ // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys
+ Environment.SetEnvironmentVariable("GOOGLE_API_KEY", SECRETS.GOOGLE_API_KEY);
+ //Create a cs file named "SECRETS",
+ //add 'public static string GOOGLE_API_KEY = "APIHERE";',
+ //replace the "APIHERE" with your own google api key, or leave it empty.
+ Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", SECRETS.GOOGLE_DEFAULT_CLIENT_ID);
+ //Create a cs file named "SECRETS",
+ //add 'public static string GOOGLE_DEFAULT_CLIENT_ID = "IDHERE";',
+ //replace the "IDHERE" with your own google client id, or leave it empty.
+ Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", SECRETS.GOOGLE_DEFAULT_CLIENT_SECRET);
+ //Create a cs file named "SECRETS",
+ //add 'public static string GOOGLE_DEFAULT_CLIENT_SECRET = "SECRETHERE";',
+ //replace the "SECRETHERE" with your own google client secret, or leave it empty.
+ }
+ ApplicationDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SLT World", "SLBr");
+ //if (!IsPrivateMode)
+ CachePath = Path.Combine(ApplicationDataPath, "Cache");
+ LogPath = Path.Combine(ApplicationDataPath, "Debug.log");
+
+ foreach (string Name in SaveNames)
+ Saves.Add(new Utils.Saving(true, Name, ApplicationDataPath));
+ InitializeComponent();
+ Instance = this;
+
+ DateTime CurrentDateTime = DateTime.Now;
+ if (string.IsNullOrEmpty(ReleaseYear))
+ ReleaseYear = CurrentDateTime.Year.ToString();
+ if (string.IsNullOrEmpty(ReleaseMonth))
+ ReleaseMonth = CurrentDateTime.Month.ToString();
+ if (string.IsNullOrEmpty(ReleaseDay))
+ ReleaseDay = CurrentDateTime.Day.ToString();
+ ReleaseVersion = $"{ReleaseYear}.{ReleaseMonth}.{ReleaseDay}.0";
+ BitProcess = Environment.Is64BitProcess ? "64" : "36";
+ ChromiumVersion = Cef.ChromiumVersion;
+
+ if (!IsIEMode)
+ {
+ InitializeCEF();
+
+ _LifeSpanHandler = new LifeSpanHandler();
+ _DownloadHandler = new DownloadHandler();
+ _RequestHandler = new RequestHandler();
+ _ContextMenuHandler = new ContextMenuHandler();
+ _KeyboardHandler = new KeyboardHandler();
+ _JSBindingHandler = new JSBindingHandler();
+ InitializeKeyboardHandler();
+ _SafeBrowsing = new Utils.SafeBrowsing(Environment.GetEnvironmentVariable("GOOGLE_API_KEY"), Environment.GetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID"));
+ }
+ /*else
+ InitializeIE();*/
+
+ MainSave = Saves[0];
+ FavouriteSave = Saves[1];
+ SearchEnginesSave = Saves[2];
+ TabsSave = Saves[3];
+ ATSADSEUrlsSave = Saves[4];
+ ExecutableLocation = Assembly.GetExecutingAssembly().Location.Replace("\\", "\\\\");
+ TinyDownloader = new WebClient();
+ }
+ public void InitializeCEF()
+ {
+ /*if (!File.Exists(LogFile))
+ File.Create(LogFile).Close();*/
+ CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
+ CefSharpSettings.ShutdownOnExit = true;
+ Cef.EnableHighDPISupport();
+ var settings = new CefSettings();
+ //settings.BackgroundColor = Cef.ColorSetARGB(0, 255, 255, 255);
+ //CefSharpSettings.ConcurrentTaskExecution = true; //true
+ //CefSharpSettings.FocusedNodeChangedEnabled = true;
+ //CefSharpSettings.WcfEnabled = true; //true
+
+ //settings.CefCommandLineArgs.Add("enable-widevine");
+ //settings.CefCommandLineArgs.Add("enable-widevine-cdm");
+
+ settings.CommandLineArgsDisabled = true;
+ settings.LogFile = LogPath;
+ settings.LogSeverity = LogSeverity.Warning;
+ settings.CachePath = CachePath;
+ settings.CefCommandLineArgs.Add("enable-print-preview");//Only for Non-OSR
+ settings.RemoteDebuggingPort = RemoteDebuggingPort;
+
+ settings.CefCommandLineArgs.Add("enable-media-stream");
+ settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
+ settings.CefCommandLineArgs.Add("enable-speech-input");
+ settings.CefCommandLineArgs.Add("enable-usermedia-screen-capture");
+ settings.CefCommandLineArgs.Add("enable-features", "PdfUnseasoned");
+ //settings.CefCommandLineArgs.Add("enable-viewport");
+ //settings.CefCommandLineArgs.Add("enable-features", "CastMediaRouteProvider,NetworkServiceInProcess");
+
+ //settings.CefCommandLineArgs.Add("disable-extensions");
+ //settings.CefCommandLineArgs.Add("enable-logging"); //Enable Logging for the Renderer process (will open with a cmd prompt and output debug messages - use in conjunction with setting LogSeverity = LogSeverity.Verbose;)
+ settings.CefCommandLineArgs.Add("ignore-certificate-errors");
+
+ //OSR Performance
+ //settings.SetOffScreenRenderingBestPerformanceArgs();
+ settings.CefCommandLineArgs.Add("disable-direct-composition");
+ settings.CefCommandLineArgs.Add("disable-gpu-compositing");
+ settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling");
+ settings.CefCommandLineArgs.Add("disable-gpu-vsync");
+ //settings.CefCommandLineArgs.Add("disable-gpu");
+ settings.CefCommandLineArgs.Add("disable-gpu-shader-disk-cache");
+ settings.CefCommandLineArgs.Add("off-screen-frame-rate", "30");
+
+ //settings.CefCommandLineArgs.Add("proxy-server", ProxyServer);
+ settings.CefCommandLineArgs.Add("debug-plugin-loading");
+ settings.CefCommandLineArgs.Add("disable-plugins-discovery");
+ //settings.CefCommandLineArgs.Add("allow-running-insecure-content");
+ settings.CefCommandLineArgs.Add("no-proxy-server");
+ settings.CefCommandLineArgs.Add("disable-pinch");
+ settings.CefCommandLineArgs.Add("disable-features", "WebUIDarkMode");/*,TouchpadAndWheelScrollLatching,AsyncWheelEvents*/
+ //settings.CefCommandLineArgs["disable-features"] += ",SameSiteByDefaultCookies";//Cross Site Request
+
+ settings.CefCommandLineArgs.Add("renderer-process-limit", "1");
+ settings.CefCommandLineArgs.Add("multi-threaded-message-loop");
+ settings.CefCommandLineArgs.Add("disable-threaded-scrolling");
+ settings.CefCommandLineArgs.Add("disable-smooth-scrolling");
+ settings.CefCommandLineArgs.Add("disable-surfaces");
+ settings.CefCommandLineArgs.Remove("process-per-tab");
+ settings.CefCommandLineArgs.Add("disable-site-isolation-trials");
+
+ settings.CefCommandLineArgs.Add("allow-universal-access-from-files");
+ settings.CefCommandLineArgs.Add("allow-file-access-from-files");
+ //settings.CefCommandLineArgs.Add("disable-features=IsolateOrigins,process-per-tab,site-per-process,process-per-site");
+ //settings.CefCommandLineArgs.Add("process-per-site");
+ //settings.CefCommandLineArgs.Remove("process-per-site");
+ //settings.CefCommandLineArgs.Remove("site-per-process");
+ //settings.CefCommandLineArgs.Add("process-per-site-instance");
+
+ //settings.CefCommandLineArgs.Add("disable-3d-apis", "1");
+ settings.CefCommandLineArgs.Add("disable-low-res-tiling");
+ //settings.CefCommandLineArgs.Add("disable-direct-write");
+ //settings.CefCommandLineArgs.Add("allow-sandbox-debugging");
+ //settings.CefCommandLineArgs.Add("webview-sandboxed-renderer");
+ settings.CefCommandLineArgs.Add("js-flags", "max_old_space_size=1024,lite_mode");
+ //settings.CefCommandLineArgs.Add("no-experiments");
+ //settings.CefCommandLineArgs.Add("no-vr-runtime");
+ //settings.CefCommandLineArgs.Add("in-process-gpu");//The --in-process-gpu option will run the GPU process as a thread in the main browser process. These processes consume most of the CPU time and the GPU driver crash will likely crash the whole browser, so you probably don't wanna use it.
+
+ /*settings.CefCommandLineArgs.Add("flag-switches-begin");
+ settings.CefCommandLineArgs.Add("flag-switches-end");*/
+
+ settings.CefCommandLineArgs.Add("autoplay-policy", "no-user-gesture-required");
+
+ //Enables Uncaught exception handler
+ //settings.UncaughtExceptionStackSize = 10;
+ if (!IsChromiumMode)
+ settings.UserAgentProduct = $"SLBr/{ReleaseVersion} Chromium/{ChromiumVersion}";
+ //settings.CefCommandLineArgs.Remove("mute-audio");
+ //else
+ // settings.UserAgentProduct = $"Chromium/{ChromiumVersion}";
+ //settings.ChromeRuntime = true;
+ //settings.CefCommandLineArgs.Add("enable-chrome-runtime");//https://bitbucket.org/chromiumembedded/cef/issues/2969/support-chrome-windows-with-cef-callbacks
+ /*var proxy = ProxyConfig.GetProxyInformation();
+ switch (proxy.AccessType)
+ {
+ case InternetOpenType.Direct:
+ {
+ //Don't use a proxy server, always make direct connections.
+ settings.CefCommandLineArgs.Add("no-proxy-server");
+ break;
+ }
+ case InternetOpenType.Proxy:
+ {
+ settings.CefCommandLineArgs.Add("proxy-server", proxy.ProxyAddress);
+ break;
+ }
+ case InternetOpenType.PreConfig:
+ {
+ settings.CefCommandLineArgs.Add("proxy-auto-detect");
+ break;
+ }
+ }*/
+ //CefSharpSettings.FocusedNodeChangedEnabled = true;
+ //CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
+ //Cef.EnableHighDPISupport();
+ //Load pepper flash player
+ //settings.CefCommandLineArgs.Add("ppapi-flash-path", System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"pepflashplayer.dll");
+ foreach (string Name in SchemeDomainNames)
+ {
+ string NewName = $"{Name}.html";
+ if (Name.Contains("."))
+ NewName = Name;
+ settings.RegisterScheme(new CefCustomScheme
+ {
+ SchemeName = SchemeName,
+ DomainName = Name.ToLower(),
+ SchemeHandlerFactory = new FolderSchemeHandlerFactory(
+ rootFolder: SchemeFolder,
+ hostName: Name,
+ defaultPage: NewName
+ ),
+ IsSecure = true
+ });
+ //SchemeDomainUrls.Add($"{SchemeName}://{Name.ToLower()}");
+ }
+ Cef.Initialize(settings);
+ }
+ /*public void InitializeIE()
+ {
+ RegistryKey Regkey = null;
+ try
+ {
+ // For 64 bit machine
+ if (Environment.Is64BitOperatingSystem)
+ Regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
+ else //For 32 bit machine
+ Regkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
+
+ // If the path is not correct or
+ // if the user haven't priviledges to access the registry
+ if (Regkey == null)
+ {
+ MessageBox.Show("Application Settings Failed - Address Not found");
+ return;
+ }
+
+ string FindAppkey = Convert.ToString(Regkey.GetValue("SLBr"));
+
+ // Check if key is already present
+ if (FindAppkey == "11001")
+ {
+ MessageBox.Show("Required Application Settings Present");
+ Regkey.Close();
+ return;
+ }
+
+ // If a key is not present add the key, Key value 8000 (decimal)
+ if (string.IsNullOrEmpty(FindAppkey))
+ Regkey.SetValue("SLBr", unchecked((int)0x1F40), RegistryValueKind.DWord);
+
+ // Check for the key after adding
+ FindAppkey = Convert.ToString(Regkey.GetValue("SLBr"));
+
+ if (FindAppkey == "11001")
+ MessageBox.Show("Application Settings Applied Successfully");
+ else
+ MessageBox.Show("Application Settings Failed, Ref: " + FindAppkey);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Application Settings Failed");
+ MessageBox.Show(ex.Message);
+ }
+ finally
+ {
+ // Close the Registry
+ if (Regkey != null)
+ Regkey.Close();
+ }
+ }*/
+ public void InitializeKeyboardHandler()
+ {
+ _KeyboardHandler.AddKey(Refresh, (int)System.Windows.Forms.Keys.R, true);
+ _KeyboardHandler.AddKey(delegate() { CreateTab(CreateWebBrowser()); }, (int)System.Windows.Forms.Keys.T, true);
+ _KeyboardHandler.AddKey(CloseTab, (int)System.Windows.Forms.Keys.W, true);
+ _KeyboardHandler.AddKey(Screenshot, (int)System.Windows.Forms.Keys.S, true);
+ _KeyboardHandler.AddKey(Refresh, (int)System.Windows.Forms.Keys.F5);
+ _KeyboardHandler.AddKey(DevTools, (int)System.Windows.Forms.Keys.F12);
+ }
+
+ /*using (var devToolsClient = browser.GetDevToolsClient())
+{
+ //Get the content size
+ var layoutMetricsResponse = await devToolsClient.Page.GetLayoutMetricsAsync();
+ var contentSize = layoutMetricsResponse.ContentSize;
+
+ var viewPort = new Viewport()
+ {
+ Height= contentSize.Height,
+ Width = contentSize.Width,
+ X = 0,
+ Y = 0,
+ Scale = 1
+ };
+
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1198576#c17
+ var result = await devToolsClient.Page.CaptureScreenshotAsync(clip: viewPort, fromSurface:true, captureBeyondViewport: true);
+
+ return result.Data;
+}v*/
+ bool IsProcessLoaded;
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ Task.Delay(1000).ContinueWith(_ =>
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ //if (!MainSave.Has("AssociationsSet"))
+ //{
+ // FileAssociations.EnsureAssociationsSet();
+ //MainSave.Set("AssociationsSet", true.ToString());
+ //}
+ if (!MainSave.Has("Search_Engine"))
+ MainSave.Set("Search_Engine", SearchEngines[0]);
+ if (!MainSave.Has("Homepage"))
+ MainSave.Set("Homepage", "slbr://newtab"/*Utils.FixUrl(new Uri(SearchEngines[0]).Host, false)*/);
+ if (!MainSave.Has("DarkTheme"))
+ MainSave.Set("DarkTheme", false.ToString());
+ else
+ Action(Actions.DarkTheme, null, "", MainSave.Get("DarkTheme"));
+ if (!MainSave.Has("FullAddress"))
+ MainSave.Set("FullAddress", false.ToString());
+ if (!MainSave.Has("BlockKeywords"))
+ MainSave.Set("BlockKeywords", true.ToString());
+ if (!MainSave.Has("BlockedKeywords"))
+ MainSave.Set("BlockedKeywords", "roblox,gacha");
+ if (!MainSave.Has("BlockRedirect"))
+ MainSave.Set("BlockRedirect", MainSave.Get("Homepage"));
+ if (!MainSave.Has("RestoreTabs"))
+ MainSave.Set("RestoreTabs", false.ToString());
+ if (!MainSave.Has("AFDP"))
+ MainSave.Set("AFDP", true.ToString());
+ if (!MainSave.Has("ATSADSE"))
+ MainSave.Set("ATSADSE", true.ToString());
+ if (!MainSave.Has("DownloadPath"))
+ MainSave.Set("DownloadPath", GetDownloadsPath());
+ if (!MainSave.Has("SelectedTabIndex"))
+ MainSave.Set("SelectedTabIndex", 1.ToString());
+ if (!MainSave.Has("HideTabs"))
+ MainSave.Set("HideTabs", false.ToString());
+ if (!MainSave.Has("Weblight"))
+ MainSave.Set("Weblight", false.ToString());
+ if (!MainSave.Has("TabUnloading"))
+ MainSave.Set("TabUnloading", true.ToString());
+ /*if (!MainSave.Has("IsI5Processor"))
+ {
+ if (Utils.GetProcessorID().Contains("i5"))
+ {
+ MainSave.Set("IsI5Processor", true.ToString());
+ }
+ else
+ MainSave.Set("IsI5Processor", false.ToString());
+ }*/
+ bool RestoreTabs = bool.Parse(MainSave.Get("RestoreTabs"));
+ if (RestoreTabs)
+ {
+ if (TabsSave.Has("Tab_Count"))
+ {
+ if (int.Parse(TabsSave.Get("Tab_Count")) > 0)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ int Index = int.Parse(MainSave.Get("SelectedTabIndex"));
+ for (int i = 0; i < int.Parse(TabsSave.Get("Tab_Count")); i++)
+ {
+ string Url = TabsSave.Get($"Tab_{i}");
+ //if (!SearchEngines.Contains(Url))
+ bool IsSelected = false;
+ if (Index == i && MainSave.Has("UsedBefore"))
+ IsSelected = true;
+ if (IsIEMode)
+ CreateIETab(CreateIEWebBrowser(Url), IsSelected);
+ else
+ CreateTab(CreateWebBrowser(Url), IsSelected);
+ }
+ if (Args.Length > 1 && File.Exists(Args[1]))
+ {
+ if (IsIEMode)
+ CreateIETab(CreateIEWebBrowser(NewTabUrl));
+ else
+ CreateTab(CreateWebBrowser(NewTabUrl));
+ }
+ }));
+ }
+ else
+ {
+ if (IsIEMode)
+ CreateIETab(CreateIEWebBrowser(NewTabUrl));
+ else
+ CreateTab(CreateWebBrowser(NewTabUrl));
+ }
+ }
+ else
+ {
+ if (IsIEMode)
+ CreateIETab(CreateIEWebBrowser(NewTabUrl));
+ else
+ CreateTab(CreateWebBrowser(NewTabUrl));
+ }
+ }
+ else
+ {
+ if (IsIEMode)
+ CreateIETab(CreateIEWebBrowser(NewTabUrl));
+ else
+ CreateTab(CreateWebBrowser(NewTabUrl));
+ }
+ HideTabs(bool.Parse(MainSave.Get("HideTabs")));
+ /*if (bool.Parse(MainSave.Get("IsI5Processor")))
+ {
+ if (!IsDeveloperMode || !IsIEMode)
+ {
+ MessageBox.Show("Sorry, SLBr can't support device Intel i5 processors");
+ Application.Current.Shutdown();
+ }
+ }*/
+ /*Cef.UIThreadTaskFactory.StartNew(delegate {
+ var rc = ((Tabs.Items.GetItemAt(1) as TabItem).Content as ChromiumWebBrowser).GetBrowser().GetHost().RequestContext;
+ var v = new Dictionary();
+ v["mode"] = "fixed_servers";
+ v["server"] = "socks5://127.0.0.1:9190";
+ string error;
+ bool success = rc.SetPreference("proxy", v, out error);
+ });*/
+ }));
+ });
+ if (FavouriteSave.Has("Favourite_Count"))
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ for (int i = 0; i < int.Parse(FavouriteSave.Get("Favourite_Count")); i++)
+ {
+ string[] Value = FavouriteSave.Get($"Favourite_{i}", true);
+ //string Url = Value[0];
+ //string Header = Value[1];
+
+ Favourites.Add(new Favourite { Name = Value[1], Arguments = $"12<,>{Value[0]}" });
+ }
+ if (Favourites.Count == 0)
+ FavouriteContainer.Visibility = Visibility.Collapsed;
+ else
+ FavouriteContainer.Visibility = Visibility.Visible;
+ }));
+ }
+ else
+ FavouriteContainer.Visibility = Visibility.Collapsed;
+ if (ATSADSEUrlsSave.Has("ATSADSEUrl_Count"))
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ for (int i = 0; i < int.Parse(ATSADSEUrlsSave.Get("ATSADSEUrl_Count")); i++)
+ {
+ string Url = ATSADSEUrlsSave.Get($"ATSADSEUrl_{i}");
+ if (!ATSADSEUrls.Contains(Url))
+ ATSADSEUrls.Add(Url);
+ }
+ }));
+ }
+ if (SearchEnginesSave.Has("Search_Engine_Count"))
+ {
+ SearchEngines = new List();
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ for (int i = 0; i < int.Parse(SearchEnginesSave.Get("Search_Engine_Count")); i++)
+ {
+ string Url = SearchEnginesSave.Get($"Search_Engine_{i}");
+ if (!SearchEngines.Contains(Url))
+ SearchEngines.Add(Url);
+ }
+ }));
+ }
+ else
+ SearchEngines = new List(DefaultSearchEngines);
+ if (!IsDeveloperMode)
+ IsDeveloperMode = Utils.HasDebugger();
+ if (IsPrivateMode)
+ {
+ Prompt("No browsing history will be saved, in-memory cache will be used.", false);//is being used
+ CachePath = string.Empty;
+ }
+ else if (IsDeveloperMode)
+ {
+ Prompt("Enabled access to developer/experimental features & functionalities of SLBr.", false, "", "", "", true, "\xE71C", "180");
+ TestsMenuItem.Visibility = Visibility.Visible;
+ }
+ else if (IsChromiumMode)
+ Prompt("API Keys are missing. The following functionalities of SLBr will be disabled [SafeBrowsing, Google Sign-in].", false);
+ else if (IsIEMode)
+ {
+ Prompt("Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors. But hey, at least you can test out a website and see how bad it's styling gets.", false);
+ FindTextBox.Visibility = Visibility.Collapsed;
+ SSLGrid.Visibility = Visibility.Collapsed;
+ }
+ else if (string.IsNullOrEmpty(CachePath))
+ Prompt("No browsing history will be saved, in-memory cache will be used.", false);
+ IsProcessLoaded = true;
+ if (!Utils.HasDebugger() && !IsDeveloperMode && !IsIEMode && !IsChromiumMode && !IsPrivateMode)
+ {
+ try
+ {
+ string VersionInfo = TinyDownloader.DownloadString("https://raw.githubusercontent.com/SLT-World/SLBr/main/Version.txt").Replace("\n", "");
+ if (!VersionInfo.StartsWith(ReleaseVersion))
+ {
+ Prompt($"SLBr {VersionInfo} is now available, please update SLBr to keep up with the progress.", true, "Download", $"24<,>https://github.com/SLT-World/SLBr/releases/tag/{VersionInfo}", $"https://github.com/SLT-World/SLBr/releases/tag/{VersionInfo}", true, "\xE896");//SLBr is up to date
+ }
+ }
+ catch { }
+ }
+ if (!MainSave.Has("UsedBefore"))
+ {
+ MainSave.Set("UsedBefore", true.ToString());
+ if (!IsIEMode)
+ CreateTab(CreateWebBrowser("slbr://about/"), true);
+ }
+ FavouritesPanel.ItemsSource = Favourites;
+ FavouritesMenu.Collection = Favourites;
+ PromptsPanel.ItemsSource = Prompts;
+ UnloadAllTabsTimer = new DispatcherTimer();
+ UnloadAllTabsTimer.Tick += UnloadAllTabsTimer_Tick;
+ UnloadAllTabsTimer.Interval = new TimeSpan(0, 7, 0);
+ UnloadAllTabsTimer.Start();
+ }
+
+ private void UnloadAllTabsTimer_Tick(object sender, EventArgs e)
+ {
+ if (!bool.Parse(MainSave.Get("TabUnloading")))
+ return;
+ foreach (TabItem Tab in Tabs.Items)
+ {
+ if (!Tab.IsSelected)
+ UnloadTab(Tab, true);//PROBLEM: Look at the UnloadTab code
+ }
+ }
+
+ /*foreach (ManagementObject video in new ManagementObjectSearcher(new SelectQuery("Win32_VideoController")).Get())
+ if ((string)video["Name"] == "Intel(R) Iris(R) Xe Graphics" && string.CompareOrdinal((string)video["DriverVersion"], "30.0.100.9667") <= 0)
+ {
+ System.Windows.Media.RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
+ break;
+ }*/
+
+ #region Actions
+ public enum Actions
+ {
+ Undo = 0,
+ Redo = 1,
+ Refresh = 2,
+ Create_Tab = 3,
+ Print = 4,
+ Source = 5,
+ DevTools = 6,
+ CloseTab = 7,
+ Settings = 8,
+ HTMLEditor = 9,
+ Home = 10,
+ Favourite = 11,
+ Navigate = 12,
+ FileExplorer = 13,
+ DarkTheme = 14,
+ Relaunch = 15,
+ Reset = 16,
+ ZoomIn = 17,
+ ZoomOut = 18,
+ ResetZoomLevel = 19,
+ NewsFeed = 20,
+ Pin = 21,
+ ClosePrompt = 22,
+ Prompt = 23,
+ PromptNavigate = 24,
+ Screenshot = 25,
+ }
+ private void Action(Actions _Action, object sender = null, string LastValue = "", string Value1 = "", string Value2 = "", string Value3 = "")
+ {
+ switch (_Action)
+ {
+ case Actions.Undo:
+ Undo();
+ break;
+ case Actions.Redo:
+ Redo();
+ break;
+ case Actions.Refresh:
+ Refresh();
+ break;
+ case Actions.Create_Tab:
+ if (IsIEMode)
+ CreateIETab(CreateIEWebBrowser());
+ else
+ CreateTab(CreateWebBrowser());
+ break;
+ case Actions.Print:
+ Print();
+ break;
+ case Actions.Source:
+ ViewSource();
+ break;
+ case Actions.DevTools:
+ DevTools();
+ break;
+ case Actions.CloseTab:
+ if (Tabs.Items.Count == 2)
+ break;
+ /*if (sender != null && sender is MenuItem)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ //Control c = (Control)(((ContextMenu)((MenuItem)sender).Parent).PlacementTarget);
+ //throw new Exception(c.GetType().ToString());
+ TabItem SpecifiedTab = null;
+ //if (sender is MenuItem)
+ SpecifiedTab = (TabItem)((ContextMenu)((MenuItem)sender).Parent).PlacementTarget; if (sender is MenuItem)
+ //else if (sender is Button)
+ //{
+ // Control c = (Control)((Button)sender).Parent;
+ // throw new Exception(c.GetType().ToString());
+ //}
+ CloseTab(SpecifiedTab);
+ }));
+ }
+ else*/
+ CloseTab();
+ break;
+ case Actions.Settings:
+ Settings();
+ break;
+ case Actions.HTMLEditor:
+ HTMLEditor();
+ break;
+ case Actions.Home:
+ Home();
+ break;
+ case Actions.Favourite:
+ Favourite();
+ break;
+ case Actions.Navigate:
+ if (sender != null)
+ Navigate(Value1);
+ /*if (sender is Button)
+ Navigate(((Button)sender).Content.ToString());
+ else if (sender is MenuItem)
+ Navigate(((MenuItem)sender).Header.ToString());*/
+ break;
+ case Actions.FileExplorer:
+ if (sender is MenuItem || sender is Button)
+ FileExplorer(Value1);
+ break;
+ case Actions.DarkTheme:
+ //MessageBox.Show($"{Value1}|{Value2}|{Value3},{LastValue}");
+ DarkTheme(bool.Parse(Value1));
+ break;
+ case Actions.Relaunch:
+ Relaunch();
+ break;
+ case Actions.Reset:
+ Reset();
+ break;
+ case Actions.ZoomIn:
+ Reset();
+ break;
+ case Actions.ZoomOut:
+ Reset();
+ break;
+ case Actions.ResetZoomLevel:
+ Reset();
+ break;
+ case Actions.NewsFeed:
+ NewsFeed();
+ break;
+ case Actions.Pin:
+ Pin(sender);
+ break;
+ case Actions.ClosePrompt:
+ ClosePrompt(int.Parse(Value1));
+ break;
+ case Actions.Prompt:
+ //NewMessage(Value1, Value2, Value3);
+ Prompt(Value1, true, Value2, Value3);
+ break;
+ case Actions.PromptNavigate:
+ PromptNavigate(int.Parse(LastValue), Value1);
+ break;
+ case Actions.Screenshot:
+ Screenshot();
+ break;
+ }
+ }
+
+ public async void Screenshot()
+ {
+ if (IsIEMode)
+ {
+ Prompt("The screenshot feature is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ if (!IsDeveloperMode)
+ {
+ Prompt("The screenshot feature is still an experimental feature.", false);
+ return;
+ }
+ using (var _DevToolsClient = GetBrowser().GetDevToolsClient())
+ {
+ string Url = $"{Path.Combine(GetDownloadsPath(), "SLBr_Screenshot_Test.png")}";
+ var result = await _DevToolsClient.Page.CaptureScreenshotAsync(CefSharp.DevTools.Page.CaptureScreenshotFormat.Png, null, null, null, false);
+ File.WriteAllBytes(Url, result.Data);
+ Navigate(Url);
+ }
+ }
+ public void Prompt(string Content, bool IncludeButton = true, string ButtonContent = "", string ButtonArguments = "", string ToolTip = "", bool IncludeIcon = false, string IconText = "", string IconRotation = "")
+ {
+ int Count = Prompts.Count;
+ Prompts.Add(new Prompt { Content = Content, ButtonVisibility = IncludeButton ? Visibility.Visible : Visibility.Collapsed, ButtonToolTip = ToolTip, ButtonContent = ButtonContent, ButtonTag = ButtonArguments + $"<,>{Count}", CloseButtonTag = $"22<,>{Count}", IconVisibility = IncludeIcon ? Visibility.Visible : Visibility.Collapsed, IconText = IconText, IconRotation = IconRotation });
+ }
+ public void PromptNavigate(int Index, string Url)
+ {
+ Navigate(Url);
+ ClosePrompt(Index);
+ }
+ public void ClosePrompt(int Index)
+ {
+ if (Prompts.Count > 0)
+ {
+ Prompts.RemoveAt(Index);
+ foreach (Prompt _Prompt in Prompts)
+ {
+ _Prompt.CloseButtonTag = $"22<,>{Prompts.IndexOf(_Prompt)}";
+ _Prompt.ButtonTag = Utils.RemoveCharsAfterLastChar(_Prompt.ButtonTag, "<,>", true) + Prompts.IndexOf(_Prompt).ToString();
+ }
+ }
+ //MessagesPanel.Refresh();
+ }
+ public void HideTabs(bool Toggle)
+ {
+ MainSave.Set("HideTabs", Toggle.ToString());
+ TabPanel _TabPanel = (TabPanel)Tabs.Template.FindName("HeaderPanel", Tabs);
+ if (Toggle)
+ {
+ foreach (TabItem Item in Tabs.Items)
+ {
+ if (Item.Name == "SLBrSettingsTab")
+ {
+ Tabs.SelectedItem = Item;
+ CloseTab();
+ _SettingsWindow = new SettingsWindow();
+ _SettingsWindow.Show();
+ break;
+ }
+ }
+ _TabPanel.Visibility = Visibility.Collapsed;
+ }
+ else
+ {
+ if (_SettingsWindow != null)
+ {
+ _SettingsWindow.Close();
+ //_SettingsWindow = null;
+ Settings();
+ }
+ _TabPanel.Visibility = Visibility.Visible;
+ }
+ }
+ public void Pin(object sender)
+ {
+ TabItem Tab = GetCurrentTab();
+ int TabIndex = Tabs.Items.IndexOf(Tab);
+ string CleanedTag = Tab.Tag.ToString().Replace("<,>Unpinned", "").Replace("<,>Pinned", "");
+ int Index = 0;
+ try
+ {
+ Index = int.Parse(CleanedTag);
+ }
+ catch { Index = TabIndex; }
+ Button _PinButton = (Button)sender;
+ if (CleanedTag != TabIndex.ToString())
+ {
+ //_PinButton.Content = "\xE840";
+ Tabs.Items.Remove(Tab);
+ Tabs.Items.Insert(Index, Tab);
+ Tab.IsSelected = true;
+ Tab.Tag = $"{TabIndex}<,>Unpinned";
+ }
+ else
+ {
+ //_PinButton.Content = "\xE77A";
+ Tabs.Items.Remove(Tab);
+ Tabs.Items.Insert(1, Tab);
+ Tab.IsSelected = true;
+ Tab.Tag = $"{TabIndex}<,>Pinned";
+ }
+ _PinButton = (Button)Tab.Template.FindName("PinButton", Tab);
+ if (_PinButton != null && !_PinButton.Tag.ToString().Contains("ActionSetted"))
+ {
+ _PinButton.Tag = "21<,>ActionSetted";
+ _PinButton.Click += new RoutedEventHandler(ButtonAction);
+ }
+ }
+ public void NewsFeed()
+ {
+ new NewsPage().Show();
+ }
+ public void ResetZoomLevel()
+ {
+ if (IsIEMode)
+ {
+ Prompt("Zooming is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.SetZoomLevel(0);
+ _Browser.ZoomLevel = 0;
+ }
+ public void ZoomOut()
+ {
+ if (IsIEMode)
+ {
+ Prompt("Zooming is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.ZoomLevel -= _Browser.ZoomLevelIncrement;
+ }
+ public void ZoomIn()
+ {
+ if (IsIEMode)
+ {
+ Prompt("Zooming is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.ZoomLevel += _Browser.ZoomLevelIncrement;
+ }
+ public void Reset()
+ {
+ if (MessageBox.Show("Are you sure you want to reset everything? (Restarts Application after resetting)", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.No)
+ {
+ return;
+ }
+ foreach (Utils.Saving Save in Saves)
+ {
+ string _Path = Save.SaveFilePath;
+ if (File.Exists(_Path))
+ File.Delete(_Path);
+ Save.Clear();
+ /*ATSADSEUrls
+ SearchEngines
+ Favourites*/
+ }
+ Relaunch(false);
+ }
+ /*public void ClearCache()
+ {
+ string _Path = CachePath;
+ if (Directory.Exists(_Path))
+ Directory.Delete(_Path);
+ //Restart();
+ }*/
+ public void Relaunch(bool CallClosingEvent = true)
+ {
+ if (CallClosingEvent && MessageBox.Show("Are you sure you want to relaunch SLBr? (Everything will be saved)", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.No)
+ {
+ return;
+ }
+ else if (!CallClosingEvent)
+ IsProcessLoaded = false;
+ //Closing -= Window_Closing;
+ Process.Start(Application.ResourceAssembly.Location);//DoNotUseIfUsingClickOnce
+ Application.Current.Shutdown();
+ }
+ public void DarkTheme(bool Toggle)
+ {
+ if (Toggle)
+ {
+ Resources["PrimaryBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#202225"));
+ Resources["FontBrush"] = new SolidColorBrush(Colors.White);
+ Resources["BorderBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#36393F"));
+ Resources["UnselectedTabBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F3136"));
+ Resources["ControlFontBrush"] = new SolidColorBrush(Colors.Gainsboro);
+ }
+ else
+ {
+ Resources["PrimaryBrush"] = new SolidColorBrush(Colors.White);
+ Resources["FontBrush"] = new SolidColorBrush(Colors.Black);
+ Resources["BorderBrush"] = new SolidColorBrush(Colors.Gainsboro);
+ Resources["UnselectedTabBrush"] = new SolidColorBrush(Colors.WhiteSmoke);
+ Resources["ControlFontBrush"] = new SolidColorBrush(Colors.Gray);
+ }
+ }
+ public void FileExplorer(string _Path)
+ {
+ //string FolderPath = System.IO.Path.GetDirectoryName(_Path);
+ /*if (Directory.Exists(FolderPath))
+ {*/
+ _Path = Utils.CleanUrl(_Path).Replace("%20", "");
+ ProcessStartInfo startInfo = new ProcessStartInfo
+ {
+ Arguments = "/select, \"" + _Path + "\"",
+ FileName = "explorer.exe"
+ };
+ Process.Start(startInfo);
+ /*}
+ else
+ {
+ MessageBox.Show(string.Format("{0} Directory does not exist!", FolderPath));
+ }*/
+ }
+ public void Navigate(string Url)
+ {
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.Navigate(Url);
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.Address = Utils.FixUrl(Url, bool.Parse(MainSave.Get("Weblight")));
+ }
+ }
+ public void Favourite()
+ {
+ if (IsIEMode)
+ {
+ Prompt("The favourite feature is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ TabItem Tab = GetCurrentTab();
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ string Url = _Browser.Address;
+ int FavouriteExistIndex = FavouriteExists(Url);
+ if (FavouriteExistIndex != -1)
+ {
+ Favourites.RemoveAt(FavouriteExistIndex);
+ FavouriteButton.Content = "\xEB51";
+ //Dispatcher.Invoke(delegate () { }, DispatcherPriority.Render);
+ }
+ else if (_Browser.IsLoaded)
+ {
+ Favourites.Add(new Favourite { Name = _Browser.Title, Arguments = $"12<,>{Url}" });
+ FavouriteButton.Content = "\xEB52";
+ }
+ if (Favourites.Count == 0)
+ FavouriteContainer.Visibility = Visibility.Collapsed;
+ else
+ FavouriteContainer.Visibility = Visibility.Visible;
+ }
+ public void Home()
+ {
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.Navigate(MainSave.Get("Homepage"));
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.Address = Utils.FixUrl(MainSave.Get("Homepage"), bool.Parse(MainSave.Get("Weblight")));
+ }
+ }
+ public void HTMLEditor()
+ {
+ if (IsIEMode)
+ {
+ Prompt("HTML Editor is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ CreateTab(CreateWebBrowser("slbr://htmleditor"));
+ }
+ public void Settings()
+ {
+ //new SettingsWindow().ShowDialog();
+ if (bool.Parse(MainSave.Get("HideTabs")))
+ {
+ //if (_SettingsWindow == null)
+ //{
+ _SettingsWindow = new SettingsWindow();
+ _SettingsWindow.Show();
+ //}
+ //else
+ // MessageBox.Show("An instance of the settings window is already running.");
+ }
+ else
+ {
+ if (SettingsPages > 0)
+ {
+ bool FoundSettingsPage = false;
+ foreach (TabItem Item in Tabs.Items)
+ {
+ if (Item.Name == "SLBrSettingsTab")
+ {
+ Tabs.SelectedItem = Item;
+ if (!FoundSettingsPage)
+ FoundSettingsPage = true;
+ break;
+ }
+ }
+ if (!FoundSettingsPage)
+ SettingsPages = 0;
+ return;
+ }
+
+ int Count = Tabs.Items.Count;
+ Frame _Frame = new Frame();
+ TabItem Tab = new TabItem()
+ {
+ Name = "SLBrSettingsTab",
+ Header = "Settings",
+ Content = _Frame
+ };
+ _Frame.Content = new SettingsPage();
+ Tabs.Items.Insert(Count/* - 1*/, Tab);
+ Tab.Tag = $"{Count}<,>Unpinned";
+ Tabs.SelectedItem = Tab;
+ AddressBox.Text = string.Empty;
+ _Frame.LoadCompleted += (sender, args) =>
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ Tab.ApplyTemplate();
+ Button _Button = (Button)Tab.Template.FindName("CloseTabButton", Tab);
+ if (_Button != null && !_Button.Tag.ToString().Contains("ActionSetted")/* && Tab.ContextMenu.Items[0] != null*/)
+ {
+ /*MenuItem _MenuItem = (MenuItem)Tab.ContextMenu.Items[0];
+ _MenuItem.Tag = "7";
+ _MenuItem.Click += new RoutedEventHandler(ButtonAction);*/
+ _Button.Tag = "7<,>ActionSetted";
+ _Button.Click += new RoutedEventHandler(ButtonAction);
+ }
+ Image _Image = (Image)Tab.Template.FindName("Icon", Tab);
+ System.Windows.Shapes.Path _DefaultTabIcon = (System.Windows.Shapes.Path)Tab.Template.FindName("TabIcon", Tab);
+ if (_DefaultTabIcon != null && _Image != null)
+ {
+ _DefaultTabIcon.Visibility = Visibility.Visible;
+ _Image.Visibility = Visibility.Collapsed;
+ }
+ Button _PinButton = (Button)Tab.Template.FindName("PinButton", Tab);
+ if (_PinButton != null && !_PinButton.Tag.ToString().Contains("ActionSetted"))
+ {
+ _PinButton.Tag = "21<,>ActionSetted";
+ _PinButton.Click += new RoutedEventHandler(ButtonAction);
+ }
+ }));
+ };
+ SettingsPages++;
+ }
+ }
+ public void CloseTab(/*TabItem SpecifiedTab = null*/)
+ {
+ TabItem Tab;
+ /*if (SpecifiedTab != null)
+ Tab = SpecifiedTab;
+ else
+ return;*/
+ Tab = GetCurrentTab();
+ /*if (_MenuItem != null && !(_MenuItem.DataContext is TabItem))
+ throw new Exception();*/
+ if (Tab.Name == "SLBrSettingsTab")
+ SettingsPages--;
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser != null)
+ _Browser.Dispose();
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser != null)
+ {
+ //DisposeBrowser(_Browser);
+ //_Browser.Stop();
+ //_Browser.BrowserCore.CloseBrowser(true);
+ _Browser.Dispose();
+ }
+ }
+ Tabs.Items.Remove(Tab);
+ }
+ public void DevTools()
+ {
+ if (IsIEMode)
+ {
+ Prompt("Developer Tools is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.ShowDevTools();
+ /*if (IsDevToolsOpen)
+ {
+ Grid.SetColumnSpan(Tabs, 2);
+ DevToolsContainer.Children.Clear();
+ _Browser.CloseDevTools();
+ IsDevToolsOpen = false;
+ }
+ else
+ {
+ Grid.SetColumnSpan(Tabs, 1);
+ IntPtr Handle = IntPtr.Zero;
+ HwndSource _HwndSource = PresentationSource.FromVisual(DevToolsContainer) as HwndSource;
+ if (_HwndSource != null)
+ {
+ Handle = _HwndSource.Handle;
+ }
+ var _Rect = GetBoundingBox(DevToolsContainer, this);
+ WindowInfo _WindowInfo = new WindowInfo();
+ _WindowInfo.SetAsChild(Handle, Convert.ToInt32(_Rect.Left), Convert.ToInt32(_Rect.Top), Convert.ToInt32(_Rect.Right), Convert.ToInt32(_Rect.Bottom));
+ _Browser.ShowDevTools(_WindowInfo);
+ IsDevToolsOpen = true;
+ }*/
+ }
+ public void ViewSource()
+ {
+ if (IsIEMode)
+ {
+ Prompt("Viewing sources is not supported on Internet Explorer mode.", false);
+ return;
+ }
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ CreateTab(CreateWebBrowser($"view-source:{_Browser.Address}"));
+ //_Browser.ViewSource();
+ }
+ public void Print()
+ {
+ /*if (IsIEMode)
+ {
+ NewMessage("Printing is not supported on Internet Explorer mode.", false);
+ return;
+ }*/
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.InvokeScript("eval", "document.execCommand('Print');");
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ _Browser.Print();
+ }
+ }
+ public void Undo()
+ {
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser == null)
+ return;
+ if (_Browser.CanGoBack == true)
+ {
+ _Browser.GoBack();
+ }
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ if (_Browser.CanGoBack == true)
+ {
+ _Browser.Back();
+ }
+ }
+ }
+ public void Redo()
+ {
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser == null)
+ return;
+ if (_Browser.CanGoForward == true)
+ {
+ _Browser.GoForward();
+ }
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ if (_Browser.CanGoForward == true)
+ {
+ _Browser.Forward();
+ }
+ }
+ }
+ public void Refresh()
+ {
+ if (IsIEMode)
+ {
+ WebBrowser _Browser = GetIEBrowser();
+ if (_Browser == null)
+ return;
+ if (_Browser.IsLoaded)
+ _Browser.Refresh();
+ else
+ _Browser.InvokeScript("eval", "document.execCommand('Stop');");
+ }
+ else
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ if (_Browser.IsLoaded)
+ _Browser.Reload();
+ else
+ _Browser.Stop();
+ }
+ }
+ #endregion
+ public void CreateTab(ChromiumWebBrowser _Browser, bool Focus = true, int Index = 0, bool NameByUrl = false)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ int Count = Tabs.Items.Count;
+ if (Index > 0)
+ Count = Index;
+ string TabName = NameByUrl ? _Browser.Address : "New Tab";
+ TabItem Tab = new TabItem()
+ {
+ Header = $"{TabName}"
+ };
+ ApplyToTab(_Browser, Tab, true);
+ Tabs.Items.Insert(Count/* - 1*/, Tab);
+ Tab.Tag = $"{Count}<,>Unpinned";
+ Tab.IsSelected = Focus;
+ Tab.UseLayoutRounding = true;
+ Tab.SnapsToDevicePixels = true;
+ }));
+ }
+ public void CreateIETab(WebBrowser _Browser, bool Focus = true, int Index = 0)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ int Count = Tabs.Items.Count;
+ if (Index > 0)
+ Count = Index;
+ string TabName = /*NameByUrl ? */_Browser.Source.AbsoluteUri/* : "New Tab"*/;
+ TabItem Tab = new TabItem()
+ {
+ //Header = $"Tab {Count}"
+ Header = $"{TabName}"
+ };
+ _Browser = ConfigureIE(_Browser, Tab);
+ //Tab.Background = Brushes.Transparent;
+ //Tab.FontFamily = new FontFamily("Original");
+ Tab.Content = _Browser;
+ /*_Browser.SnapsToDevicePixels = true;
+ _Browser.UseLayoutRounding = true;*/
+ Tabs.Items.Insert(Count/* - 1*/, Tab);
+ Tab.Tag = $"{Count}<,>Unpinned";
+ Tab.IsSelected = Focus;
+ //Tab.UseLayoutRounding = true;
+ //NewMessage("You are in SLBr developer mode, you have access to developer features of SLBr.", false);
+ /*else if (InternetExplorerMode)
+ NewMessage("All sites in this tab will be opened in Internet Explorere mode.", false);*/
+ }));
+ }
+
+ public void UnloadTab(TabItem Tab, bool IgnoreIfSound = false)
+ {
+ ChromiumWebBrowser _Browser = GetBrowser(Tab);
+ if (_Browser != null && _Browser.IsBrowserInitialized)
+ {
+ if (IgnoreIfSound)//PROBLEM: This checks if the address is a known music website. I need help on detecting sound.
+ {
+ string CleanedAddress = Utils.CleanUrl(_Browser.Address);
+ if (CleanedAddress.Contains("youtube.com/watch")
+ || CleanedAddress.Contains("spotify.com/track/")
+ || CleanedAddress.Contains("soundcloud.com")
+ || CleanedAddress.Contains("dailymotion.com/video/")
+ || CleanedAddress.Contains("vimeo.com")
+ || CleanedAddress.Contains("twitch.tv/")
+ || CleanedAddress.Contains("bitchute.com/video/")
+ || CleanedAddress.Contains("ted.com/talks/")
+ )
+ {
+ return;
+ }
+ }
+ string Url = _Browser.Address;
+ _Browser.Dispose();
+ Tab.Content = null;
+ ApplyToTab(CreateWebBrowser(Url), Tab, true);
+ }
+ }
+ public void ApplyToTab(ChromiumWebBrowser _Browser, TabItem Tab, bool Configure)
+ {
+ if (Configure)
+ _Browser = this.Configure(_Browser, Tab);
+ Tab.Content = _Browser;
+ }
+
+ public ChromiumWebBrowser Configure(ChromiumWebBrowser _Browser, TabItem Tab/* = null*/)
+ {
+ var sett = new BrowserSettings();
+ sett.BackgroundColor = Utils.ColorToUInt(System.Drawing.Color.Black);
+ _Browser.BrowserSettings = sett;
+ _Browser.JavascriptObjectRepository.Register("slbr", _JSBindingHandler, true, BindingOptions.DefaultBinder);
+ //_Browser.ExecuteScriptAsyncWhenPageLoaded(File.ReadAllText("Resources/JsBinding.js")/*, true*/);
+ _Browser.TitleChanged += TitleChanged;
+ _Browser.LoadingStateChanged += LoadingStateChanged;
+ // Enable touch scrolling - once properly tested this will likely become the default
+ //_Browser.IsManipulationEnabled = true;
+ _Browser.LifeSpanHandler = _LifeSpanHandler;
+ _Browser.DownloadHandler = _DownloadHandler;
+ _Browser.RequestHandler = _RequestHandler;
+ _Browser.MenuHandler = _ContextMenuHandler;
+ _Browser.KeyboardHandler = _KeyboardHandler;
+ _Browser.ZoomLevelIncrement = 0.25;
+ _Browser.FrameLoadEnd += (sender, args) =>
+ {
+ if (args.Frame.IsValid && args.Frame.IsMain)
+ {
+ /*Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ args.Frame.ExecuteJavaScriptAsync("const addCSS = s => document.head.appendChild(document.createElement('style')).innerHTML=s;" +
+ "addCSS(\'::-webkit-scrollbar-thumb:hover{background:" + (Resources["ControlFontBrush"] as SolidColorBrush).Color.ToString() + ";}\');" +
+ "addCSS(\'::-webkit-scrollbar-thumb{background:" + (Resources["BorderBrush"] as SolidColorBrush).Color.ToString() + ";}\');" +
+ "addCSS(\'::-webkit-scrollbar-track{background:" + (Resources["PrimaryBrush"] as SolidColorBrush).Color.ToString() + ";}\');");
+ }));*/
+ string ArgsUrl = args.Url;
+ if (!IsInformationSet)
+ {
+ var Response = args.Browser.GetDevToolsClient().Browser.GetVersionAsync();
+ JavascriptVersion = Response.Result.JsVersion;
+ /*Revision = Response.Result.Revision;
+ if (Revision.StartsWith("@"))
+ Revision = Revision.Substring(1);*/
+ UserAgent = Response.Result.UserAgent;
+ IsInformationSet = true;
+ }
+ if (ArgsUrl == "slbr://version/")
+ {
+ args.Frame.ExecuteJavaScriptAsync($"document.getElementById(\"_version\").innerHTML = \"{ReleaseVersion}\";" +
+ $"document.getElementById(\"bit_process\").innerHTML = \"({BitProcess}-bit ARM)\";" +
+ $"document.getElementById(\"build_type\").innerHTML = \"({_BuildType} Build)\";" +
+ $"document.getElementById(\"chromium_version\").innerHTML = \"{ChromiumVersion}\";" +
+ //$"document.getElementById(\"_revision\").innerHTML = \"{Revision}\";" +
+ //"document.getElementById(\"_os_type\").innerHTML = \"Windows\";" +
+ $"document.getElementById(\"js_version\").innerHTML = \"{JavascriptVersion}\";" +
+ //$"document.getElementById(\"_useragent\").innerHTML = \"{UserAgent}\";" +
+ $"document.getElementById(\"_command_line\").innerHTML = '{"\"" + ExecutableLocation + "\""}';" +
+ $"document.getElementById(\"_executable_path\").innerHTML = \"{ExecutableLocation}\";" +
+ $"document.getElementById(\"_cache_path\").innerHTML = \"{CachePath.Replace("\\", "\\\\")}\";");
+ }
+ if (bool.Parse(MainSave.Get("DarkTheme")))
+ {
+ args.Frame.ExecuteJavaScriptAsync("document.documentElement.style.setProperty('filter', 'invert(100%)');" +
+ "const addCSS = s => document.head.appendChild(document.createElement('style')).innerHTML=s;" +
+ "addCSS('iframe, img, svg, video{ filter:invert(100%); }');" +
+ "const all = document.querySelectorAll('*');" +
+ "const restricted = ['iframe', 'img', 'svg', 'video'];" +
+ "all.forEach(tags => {" +
+ "if (!restricted.includes(tags.tagName.toLowerCase()))" +
+ "{" +
+ "if (getComputedStyle(tags).backgroundImage != 'none')" +
+ "{" +
+ "tags.style.filter = 'invert(100%)';" +
+ "}" +
+ "}" +
+ "});");
+ }
+ int HttpStatusCode = args.HttpStatusCode;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ if (HttpStatusCode == 404 && !Utils.CleanUrl(ArgsUrl).StartsWith("web.archive.org"))
+ Prompt("This page is missing, do you want to check if there's a saved version on the Wayback Machine?", true, "Check for saved version", $"24<,>https://web.archive.org/{ArgsUrl}", $"https://web.archive.org/{ArgsUrl}", true, "\xF142");
+ else if (Utils.CleanUrl(ArgsUrl).EndsWith(".png") || Utils.CleanUrl(ArgsUrl).EndsWith(".jpeg") || Utils.CleanUrl(ArgsUrl).EndsWith(".webp"))
+ Prompt("You are viewing a image, don't mistake it for a webpage.", false);
+ else
+ CloseClosableMessages();
+ try
+ {
+ string Host = new Uri(_Browser.Address).Host;
+ if (bool.Parse(MainSave.Get("ATSADSE")) && !ATSADSEUrls.Contains(Host) && !SearchEngines.Select(item => new Uri(item).Host).Contains(Host))
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ try
+ {
+ _Browser.GetMainFrame().EvaluateScriptAsync(@"document.getElementsByTagName('head')[0].innerHTML").ContinueWith(t =>
+ {
+ if (t.Result != null && t.Result.Result != null)
+ {
+ var result = t.Result.Result.ToString();
+
+ string Url = string.Empty;
+ var _Document = new HtmlDocument();
+ _Document.LoadHtml(result);
+ HtmlNode _Node = _Document.DocumentNode.SelectSingleNode("//link[contains(@type, 'application/opensearchdescription+xml')]");
+ if (_Node != null)
+ {
+ Url = _Node.Attributes["href"].Value;
+ ATSADSEUrls.Add(Host);
+ if (!Url.StartsWith("//") && Url.StartsWith("/"))
+ Url = "http://" + Host + Url;
+ else if (Url.StartsWith("//"))
+ Url = "http://" + Url.Substring(2);
+ if (MessageBox.Show("Set as default search provider?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes, MessageBoxOptions.DefaultDesktopOnly) == MessageBoxResult.Yes)
+ {
+ if (Path.GetExtension(Url) == ".xml")
+ {
+ string Content = TinyDownloader.DownloadString(Url);
+ _Document.LoadHtml(Content);
+ _Node = _Document.DocumentNode.SelectSingleNode("//opensearchdescription").SelectSingleNode("//url");
+ string _SearchUrl = _Node.Attributes["template"].Value.Replace("searchTerms", "0");
+ SearchEngines.Add(_SearchUrl);
+ MainSave.Set("Search_Engine", _SearchUrl);
+ }
+ }
+ }
+ }
+ });
+ }
+ catch { }
+ }));
+ }
+ }
+ catch { }
+ Button _Button = (Button)Tab.Template.FindName("CloseTabButton", Tab);
+ if (_Button != null && !_Button.Tag.ToString().Contains("ActionSetted")/* && Tab.ContextMenu.Items[0] != null*/)
+ {
+ //_Browser.ExecuteScriptAsync("chrome.webRequest.onBeforeRequest.addListener(function(details) { return { cancel: true}; },{ urls:[\"*://*.doubleclick.net/*\"] },[\"blocking\"]);");
+ /*MenuItem _MenuItem = (MenuItem)Tab.ContextMenu.Items[0];
+ _MenuItem.Tag = "7";
+ _MenuItem.Click += new RoutedEventHandler(ButtonAction);*/
+ _Button.Tag = "7<,>ActionSetted";
+ _Button.Click += new RoutedEventHandler(ButtonAction);
+ }
+ Image _Image = (Image)Tab.Template.FindName("Icon", Tab);
+ System.Windows.Shapes.Path _DefaultTabIcon = (System.Windows.Shapes.Path)Tab.Template.FindName("TabIcon", Tab);
+ if (AddressBox.Text != (bool.Parse(MainSave.Get("FullAddress")) ? _Browser.Address : Utils.CleanUrl(_Browser.Address)) && _Browser == GetBrowser())
+ {
+ AddressBox.Text = bool.Parse(MainSave.Get("FullAddress")) ? _Browser.Address : Utils.CleanUrl(_Browser.Address);
+ AddressBox.Tag = _Browser.Address;
+ }
+ if (_DefaultTabIcon != null && _Image != null)
+ {
+ try
+ {
+ var bytes = TinyDownloader.DownloadData("https://www.google.com/s2/favicons?domain=" + new Uri(_Browser.Address).Host);
+ var ms = new MemoryStream(bytes);
+
+ var bi = new BitmapImage();
+ bi.BeginInit();
+ bi.StreamSource = ms;
+ bi.EndInit();
+
+ _DefaultTabIcon.Visibility = Visibility.Collapsed;
+ _Image.Visibility = Visibility.Visible;
+ _Image.Source = bi;
+ }
+ catch
+ {
+ _DefaultTabIcon.Visibility = Visibility.Visible;
+ _Image.Visibility = Visibility.Collapsed;
+ }
+ }
+ Button _PinButton = (Button)Tab.Template.FindName("PinButton", Tab);
+ if (_PinButton != null && !_PinButton.Tag.ToString().Contains("ActionSetted"))
+ {
+ _PinButton.Tag = "21<,>ActionSetted";
+ _PinButton.Click += new RoutedEventHandler(ButtonAction);
+ }
+ //_Browser.ExecuteScriptAsync("function C(d,o){v=d.createElement('div');o.parentNode.replaceChild(v,o);}function A(d){for(j=0;t=[\", Interaction.IIf(browser.Address.Contains(\"youtube.com\"), \"'iframe','marquee'\", \"'iframe','embed','marquee'\")), \"][j];++j){o=d.getElementsByTagName(t);for(i=o.length-1;i>=0;i--)C(d,o[i]);}g=d.images;for(k=g.length-1;k>=0;k--)if({'21x21':1,'48x48':1,'60x468':1,'88x31':1,'88x33':1,'88x62':1,'90x30':1,'90x32':1,'90x90':1,'100x30':1,'100x37':1,'100x45':1,'100x50':1,'100x70':1,'100x100':1,'100x275':1,'110x50':1,'110x55':1,'110x60':1,'110x110':1,'120x30':1,'120x60':1,'120x80':1,'120x90':1,'120x120':1,'120x163':1,'120x181':1,'120x234':1,'120x240':1,'120x300':1,'120x400':1,'120x410':1,'120x500':1,'120x600':1,'120x800':1,'125x40':1,'125x60':1,'125x65':1,'125x72':1,'125x80':1,'125x125':1,'125x170':1,'125x250':1,'125x255':1,'125x300':1,'125x350':1,'125x400':1,'125x600':1,'125x800':1,'126x110':1,'130x60':1,'130x65':1,'130x158':1,'130x200':1,'132x70':1,'140x55':1,'140x350':1,'145x145':1,'146x60':1,'150x26':1,'150x60':1,'150x90':1,'150x100':1,'150x150':1,'155x275':1,'155x470':1,'160x80':1,'160x126':1,'160x600':1,'180x30':1,'180x66':1,'180x132':1,'180x150':1,'194x165':1,'200x60':1,'220x100':1,'225x70':1,'230x30':1,'230x33':1,'230x60':1,'234x60':1,'234x68':1,'240x80':1,'240x300':1,'250x250':1,'275x60':1,'280x280':1,'300x60':1,'300x100':1,'300x250':1,'320x50':1,'320x70':1,'336x280':1,'350x300':1,'350x850':1,'360x300':1,'380x112':1,'380x250':1,'392x72':1,'400x40':1,'400x50':1,'425x600':1,'430x225':1,'440x40':1,'464x62':1,'468x16':1,'468x60':1,'468x76':1,'468x120':1,'468x248':1,'470x60':1,'480x400':1,'486x60':1,'545x90':1,'550x5':1,'600x30':1,'720x90':1,'720x300':1,'725x90':1,'728x90':1,'734x96':1,'745x90':1,'750x25':1,'750x100':1,'750x150':1,'850x120':1}[g[k].width+'x'+g[k].height])C(d,g[k]);}A(document);for(f=0;z=frames[f];++f)A(z.document)");
+ if (_Browser.GetBrowser().CanGoBack)
+ BackButton.IsEnabled = true;
+ else
+ BackButton.IsEnabled = false;
+ if (_Browser.GetBrowser().CanGoForward)
+ ForwardButton.IsEnabled = true;
+ else
+ ForwardButton.IsEnabled = false;
+ }));
+ }
+ };
+ return _Browser;
+ }
+ public WebBrowser ConfigureIE(WebBrowser _Browser, TabItem Tab/* = null*/)
+ {
+ _Browser.LoadCompleted += delegate (object sender, NavigationEventArgs e) { IE_LoadCompleted(sender, e, Tab); };
+ return _Browser;
+ }
+
+ private void IE_LoadCompleted(object sender, NavigationEventArgs e, TabItem Tab)
+ {
+ WebBrowser _Browser = sender as WebBrowser;
+ string ArgsUrl = e.Uri.AbsoluteUri;
+ if (!IsInformationSet)
+ IsInformationSet = true;
+ //int HttpStatusCode = e.WebResponse.ContentType;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ if (AddressBox.Text != (bool.Parse(MainSave.Get("FullAddress")) ? e.Uri.AbsoluteUri : Utils.CleanUrl(e.Uri.AbsoluteUri)) && _Browser == GetIEBrowser())
+ {
+ AddressBox.Text = bool.Parse(MainSave.Get("FullAddress")) ? e.Uri.AbsoluteUri : Utils.CleanUrl(e.Uri.AbsoluteUri);
+ AddressBox.Tag = e.Uri.AbsoluteUri;
+ }
+ Button _Button = (Button)Tab.Template.FindName("CloseTabButton", Tab);
+ if (_Button != null && !_Button.Tag.ToString().Contains("ActionSetted")/* && Tab.ContextMenu.Items[0] != null*/)
+ {
+ /*MenuItem _MenuItem = (MenuItem)Tab.ContextMenu.Items[0];
+ _MenuItem.Tag = "7";
+ _MenuItem.Click += new RoutedEventHandler(ButtonAction);*/
+ _Button.Tag = "7<,>ActionSetted";
+ _Button.Click += new RoutedEventHandler(ButtonAction);
+ }
+ Image _Image = (Image)Tab.Template.FindName("Icon", Tab);
+ System.Windows.Shapes.Path _DefaultTabIcon = (System.Windows.Shapes.Path)Tab.Template.FindName("TabIcon", Tab);
+ if (_DefaultTabIcon != null && _Image != null)
+ {
+ try
+ {
+ var bytes = TinyDownloader.DownloadData("https://www.google.com/s2/favicons?domain=" + e.Uri.Host);
+ var ms = new MemoryStream(bytes);
+
+ var bi = new BitmapImage();
+ bi.BeginInit();
+ bi.StreamSource = ms;
+ bi.EndInit();
+
+ _DefaultTabIcon.Visibility = Visibility.Collapsed;
+ _Image.Visibility = Visibility.Visible;
+ _Image.Source = bi;
+ }
+ catch
+ {
+ _DefaultTabIcon.Visibility = Visibility.Visible;
+ _Image.Visibility = Visibility.Collapsed;
+ }
+ }
+ Button _PinButton = (Button)Tab.Template.FindName("PinButton", Tab);
+ if (_PinButton != null && !_PinButton.Tag.ToString().Contains("ActionSetted"))
+ {
+ _PinButton.Tag = "21<,>ActionSetted";
+ _PinButton.Click += new RoutedEventHandler(ButtonAction);
+ }
+ if (_Browser.CanGoBack)
+ BackButton.Foreground = Resources["ControlFontBrush"] as SolidColorBrush;
+ else
+ BackButton.Foreground = Resources["BorderBrush"] as SolidColorBrush;
+ if (_Browser.CanGoForward)
+ ForwardButton.Foreground = Resources["ControlFontBrush"] as SolidColorBrush;
+ else
+ ForwardButton.Foreground = Resources["BorderBrush"] as SolidColorBrush;
+ }));
+ }
+
+ /*private Rect GetBoundingBox(FrameworkElement element, Window containerWindow)
+ {
+ GeneralTransform transform = element.TransformToAncestor(containerWindow);
+ Point topLeft = transform.Transform(new Point(0, 0));
+ Point bottomRight = transform.Transform(new Point(element.ActualWidth, element.ActualHeight));
+ return new Rect(topLeft, bottomRight);
+ }*/
+ public static MenuItem CreateMenuItemForList(string Header, string Tag = "Empty00000", RoutedEventHandler _RoutedEventHandler = null)
+ {
+ MenuItem _MenuItem = new MenuItem();
+ _MenuItem.FontFamily = new FontFamily("Arial");
+ _MenuItem.Foreground = new SolidColorBrush(Colors.Black);
+ _MenuItem.Header = Header;
+ if (Tag != "Empty00000")
+ _MenuItem.Tag = Tag;
+ if (_RoutedEventHandler != null)
+ _MenuItem.Click += _RoutedEventHandler;
+ return _MenuItem;
+ }
+ public void ButtonAction(object sender, RoutedEventArgs e)
+ {
+ Actions _Action;
+ var Target = (FrameworkElement)sender;
+ string _Tag = Target.Tag.ToString();
+ var Values = _Tag.Split(new string[] { "<,>", "<,>" }, StringSplitOptions.None);//_Tag.Split(new[] { '<,>' }, 3);//2 = 3
+ _Action = (Actions)int.Parse(Values[0]);
+ string LastValue = Values.Last();
+ Action(_Action, sender, LastValue, (Values.Length > 1) ? Values[1] : "", (Values.Length > 2) ? Values[2] : "", (Values.Length > 3) ? Values[3] : "");
+ }
+
+ public ChromiumWebBrowser CreateWebBrowser(string Url = "Empty00000")
+ {
+ if (Url == "Empty00000")
+ Url = MainSave.Get("Homepage");
+ ChromiumWebBrowser _Browser = new ChromiumWebBrowser(Url);//Configure(GetBrowserFromPool(), Url);
+ _Browser.Address = Utils.FixUrl(Url, bool.Parse(MainSave.Get("Weblight")));
+ return _Browser;
+ }
+ public WebBrowser CreateIEWebBrowser(string Url = "Empty00000")
+ {
+ if (Url == "Empty00000")
+ Url = MainSave.Get("Homepage");
+ WebBrowser _Browser = new WebBrowser();//Configure(GetBrowserFromPool(), Url);
+ _Browser.Navigate(Url);
+ return _Browser;
+ }
+
+ void BrowserChanged(object sender, bool IsSwitchTab = false)
+ {
+ if (IsIEMode)
+ return;
+ Dispatcher.BeginInvoke(new Action(delegate
+ {
+ /*TabItem Tab = Tabs.SelectedItem as TabItem;
+ if (Tab == null)
+ return;*/
+ ChromiumWebBrowser CurrentBrowser = GetBrowser();
+ if (CurrentBrowser == null)
+ return;
+ if (sender is ChromiumWebBrowser)
+ {
+ ChromiumWebBrowser _Browser = sender as ChromiumWebBrowser;
+ if (CurrentBrowser != _Browser)
+ return;
+ }
+ if (string.IsNullOrEmpty(CurrentBrowser.Address))
+ CurrentBrowser.Address = Utils.FixUrl(MainSave.Get("Homepage"), bool.Parse(MainSave.Get("Weblight")));
+ AddressBox.Text = bool.Parse(MainSave.Get("FullAddress")) ? CurrentBrowser.Address : Utils.CleanUrl(CurrentBrowser.Address);
+ AddressBox.Tag = CurrentBrowser.Address;
+ bool ContinueUrlCheck = true;
+ if (CurrentBrowser.Address.StartsWith("http") || CurrentBrowser.Address.StartsWith("file:"))
+ {
+ string Host = new Uri(CurrentBrowser.Address).Host;//Cef.ParseUrl(CurrentBrowser.Address)
+ if (CurrentBrowser.Address.StartsWith("https:"))
+ {
+ SSLSymbol.Text = "\xE72E";
+ SSLToolTip.Content = $"{Host} has a valid SSL certificate";
+ ContinueUrlCheck = false;
+ }
+ else if (CurrentBrowser.Address.StartsWith("http:"))
+ {
+ SSLSymbol.Text = "\xE785";
+ SSLToolTip.Content = $"{Host} doesn't have a valid SSL certificate";
+ ContinueUrlCheck = false;
+ }
+ else if (CurrentBrowser.Address.StartsWith("file:"))
+ {
+ SSLSymbol.Text = "\xE8B7";//E8A5//E8B7//E7C3
+ SSLToolTip.Content = $"Local or shared file";
+ ContinueUrlCheck = false;
+ }
+ }
+ if (ContinueUrlCheck)
+ {
+ if (Utils.IsInternalUrl(CurrentBrowser.Address))
+ {
+ SSLSymbol.Text = "\xE8BE";
+ SSLToolTip.Content = $"Secure SLBr Page";
+ }
+ else if (Utils.IsSystemUrl(CurrentBrowser.Address))
+ {
+ SSLSymbol.Text = "\xE72E";
+ SSLToolTip.Content = $"{CurrentBrowser.Address} is a system scheme and is considered secure";
+ }
+ else
+ {
+ SSLSymbol.Text = "\xE783";
+ SSLToolTip.Content = $"Unknown";
+ }
+ }
+ if (!IsSwitchTab)
+ {
+ //CurrentBrowser.Reload();
+ if (CurrentBrowser.IsLoading)
+ {
+ ReloadButton.Content = "\xE72C";
+ WebsiteLoadingProgressBar.IsEnabled = false;
+ WebsiteLoadingProgressBar.IsIndeterminate = false;
+ }
+ else
+ {
+ ReloadButton.Content = "\xE711";
+ WebsiteLoadingProgressBar.IsEnabled = true;
+ WebsiteLoadingProgressBar.IsIndeterminate = true;
+ }
+ if (bool.Parse(MainSave.Get("BlockKeywords")) && MainSave.Get("BlockedKeywords").Length > 0)
+ {
+ string[] BlockedKeywords = MainSave.Get("BlockedKeywords").Split(',');
+ bool ContainsKeyword = false;
+ for (int i = 0; i < BlockedKeywords.Length; i++)
+ {
+ ContainsKeyword = CurrentBrowser.Address.ToLower().Contains(BlockedKeywords[i]) || (CurrentBrowser.Title != null && CurrentBrowser.Title.ToLower().Contains(BlockedKeywords[i]));
+ if (ContainsKeyword)
+ {
+ CurrentBrowser.Address = Utils.FixUrl(MainSave.Get("BlockRedirect"), bool.Parse(MainSave.Get("Weblight")));
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (CurrentBrowser.CanGoBack)
+ BackButton.IsEnabled = true;
+ else
+ BackButton.IsEnabled = false;
+ if (CurrentBrowser.CanGoForward)
+ ForwardButton.IsEnabled = true;
+ else
+ ForwardButton.IsEnabled = false;
+ }
+ if (FavouriteExists(AddressBox.Tag.ToString()) != -1)
+ FavouriteButton.Content = "\xEB52";
+ else
+ FavouriteButton.Content = "\xEB51";
+ if (HistoryListMenuItem.Items.Count > 0 && ((MenuItem)HistoryListMenuItem.Items[0]).Header.ToString() == CurrentBrowser.Address)
+ return;
+ string Address = Utils.FixUrl(CurrentBrowser.Address, bool.Parse(MainSave.Get("Weblight")));
+ //if (Address.Contains("googleweblight.com/?lite_url=") && bool.Parse(MainSave.Get("Weblight")))
+ // Address = Address.Replace("googleweblight.com/?lite_url=", "");
+ MenuItem _HistoryMenuItem = CreateMenuItemForList(Address, $"12<,>{Address}", new RoutedEventHandler(ButtonAction));
+ HistoryListMenuItem.Items.Insert(0, _HistoryMenuItem);
+ //if (HistoryListMenuItem.Items.Contains(CurrentBrowser.Address))
+ //{
+ // HistoryListMenuItem.Items.RemoveAt(HistoryListMenuItem.Items.IndexOf(CurrentBrowser.Address));
+ //}
+ if (HistoryListMenuItem.Items.Count > 25)
+ HistoryListMenuItem.Items.RemoveAt(25);
+ }));
+ }
+
+ //document.querySelectorAll('video').forEach(vid => vid.pause());
+
+ #region CEF
+ private void TitleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ Dispatcher.BeginInvoke(new Action(delegate
+ {
+ ChromiumWebBrowser _Browser = (ChromiumWebBrowser)sender;
+ TabItem Tab = GetCurrentTab();
+ ChromiumWebBrowser CurrentBrowser = GetBrowser();
+ if (CurrentBrowser != _Browser)
+ return;
+ Tab.Header = _Browser.Title.Trim().Length > 0 ? _Browser.Title : Utils.CleanUrl(_Browser.Address);
+ }));
+ }
+ private void LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
+ {
+ //Dispatcher.BeginInvoke(new Action(delegate
+ //{
+ BrowserChanged(sender);
+ //}));
+ }
+ #endregion
+
+ private TabItem GetCurrentTab()
+ {
+ TabItem Tab = Tabs.SelectedItem as TabItem;
+ return Tab;
+ }
+ private ChromiumWebBrowser GetBrowser(TabItem Tab = null)
+ {
+ if (Tab == null)
+ Tab = GetCurrentTab();
+ ChromiumWebBrowser _Browser = Tab.Content as ChromiumWebBrowser;
+ /*if (_Browser == null)
+ return null;*/
+ return _Browser;
+ }
+ private WebBrowser GetIEBrowser(TabItem Tab = null)
+ {
+ if (Tab == null)
+ Tab = GetCurrentTab();
+ WebBrowser _Browser = Tab.Content as WebBrowser;
+ /*if (_Browser == null)
+ return null;*/
+ return _Browser;
+ }
+
+ int FavouriteExists(string Url)
+ {
+ int ToReturn = -1;
+ string[] FavouriteUrls = Favourites.Select(item => item.Arguments.Replace("12<,>", "")).ToArray();
+ for (int i = 0; i < FavouriteUrls.Length; i++)
+ {
+ if (FavouriteUrls[i] == Url)
+ ToReturn = i;
+ }
+ return ToReturn;
+ }
+ bool CanCloseMessage(int Index)
+ {
+ Prompt _Message = Prompts[Index];
+ return (_Message.ButtonContent != null && _Message.ButtonContent == "Check for saved version"
+ || _Message.ButtonContent == "Set as default search provider?"
+ || _Message.ButtonContent == "Open in file explorer")
+ || (_Message.Content != null && _Message.Content.StartsWith("You are viewing a image"));
+ }
+ void CloseClosableMessages()
+ {
+ for (int i = 0; i < Prompts.Count; i++)
+ {
+ if (CanCloseMessage(i))
+ ClosePrompt(i);
+ }
+ }
+
+ #region AddressBox
+ private void AddressBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (IsIEMode)
+ {
+ WebBrowser _IEBrowser = GetIEBrowser();
+ if (_IEBrowser == null)
+ return;
+ if (e.Key == Key.Enter && AddressBox.Text.Trim().Length > 0)
+ {
+ if (AddressBox.Text.StartsWith("search:"))
+ _IEBrowser.Navigate(string.Format(MainSave.Get("Search_Engine"), AddressBox.Text.Substring(7).Trim().Replace(" ", "+")));
+ else if (AddressBox.Text.StartsWith("mailto:"))
+ Process.Start(AddressBox.Text);
+ else if (AddressBox.Text.Contains("."))
+ {
+ if (AddressBox.Text.StartsWith("https://") || AddressBox.Text.StartsWith("http://"))
+ _IEBrowser.Navigate(AddressBox.Text.Trim().Replace(" ", string.Empty));
+ else
+ _IEBrowser.Navigate("http://" + AddressBox.Text.Trim().Replace(" ", string.Empty));
+ }
+ else
+ _IEBrowser.Navigate(string.Format(MainSave.Get("Search_Engine"), AddressBox.Text.Trim().Replace(" ", "+")));
+ return;
+ }
+ }
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ if (e.Key == Key.Enter && AddressBox.Text.Trim().Length > 0)
+ {
+ /*if (AddressBox.Text.StartsWith("search:"))
+ _Browser.Address = Utils.FixUrl(string.Format(MainSave.Get("Search_Engine"), AddressBox.Text.Substring(7).Trim().Replace(" ", "+")), bool.Parse(MainSave.Get("Weblight")));
+ else if (AddressBox.Text.StartsWith("mailto:"))
+ Process.Start(AddressBox.Text);
+ else if (IsChromiumMode && AddressBox.Text.StartsWith("chrome:"))
+ _Browser.Address = AddressBox.Text;
+ else if (!IsChromiumMode && AddressBox.Text.StartsWith("cef:"))
+ _Browser.Address = "chrome:" + AddressBox.Text.Substring(4);
+ else if (Utils.IsSystemUrl(AddressBox.Text))
+ _Browser.Address = AddressBox.Text;
+ else if (AddressBox.Text.Contains("."))
+ {
+ if (AddressBox.Text.StartsWith("https://") || AddressBox.Text.StartsWith("http://"))
+ _Browser.Address = Utils.FixUrl(AddressBox.Text.Trim().Replace(" ", string.Empty), bool.Parse(MainSave.Get("Weblight")));
+ else
+ _Browser.Address = Utils.FixUrl("http://" + AddressBox.Text.Trim().Replace(" ", string.Empty), bool.Parse(MainSave.Get("Weblight")));
+ }
+ else
+ _Browser.Address = string.Format(MainSave.Get("Search_Engine"), AddressBox.Text.Trim().Replace(" ", "+"));
+ if (AddressBox.Text.ToLower().Contains("cefsharp.browsersubprocess"))
+ MessageBox.Show("cefsharp.browsersubprocess is necessary for the browser engine to function accordingly.");*/
+ string Url = Utils.FilterUrlForBrowser(AddressBox.Text, MainSave.Get("Search_Engine"), bool.Parse(MainSave.Get("Weblight")), IsChromiumMode);
+ if (!Utils.IsProgramUrl(Url))
+ _Browser.Address = Url;
+ }
+ }
+ private void AddressBox_GotFocus(object sender, RoutedEventArgs e)
+ {
+ //try
+ //{
+ if (AddressBox.Text == (bool.Parse(MainSave.Get("FullAddress")) ? AddressBox.Tag.ToString() : Utils.CleanUrl(AddressBox.Tag.ToString())))
+ AddressBox.Text = AddressBox.Tag.ToString();
+ //}
+ //catch { }
+ AddressBoxFocused = true;
+ }
+ private void AddressBox_LostFocus(object sender, RoutedEventArgs e)
+ {
+ if (!AddressBoxMouseEnter)
+ {
+ //try
+ //{
+ if (Utils.CleanUrl(AddressBox.Text) == Utils.CleanUrl(AddressBox.Tag.ToString()))
+ AddressBox.Text = bool.Parse(MainSave.Get("FullAddress")) ? AddressBox.Tag.ToString() : Utils.CleanUrl(AddressBox.Tag.ToString());
+ //}
+ //catch { }
+ }
+ AddressBoxFocused = false;
+ }
+ private void AddressBox_MouseEnter(object sender, MouseEventArgs e)
+ {
+ if (!AddressBoxFocused)
+ {
+ //try
+ //{
+ if (AddressBox.Text == (bool.Parse(MainSave.Get("FullAddress")) ? AddressBox.Tag.ToString() : Utils.CleanUrl(AddressBox.Tag.ToString())))
+ AddressBox.Text = AddressBox.Tag.ToString();
+ //}
+ //catch { }
+ }
+ AddressBoxMouseEnter = true;
+ }
+ private void AddressBox_MouseLeave(object sender, MouseEventArgs e)
+ {
+ if (!AddressBoxFocused)
+ {
+ //try
+ //{
+ if (Utils.CleanUrl(AddressBox.Text) == Utils.CleanUrl(AddressBox.Tag.ToString()))
+ AddressBox.Text = bool.Parse(MainSave.Get("FullAddress")) ? AddressBox.Tag.ToString() : Utils.CleanUrl(AddressBox.Tag.ToString());
+ //}
+ //catch { }
+ }
+ AddressBoxMouseEnter = false;
+ }
+ #endregion
+ private void FindTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ ChromiumWebBrowser _Browser = GetBrowser();
+ if (_Browser == null)
+ return;
+ if (FindTextBox.Text.Trim().Length > 0)
+ {
+ if (e.Key == Key.Enter)
+ _Browser.Find(FindTextBox.Text, true, false, true);
+ }
+ else
+ {
+ _Browser.StopFinding(true);
+ }
+ }
+
+ DispatcherTimer UnloadAllTabsTimer;
+
+ private void Tabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ CloseClosableMessages();
+ BrowserChanged(sender, true);
+ TabItem Tab = (TabItem)Tabs.SelectedItem;
+ if (Tab != null)
+ {
+ if (Tab.Tag != null && Tab.Tag.ToString().Contains("Unpinned"))
+ Tab.Tag = Tabs.Items.IndexOf(Tab);
+ if (Tab.Name == "SLBrSettingsTab")
+ AddressBox.Text = string.Empty;
+ }
+ }
+
+ private void Window_Closing(object sender, CancelEventArgs e)
+ {
+ if (IsProcessLoaded)
+ {
+ UnloadAllTabsTimer.Stop();
+ for (int i = 0; i < Favourites.Count; i++)
+ FavouriteSave.Set($"Favourite_{i}", Favourites[i].Arguments.Replace("12<,>", ""), Favourites[i].Name, false);
+ FavouriteSave.Set("Favourite_Count", Favourites.Count.ToString());
+ for (int i = 0; i < SearchEngines.Count; i++)
+ SearchEnginesSave.Set($"Search_Engine_{i}", SearchEngines[i], false);
+ SearchEnginesSave.Set("Search_Engine_Count", SearchEngines.Count.ToString());
+ for (int i = 0; i < ATSADSEUrls.Count; i++)
+ ATSADSEUrlsSave.Set($"ATSADSEUrl_{i}", ATSADSEUrls[i], false);
+ ATSADSEUrlsSave.Set("ATSADSEUrl_Count", ATSADSEUrls.Count.ToString());
+ bool RestoreTabs = bool.Parse(MainSave.Get("RestoreTabs"));
+ if (RestoreTabs)
+ {
+ int Count = 0;
+ int SelectedIndex = 1;
+ for (int i = 0; i < Tabs.Items.Count; i++)
+ {
+ if (i == 0)
+ continue;
+ TabItem Tab = (TabItem)Tabs.Items.GetItemAt(i);
+ string Url = "";
+ if (IsIEMode)
+ {
+ WebBrowser Browser = GetIEBrowser(Tab);
+ if (Browser == null)
+ continue;
+ Url = Browser.Source.AbsoluteUri;
+ }
+ else
+ {
+ ChromiumWebBrowser Browser = GetBrowser(Tab);
+ if (Browser == null)
+ continue;
+ Url = Browser.Address;
+ }
+ TabsSave.Set($"Tab_{Count}", Url, false);
+ if (Tab.IsSelected)
+ SelectedIndex = Count;
+ Count++;
+ }
+ TabsSave.Set("Tab_Count", Count.ToString());
+ MainSave.Set("SelectedTabIndex", SelectedIndex.ToString());
+ }
+ }
+ Cef.Shutdown();
+ //MainSave.Save();
+ }
+ }
+}
\ No newline at end of file
diff --git a/SLBr/SLBr/NewsPage.xaml b/SLBr/SLBr/NewsPage.xaml
new file mode 100644
index 0000000..f216f57
--- /dev/null
+++ b/SLBr/SLBr/NewsPage.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/SLBr/NewsPage.xaml.cs b/SLBr/SLBr/NewsPage.xaml.cs
new file mode 100644
index 0000000..f64112d
--- /dev/null
+++ b/SLBr/SLBr/NewsPage.xaml.cs
@@ -0,0 +1,92 @@
+// 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.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.Xml;
+
+namespace SLBr
+{
+ ///
+ /// Interaction logic for NewsPage.xaml
+ ///
+ public partial class NewsPage : Window
+ {
+ public static NewsPage Instance;
+
+ public NewsPage()
+ {
+ InitializeComponent();
+ Instance = this;
+ }
+
+ private void Page_Loaded(object sender, RoutedEventArgs e)
+ {
+ DarkTheme(bool.Parse(MainWindow.Instance.MainSave.Get("DarkTheme")));
+ }
+
+ //SUPPORT FOR MULTI NEWS LIKE YANDEX, GOOGLE ETC
+
+ private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ var _TextBox = sender as TextBox;
+
+ if (e.Key == Key.Enter)
+ {
+ _TextBox.Text = _TextBox.Text.Trim();
+ string Url = $"https://news.google.com/rss";
+ if (_TextBox.Text.Length > 0)
+ Url = $"https://news.google.com/rss/search?q={_TextBox.Text.Replace(" ", "+")}";
+ XmlDataProvider XML = Resources["NewsRSSFeed"] as XmlDataProvider;
+ XML.Source = new Uri(Url);
+ }
+ }
+
+ private void RefreshButton_Click(object sender, RoutedEventArgs e)
+ {
+ XmlDataProvider XML = Resources["NewsRSSFeed"] as XmlDataProvider;
+ XML.Refresh();
+ }
+
+ private void Navigate(object sender, RoutedEventArgs e)
+ {
+ Button _Button = sender as Button;
+ XmlNode _XmlNode = _Button.Tag as XmlNode;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Navigate(_XmlNode.InnerText);
+ }));
+ }
+
+ public void DarkTheme(bool Toggle)
+ {
+ if (Toggle)
+ {
+ Resources["PrimaryBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#202225"));
+ Resources["FontBrush"] = new SolidColorBrush(Colors.White);
+ Resources["BorderBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#36393F"));
+ Resources["UnselectedTabBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F3136"));
+ Resources["ControlFontBrush"] = new SolidColorBrush(Colors.Gainsboro);
+ }
+ else
+ {
+ Resources["PrimaryBrush"] = new SolidColorBrush(Colors.White);
+ Resources["FontBrush"] = new SolidColorBrush(Colors.Black);
+ Resources["BorderBrush"] = new SolidColorBrush(Colors.Gainsboro);
+ Resources["UnselectedTabBrush"] = new SolidColorBrush(Colors.WhiteSmoke);
+ Resources["ControlFontBrush"] = new SolidColorBrush(Colors.Gray);
+ }
+ }
+ }
+}
diff --git a/SLBr/SLBr/Prompt.cs b/SLBr/SLBr/Prompt.cs
new file mode 100644
index 0000000..42427a4
--- /dev/null
+++ b/SLBr/SLBr/Prompt.cs
@@ -0,0 +1,24 @@
+// 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.
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SLBr
+{
+ public class Prompt
+ {
+ public string Content { get; set; }
+ public Visibility ButtonVisibility { get; set; }
+ public string ButtonContent { get; set; }
+ public string ButtonTag { get; set; }
+ public string ButtonToolTip { get; set; }
+ public string CloseButtonTag { get; set; }
+ public Visibility IconVisibility { get; set; }
+ public string IconText { get; set; }
+ public string IconRotation { get; set; }
+ }
+}
diff --git a/SLBr/SLBr/Properties/AssemblyInfo.cs b/SLBr/SLBr/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..50f35e2
--- /dev/null
+++ b/SLBr/SLBr/Properties/AssemblyInfo.cs
@@ -0,0 +1,56 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SLBr")]
+[assembly: AssemblyDescription("SLBr is a chromium-based browser made by SLT World, the descender of Skylight Browser, also made by SLT World")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("SLT World")]
+[assembly: AssemblyProduct("SLBr")]
+[assembly: AssemblyCopyright("Copyright SLT World © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("0.0.1.0")]
+[assembly: AssemblyFileVersion("0.0.1.0")]
+[assembly: NeutralResourcesLanguage("en-US")]
diff --git a/SLBr/SLBr/Properties/Resources.Designer.cs b/SLBr/SLBr/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..d5c8d37
--- /dev/null
+++ b/SLBr/SLBr/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SLBr.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SLBr.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/SLBr/SLBr/Properties/Resources.resx b/SLBr/SLBr/Properties/Resources.resx
new file mode 100644
index 0000000..ffecec8
--- /dev/null
+++ b/SLBr/SLBr/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Properties/Settings.Designer.cs b/SLBr/SLBr/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..a642cca
--- /dev/null
+++ b/SLBr/SLBr/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SLBr.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/SLBr/SLBr/Properties/Settings.settings b/SLBr/SLBr/Properties/Settings.settings
new file mode 100644
index 0000000..8f2fd95
--- /dev/null
+++ b/SLBr/SLBr/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/ResourceDictionary.xaml b/SLBr/SLBr/ResourceDictionary.xaml
new file mode 100644
index 0000000..a1a4def
--- /dev/null
+++ b/SLBr/SLBr/ResourceDictionary.xaml
@@ -0,0 +1,494 @@
+
+
+
+
+ Gainsboro
+ White
+ WhiteSmoke
+ Gray
+ Black
+ #0092FF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/About.html b/SLBr/SLBr/Resources/About.html
new file mode 100644
index 0000000..a5b415d
--- /dev/null
+++ b/SLBr/SLBr/Resources/About.html
@@ -0,0 +1,171 @@
+
+
+
+
+
+
+
+ About SLBr
+
+
+
+
+
+
+
+
+
+
Based on the powerful Chromium platform
+
+ SLBr uses the lightweight .NET wrapper around the Chromium Embedded Framework (CEF) , CEFSharp, to render webpages and local files.
+
+
+ With the powerful Chromium browser engine, SLBr is able to stay lightweight and isn't required to use Internet Explorer, download Chromium Edge to use WebView2 or a heavy customized browser engine as the main intergrated browser engine, while also having access to Chromium's rich and useful features that can be developed into much useful features and get implemented.
+
+
+
+
+
+
Links of Interest & References
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Blank.html b/SLBr/SLBr/Resources/Blank.html
new file mode 100644
index 0000000..2c4ab6b
--- /dev/null
+++ b/SLBr/SLBr/Resources/Blank.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+ Blank
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/CannotConnect.html b/SLBr/SLBr/Resources/CannotConnect.html
new file mode 100644
index 0000000..6d1088d
--- /dev/null
+++ b/SLBr/SLBr/Resources/CannotConnect.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+ Cannot Connect
+
+
+
+ Cannot Connect
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/CdmSupport.html b/SLBr/SLBr/Resources/CdmSupport.html
new file mode 100644
index 0000000..3cc2807
--- /dev/null
+++ b/SLBr/SLBr/Resources/CdmSupport.html
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+ SLBr Cdm Support
+
+
+
+
+
+
+ Google Shaka Player demo - video play back
+
+
+ Note:
+
+
+
+ Proprietary codecs (such as H.264 ) are not supported due to
+ licensing requirements.
+
+
+
+
+
+
diff --git a/SLBr/SLBr/Resources/Copy_Icon.svg b/SLBr/SLBr/Resources/Copy_Icon.svg
new file mode 100644
index 0000000..c1c4e68
--- /dev/null
+++ b/SLBr/SLBr/Resources/Copy_Icon.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/SLBr/SLBr/Resources/Deception.html b/SLBr/SLBr/Resources/Deception.html
new file mode 100644
index 0000000..7ba6639
--- /dev/null
+++ b/SLBr/SLBr/Resources/Deception.html
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+ Deceptive Site Warning
+
+
+
+ The site ahead is a deceptive site
+ The site you are trying to visit is deceptive, it tricks you into revealing your passwords, credit cards and personal information, the content of the site is personating like a page from a trusted entity (for example, a big corporation, a browser, a internet service, operating system, bank or government)
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Default.css b/SLBr/SLBr/Resources/Default.css
new file mode 100644
index 0000000..4af5a98
--- /dev/null
+++ b/SLBr/SLBr/Resources/Default.css
@@ -0,0 +1,126 @@
+/*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.*/
+
+* {
+ text-decoration: none;
+ list-style: none;
+ box-sizing: border-box;
+ padding: 0;
+ margin: 0;
+}
+
+html {
+ scroll-behavior: smooth;
+}
+
+
+.dark-mode {
+ filter: invert(1) hue-rotate(180deg)
+}
+
+.invert {
+ filter: invert(1) hue-rotate(180deg)
+}
+
+body {
+ font-family: Montserrat;
+}
+
+::-webkit-scrollbar {
+ width: 0px;
+}
+
+::-webkit-scrollbar-track {
+ border-radius: 5px;
+ background-color: rgba(0, 0, 0, 0.25);
+}
+
+::-webkit-scrollbar-thumb {
+ border-radius: 5px;
+ background-color: #009578;
+}
+
+::-webkit-scrollbar-thumb:hover {
+ background-color: #6DCDB1;
+ transition: 0.5s;
+ -o-transition: background 0.5s;
+ -moz-transition: background 0.5s;
+ -webkit-transition: background 0.5s;
+}
+
+.MainContent {
+}
+
+section {
+ width: 100%;
+ float: left;
+ height: 100vh;
+}
+
+#CodeEditor {
+ background-color: rgb(244, 245, 247);
+}
+
+.Container {
+ padding: 25px;
+}
+
+/*Start Code Editor*/
+
+.CodeGrid {
+ display: flex;
+ grid-template-columns: auto auto auto auto;
+ grid-gap: 25px;
+ height: 46vh;
+ width: 100%;
+ margin: 0 0 25px 0;
+ justify-content: center;
+ align-items: stretch;
+}
+
+.HTMLTextArea, .CSSTextArea, .JSTextArea, pre {
+ -o-tab-size: 2;
+ tab-size: 2;
+ display: flex;
+ width: 100%;
+ padding: 18px;
+ border-radius: 8px;
+ background-color: #333333;
+ overflow-x: hidden;
+ overflow-y: auto;
+ white-space: pre;
+ outline: none;
+ font-size: 15px;
+ border: none;
+ resize: none;
+ color: gray;
+}
+
+.CodeDisplayFrame {
+ display: flex;
+ width: 100%;
+ height: 46vh;
+ padding: 18px;
+ border-radius: 8px;
+ background-color: #FFFFFF;
+ border: none;
+ right: 0;
+}
+
+.RunButton {
+ border: none;
+ background-color: lightgreen;
+ color: white;
+ padding: 5px 5px;
+ text-align: center;
+ text-decoration: none;
+ display: inline-block;
+ font-size: 16px;
+ cursor: pointer;
+ border-radius: 8px;
+ align-items: center;
+ justify-content: center;
+ position: relative;
+}
+
+/*End Code Editor*/
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Default.js b/SLBr/SLBr/Resources/Default.js
new file mode 100644
index 0000000..139cc33
--- /dev/null
+++ b/SLBr/SLBr/Resources/Default.js
@@ -0,0 +1,38 @@
+/*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.*/
+
+var htmlbox = document.querySelector(".HTMLTextArea");
+var cssbox = document.querySelector(".CSSTextArea");
+var jsbox = document.querySelector(".JSTextArea");
+function CompileCodeEditor() {
+ var html = htmlbox.value;
+ /*var css = "";
+ if(cssbox.value == "")
+ css = "";*/
+ var css = "";
+ var js = "";
+ var frame = document.querySelector(".CodeDisplayFrame").contentWindow.document;
+ frame.open();
+ frame.write(html + css + js);
+ frame.close();
+}
+
+function Download() {
+ var html = htmlbox.value;
+ var css = "";
+ var js = "";
+ download("htmleditorscript.html", html + css + js);
+}
+
+function download(filename, text) {
+ var element = document.createElement('a');
+ element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
+ element.setAttribute('download', filename);
+
+ element.style.display = 'none';
+ document.body.appendChild(element);
+
+ element.click();
+
+ document.body.removeChild(element);
+}
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/DevToolsTests.html b/SLBr/SLBr/Resources/DevToolsTests.html
new file mode 100644
index 0000000..7524005
--- /dev/null
+++ b/SLBr/SLBr/Resources/DevToolsTests.html
@@ -0,0 +1,82 @@
+
+
+
+
+ SLBr DevTools Tests
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Dino.html b/SLBr/SLBr/Resources/Dino.html
new file mode 100644
index 0000000..699aba1
--- /dev/null
+++ b/SLBr/SLBr/Resources/Dino.html
@@ -0,0 +1,191 @@
+
+
+
+
+
+ Dino Game
+
+
+
+
+
+ Restart
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/GeolocationTest.html b/SLBr/SLBr/Resources/GeolocationTest.html
new file mode 100644
index 0000000..5c02028
--- /dev/null
+++ b/SLBr/SLBr/Resources/GeolocationTest.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ SLBr Geolocation Test
+
+
+
+ Display Location
+
+
+
+
diff --git a/SLBr/SLBr/Resources/HTMLEditor.html b/SLBr/SLBr/Resources/HTMLEditor.html
new file mode 100644
index 0000000..5da81eb
--- /dev/null
+++ b/SLBr/SLBr/Resources/HTMLEditor.html
@@ -0,0 +1,60 @@
+
+
+
+
+ HTML Editor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Run
+
+
+ Download
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/SLBr/Resources/License.html b/SLBr/SLBr/Resources/License.html
new file mode 100644
index 0000000..7078fc6
--- /dev/null
+++ b/SLBr/SLBr/Resources/License.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+ License
+
+
+
+
+// SLBr. The new, clean and lightweight .NET Web browser.
+// Copyright (C) 2022 SLT World
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Malware.html b/SLBr/SLBr/Resources/Malware.html
new file mode 100644
index 0000000..d7f7055
--- /dev/null
+++ b/SLBr/SLBr/Resources/Malware.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ Malware Warning
+
+
+
+ The site ahead contains malware
+ The site you are trying to visit contains malware, which is used by attackers to install dangerous programs on your computer that steals, leaks or deletes your information (for example, photons , passwords, messages, credit cards and personal information)
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/NewTab.html b/SLBr/SLBr/Resources/NewTab.html
new file mode 100644
index 0000000..0abd09b
--- /dev/null
+++ b/SLBr/SLBr/Resources/NewTab.html
@@ -0,0 +1,46 @@
+
+
+
+
+
+ New Tab
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Plans.html b/SLBr/SLBr/Resources/Plans.html
new file mode 100644
index 0000000..3296223
--- /dev/null
+++ b/SLBr/SLBr/Resources/Plans.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+ SLBr Major Planned Features
+
+
+
+ List of major planned features
+ The features here are what the user should expect for the next updates
+ Any of the features listed in here could be potentially delayed or made early
+
+
Unspecified
+
+ Full Smooth Scrolling Support without raising too much cpu
+ Default System Browser
+ Better HTML File Association
+ Tab Grouping
+ Draggable Tabs
+ User Credential Cache
+ History Tree & History Per Tab
+ Customizable Flags/Command Line Arguments
+ Print Preview
+ CHM Support
+ Multi-Users
+ Plug-ins/Add-ons/Extensions
+ Tor Connection
+ FTP Client
+ Easter Eggs
+ Tab Hover Cards to view content
+ SLBr Support Forum
+ OpenH264 Implementation
+ Touch Mode
+ Caret Browsing
+ Adobe Flash
+
+
SLBr 4
+
+
SLBr 3
+
+ Custom Themes/Skins
+ Full WebGL Support [Toggle WebGL Toggle in the Menu, the page will reload]
+ Improved Security
+ Force Dark Mode on Web Contents
+ Dark Mode syncing with OS Theme
+ prefers-color-scheme Media Query Support
+ Loading Screen Color
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/SLBr-Urls.html b/SLBr/SLBr/Resources/SLBr-Urls.html
new file mode 100644
index 0000000..85a3c05
--- /dev/null
+++ b/SLBr/SLBr/Resources/SLBr-Urls.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/SLBrUADetector.html b/SLBr/SLBr/Resources/SLBrUADetector.html
new file mode 100644
index 0000000..e174aa7
--- /dev/null
+++ b/SLBr/SLBr/Resources/SLBrUADetector.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+ SLBr UA Detector
+
+
+
+ This shows that SLBr is possible to be detectable with only the simplest way possible, by using the user agent only. Code below
+ const SLBr = window.navigator.userAgent.toLowerCase() && /slbr/i.test(window.navigator.userAgent.toLowerCase())
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Updates.html b/SLBr/SLBr/Resources/Updates.html
new file mode 100644
index 0000000..cf17912
--- /dev/null
+++ b/SLBr/SLBr/Resources/Updates.html
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+ SLBr Updates
+
+
+
+
+
+
VERSIONHERE - SLBr's Second Update
+
+ What are the new features?
+ Improved Performance [Disabling Proxy Servers, Limiting callbacks that calls more than ones, Removing features that don't generally help out with anything (i.e. Smooth Scrolling)]
+ Pinning and Unpinning tabs
+ Sharp Text
+ Code Cleanup
+ Google Weblight Loading
+ Keyboard Shortcuts
+
+ More context menus
+ Javascript Binding Support (Functions are accessible by JS using the code `slbr.FUNCTION()`)
+ Settings will notify if the change is made.
+
+ Hide Tabs
+ Website parameters are hidden unless you click or hover over the address bar
+ No proxy server slightly improves initialization time as it won't attempt to resolve a proxy
+ Slightly improved performance by utilizing the same instance for multiple small tasks
+ Modes (Pin SLBr on the taskbar, close SLBr, right click on SLBr and click on one of the "Open in ----" actions)
+ Default Mode
+ Private Mode (Incognito) [No browsing history will be saved, in-memory cache will be used]
+ Developer Mode [Developer/Experimental features & functionalities]
+ Chromium Mode [API Keys will not be assigned, some functionalities will be disabled and the useragent will be chromium's]
+ Internet Explorer Mode [Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors. But hey, at least you can test out a website and see how bad it's styling gets.]
+ What are the changes?
+ Dark Theme will be enabled for default
+ Menu/Tools/Tests is now only accessible by using the developer mode
+ UI improvements
+ Message Panel
+ Dark mode will be forced into web contents
+ The address bar will allow text to be dragged into it
+ Instead of the built-in 404 page, the browser will show a message asking to check if there's a saved version on Wayback Machine (Idea inspired by Brave)
+ What are the supported features of this update?
+ Full AdBlock Support
+ Weblight Loading
+ Full WebGL Support
+ Set as Default Browser Option
+ Account Sign-In (Browser)
+ Proprietary Codecs
+ Javascript Binding
+ Extensions, Plug-Ins, Add-ons
+ Proxy
+ Tor Network (The Onion Router Network)
+
+
2020.2.25.0 - The Start of SLBr
+
+ What are the new features?
+ Basic Functions [Back, Forward, Refresh, Stop Loading, Home]
+ Basic Needs [Tabs, Settings, Favourites, History, Downloads (with Download Location Dialog), Cache]
+ User-friendly UI
+ Fast Lightweight Rendering Engine
+ Security Functions [SSL Certificate Checker, Anti-malware & Anti-phishing]
+ Built-in pages [Error Pages, Warning Pages, Information pages (slbr://urls )]
+ Include "search:" in front of a text containing a dot (Which is seen as a domain by SLBr)
+ Customizable Features [Homepage, Search Provider, Download Path]
+ Other Features [Dark Theme, Restore tabs from previous session, Block keywords, Ask for download path, Ask to set as default search provider]
+ If you're interested in some country news, you can use the News Feed tool
+ The browser doesn't support saving the back and forth history
+ Keywords such as gacha and roblox are blocked for default, you can disable or change it in settings
+ HTML File Association
+ What are the changes?
+ -
+ What are the supported features of this update?
+ AdBlock Support
+
+
+ Minor WebGL Support
+ Cache
+ Set as Default Browser Option
+ Google Account Sign-In (Website)
+ Account Sign-In (Browser)
+ Safe Browsing API
+ PDF Viewer
+ Proprietary Codecs
+ Javascript Binding
+ Extensions
+ Proxy
+ Tor Network (The Onion Router Network)
+ ARM Build
+
+
+
+ SLBr was made possible by Windows Presentation Forms , The Chromium Project , Chromium Embedded Framework and CEFSharp . If you can, please donate and support them. It will contribute greatly to SLBr and every developer using them as well.
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Urls.html b/SLBr/SLBr/Resources/Urls.html
new file mode 100644
index 0000000..986ec0d
--- /dev/null
+++ b/SLBr/SLBr/Resources/Urls.html
@@ -0,0 +1,31 @@
+
+
+waa
+
+
+
+
+ SLBr URLs
+
+
+
+ List of SLBr Urls
+
+
+
diff --git a/SLBr/SLBr/Resources/Version.html b/SLBr/SLBr/Resources/Version.html
new file mode 100644
index 0000000..0a94a8f
--- /dev/null
+++ b/SLBr/SLBr/Resources/Version.html
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+ SLBr Version
+
+
+
+
+
+
SLBr
+
SLT World
+
Copyright © 2022 SLT World. All rights reserved.
+
+
+
+
+
+ SLBr
+
+
+ Version
+ (Official Build)
+ Bit Process
+
+
+
+
+
+
+
+ Chromium
+
+ Chromium Version
+
+
+
+ Internet Explorer
+
+ IE Version
+
+
+
+
+
+
+ Operating System
+
+ Operating System
+
+
+
+
+
+
+
+
+ JavaScript
+
+ V8
+ Javascript Version
+
+
+
+
+ User Agent
+
+ User Agent
+
+
+
+ Command Line
+
+ Command Line
+
+
+
+
+ Executable Path
+
+ Executable Path
+
+
+
+ Cache Path
+
+ Cache Path
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/Welcome.html b/SLBr/SLBr/Resources/Welcome.html
new file mode 100644
index 0000000..035d990
--- /dev/null
+++ b/SLBr/SLBr/Resources/Welcome.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ Welcome to SLBr
+
+
+
+ SLBr
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/WhatsNew.html b/SLBr/SLBr/Resources/WhatsNew.html
new file mode 100644
index 0000000..cfd65ed
--- /dev/null
+++ b/SLBr/SLBr/Resources/WhatsNew.html
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+ About SLBr
+
+
+
+
+
+
+
+
+
+
What's New in SLBr 2022.3.13.0
+
+ Every update of SLBr delivers many new features.
+
+
+
UI Changes
+
+ The settings tab/window will notify if a change is made successfully.
+ Find box and new tab button added to the top control bar
+ An improved context menu
+ Sharper Text
+ Tab pinning
+ URL Eliding (Meaning the "https://" and "www." will be hidden. There's an option to show the full URL in the Settings tab/window)
+ Dark mode will be forced into web contents
+ Text are now draggable into the address bar
+ PDF Viewer controls made visible
+ Native Built-in Prompts
+ When a request returns 404, SLBr will prompt a question asking to check if there's a saved version on Wayback Machine instead of displaying a 404 page
+
+
New developer features
+
+ Javascript Binding (Various functions are accessible by JS using the code `slbr.FUNCTION()`)
+ Faster website loading with Google Weblight
+ Screenshot feature (Still in development)
+ Tests menu
+ Developer mode, Developer/Experimental features & functionalities will be enabled.
+ Chromium mode, API Keys will not be assigned, some functionalities will be disabled and the useragent will be chromium's.
+ Internet Explorer mode, Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors.
+
+
Other new features
+
+ More URL Schemes Supported
+ Performance slightly improved
+
+
+ Code Cleanup
+ Tab Unloading - 12/3/2022
+ Limited renderer processes
+ Disabled lots of unused, untouched and unnoticed features of the Chromium of SLBr, features that SLBr doesn't have to support (i.e. Smooth Scrolling, Low Resolution Tiling, Plugins/Add-ons/Extensions, Proxies)
+ Disabled some parts of the GPU Acceleration because using the gpu is noticeably unreliable, but kept the rest for a limited WebGL support
+ No plugins/add-ons/extensions are needed to be initialized since SLBr does not support these
+ Without Proxy servers slightly improve the initialization time of SLBr as it won't attempt to resolve a proxy
+ Utilized a single instance for multiple small tasks
+ Removed callbacks that returns more than once.
+
+ Keyboard Shortcuts
+
+
+ Ctrl+R, F5 (Refresh)
+ Ctrl+T (New Tab)
+ Ctrl+W (Close Tab)
+ Ctrl+S (Screenshot)
+ F12 (Developer Tools)
+
+
+ Modes
+
+
+ Private mode (Incognito), No browsing history will be saved, in-memory cache will be used.
+ Developer mode, Developer/Experimental features & functionalities will be enabled.
+ Chromium mode, API Keys will not be assigned, some functionalities will be disabled and the useragent will be chromium's.
+ Internet Explorer mode, Javascript will not function properly and much of SLBr's functionalities will be disabled/broken. There will also be unexpected crashes and lots of errors.
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/Resources/style.css b/SLBr/SLBr/Resources/style.css
new file mode 100644
index 0000000..f3f08d4
--- /dev/null
+++ b/SLBr/SLBr/Resources/style.css
@@ -0,0 +1,123 @@
+html {
+ background: white;
+}
+
+body {
+ font-family: 'Segoe UI', Tahoma, sans-serif;
+}
+
+/*#checkboxes {
+ float: left;
+}*/
+
+#checkboxes ul {
+ /*margin: 0;*/
+ padding: 0;
+ list-style: none;
+ /*float: left;*/
+}
+
+#checkboxes ul li input {
+ vertical-align: -1px;
+ padding: 0;
+ margin-right: 7.5px;
+ /*vertical-align: middle;*/
+ overflow: visible;
+}
+
+#checkboxes ul li p {
+ padding: 0;
+ margin: 0;
+ margin-left: 5px;
+ overflow: visible;
+}
+
+h3 {
+ margin: 7.5px 0px;
+}
+
+h4 {
+ margin: 7.5px 0px;
+}
+
+.AboutHeader {
+ padding: 60px;
+ text-align: center;
+ background: #F5F5F5;
+ /*color: white;*/
+ font-size: 30px;
+}
+
+.AboutContent {
+ padding: 20px;
+}
+
+.AboutContent p {
+ margin: 1px;
+}
+
+a {
+ text-decoration: none;
+ color: #646464;
+}
+a:hover {
+ color: #808080;
+}
+
+.NewTabSearchContainer {
+ /*margin-top: 20%;*/
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ overflow: auto;
+}
+
+.Center {
+ /*position: absolute;
+ top: 50%;
+ -ms-transform: translateY(-50%);
+ transform: translateY(-50%);*/
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.SearchInput {
+ display: flex;
+ align-items: center;
+ border: 1px solid lightgray;
+ height: 30px;
+ padding: 2.5px 20px;
+ border-radius: 999px;
+ width: 75vw;
+ margin: 0 auto;
+ max-width: 560px;
+
+}
+
+.SearchInput input {
+ flex: 1;
+ padding: 10px 0;/*20px*/
+ border: none;
+ outline: none;
+}
+
+.SearchInput .material-icons {
+ color: gray;
+}
+
+.List ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ /*float: left;*/
+}
+
+.List ul li {
+ padding: 0;
+ margin: 0;
+ margin-left: 15px;
+ overflow: visible;
+}
\ No newline at end of file
diff --git a/SLBr/SLBr/SLBr.csproj b/SLBr/SLBr/SLBr.csproj
new file mode 100644
index 0000000..bc5315c
--- /dev/null
+++ b/SLBr/SLBr/SLBr.csproj
@@ -0,0 +1,285 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7816736D-3C43-4D68-9A4D-9F0825372E97}
+ WinExe
+ SLBr
+ SLBr
+ v4.7.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ app.manifest
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 7.3
+ prompt
+ true
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ 7.3
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ 7.3
+ prompt
+ true
+
+
+ SLBr.App
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+ NewsPage.xaml
+
+
+
+ SettingsPage.xaml
+
+
+ SettingsWindow.xaml
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+ PreserveNewest
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ .editorconfig
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+ 99.2.90
+
+
+ 1.11.42
+
+
+ 10.0.22000.196
+
+
+ 13.0.1
+
+
+ 6.0.0
+
+
+ 4.7.0
+
+
+ 4.7.0
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SLBr/SLBr/SLBrBrowserModel.cs b/SLBr/SLBr/SLBrBrowserModel.cs
new file mode 100644
index 0000000..a91f556
--- /dev/null
+++ b/SLBr/SLBr/SLBrBrowserModel.cs
@@ -0,0 +1,293 @@
+// 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.
+
+using CefSharp;
+using CefSharp.Wpf;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+//using Microsoft.mshtml;
+
+namespace SLBr
+{
+ public class SLBrBrowserModel
+ {
+ public enum EngineType
+ {
+ Blink,
+ Trident,
+ Gecko,
+ EdgeHTML,
+ WebKit,
+ }
+
+ public EngineType _EngineType;
+ public ChromiumWebBrowser _Blink;
+ public WebBrowser _Trident;
+ public float ZoomLevel;
+ public float ZoomLevelIncrement;
+
+ public SLBrBrowserModel(EngineType _EngineType, string Url, float _ZoomLevelIncrement = 0, object Custom = null)
+ {
+ this._EngineType = _EngineType;
+ ZoomLevelIncrement = _ZoomLevelIncrement;
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ if (Custom != null)
+ _Blink = Custom as ChromiumWebBrowser;
+ else
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ _Blink = new ChromiumWebBrowser();
+ }));
+ //MessageBox.Show(_Blink.ActualWidth.ToString());
+ _Blink.Address = Url;
+ //_Blink.BeginInit();
+ //ZoomLevel = float.Parse(_Blink.ZoomLevel.ToString());
+ //_Blink.ZoomLevelIncrement = ZoomLevelIncrement;
+ break;
+ case EngineType.Trident:
+ _Trident = new WebBrowser();
+ //_Trident.Navigate(Url);
+ break;
+ }
+ //MessageBox.Show(_Blink.Address);
+ //Navigate(Url);
+ }
+
+ public string Url()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ return _Blink.Address;
+ case EngineType.Trident:
+ return _Trident.Source.AbsoluteUri;
+ }
+ return string.Empty;
+ }
+ public string Title()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ return _Blink.Title;
+ case EngineType.Trident:
+ return /*((dynamic)_Trident.Document).Title;-*/(string)_Trident.InvokeScript("eval", "document.title.toString()");
+ }
+ return string.Empty;
+ }
+
+ /*public object GetEngine()
+ {
+ switch (_BrowserType)
+ {
+ case EngineType.Blink:
+ return _Blink;
+ case EngineType.Trident:
+ return _Trident;
+ }
+ return null;
+ }*/
+
+
+ public void Dispose()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Dispose();
+ break;
+ case EngineType.Trident:
+ _Trident.Dispose();
+ break;
+ }
+ }
+
+ public void Navigate(string Url)
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Address = Url;
+ break;
+ case EngineType.Trident:
+ _Trident.Navigate(Url);
+ break;
+ }
+ }
+ public void Back()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Back();
+ break;
+ case EngineType.Trident:
+ _Trident.GoBack();
+ break;
+ }
+ }
+ public void Forward()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Forward();
+ break;
+ case EngineType.Trident:
+ _Trident.GoForward();
+ break;
+ }
+ }
+ public void Refresh()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Reload();
+ break;
+ case EngineType.Trident:
+ _Trident.Refresh();
+ break;
+ }
+ }
+ public void Stop()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ if (_Blink.IsBrowserInitialized)
+ _Blink.Stop();
+ break;
+ case EngineType.Trident:
+ _Trident.InvokeScript("eval", "document.execCommand('Stop');");
+ break;
+ }
+ }
+ public void Print()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Print();
+ break;
+ /*case EngineType.Trident:
+ mshtml.IHTMLDocument2 doc = _Trident.Document as mshtml.IHTMLDocument2;
+ doc.execCommand("Print", true, null);
+ break;*/
+ }
+ }
+ public void ShowDevTools()
+ {
+ //MessageBox.Show("e");
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ if (_Blink.IsBrowserInitialized)
+ _Blink.ShowDevTools();
+ break;
+ /*case EngineType.Trident:
+ mshtml.IHTMLDocument2 doc = _Trident.Document as mshtml.IHTMLDocument2;
+ doc.execCommand("Print", true, null);
+ break;*/
+ }
+ }
+
+ public bool CanGoBack()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ return _Blink.CanGoBack;
+ case EngineType.Trident:
+ return _Trident.CanGoBack;
+ }
+ return true;
+ }
+ public bool CanGoForward()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ return _Blink.CanGoForward;
+ case EngineType.Trident:
+ return _Trident.CanGoForward;
+ }
+ return true;
+ }
+ public bool IsLoaded()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ return _Blink.IsLoaded;
+ case EngineType.Trident:
+ return _Trident.IsLoaded;
+ }
+ return true;
+ }
+
+ public void SetZoom(float Value)
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ ZoomLevel = Value;
+ _Blink.SetZoomLevel(Value);
+ break;
+ /*case EngineType.Trident:
+ mshtml.IHTMLDocument2 doc = _Trident.Document as mshtml.IHTMLDocument2;
+ doc.parentWindow.execScript("document.body.style.zoom=" + Value.ToString().Replace(",", ".") + ";");
+ break;*/
+ }
+ }
+ public void Find(string Text, bool Forward, bool MatchCase, bool FindNext)
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.Find(Text, Forward, MatchCase, FindNext);
+ break;
+ }
+ }
+ public void StopFinding(bool ClearSelection)
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ _Blink.StopFinding(ClearSelection);
+ break;
+ }
+ }
+
+ public string Source()
+ {
+ switch (_EngineType)
+ {
+ case EngineType.Blink:
+ string Source = string.Empty;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ _Blink.GetMainFrame().EvaluateScriptAsync(@"document.getElementsByTagName('html')[0]").ContinueWith(t =>
+ {
+ if (t.Result != null && t.Result.Result != null)
+ {
+ var result = t.Result.Result.ToString();
+ Source = result;
+ }
+ });
+ }));
+ return Source;
+ /*case EngineType.Trident:
+ return (_Trident.Document as mshtml.IHTMLDocument2).body.outerHTML;*/
+ }
+ return "";
+ }
+ }
+}
diff --git a/SLBr/SLBr/SettingsPage.xaml b/SLBr/SLBr/SettingsPage.xaml
new file mode 100644
index 0000000..e1467d3
--- /dev/null
+++ b/SLBr/SLBr/SettingsPage.xaml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Search Provider
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Download
+
+
+
+
+
+
+
+
+ Blocked Keywords
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/SLBr/SettingsPage.xaml.cs b/SLBr/SLBr/SettingsPage.xaml.cs
new file mode 100644
index 0000000..2f7f481
--- /dev/null
+++ b/SLBr/SLBr/SettingsPage.xaml.cs
@@ -0,0 +1,265 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace SLBr
+{
+ public partial class SettingsPage : Page
+ {
+ public SettingsPage()
+ {
+ InitializeComponent();
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ foreach (string Url in MainWindow.Instance.SearchEngines)
+ {
+ if (!SearchEngineComboBox.Items.Contains(Url))
+ SearchEngineComboBox.Items.Add(Url);
+ }
+ //if (MainWindow.Instance.MainSave.Has("Search_Engine"))
+ //{
+ string Search_Engine = MainWindow.Instance.MainSave.Get("Search_Engine");
+ if (SearchEngineComboBox.Items.Contains(Search_Engine))
+ SearchEngineComboBox.SelectedValue = Search_Engine;
+ //}
+ //if (MainWindow.Instance.MainSave.Has("Homepage"))
+ HomepageTextBox.Text = MainWindow.Instance.MainSave.Get("Homepage");
+ DownloadPathTextBox.Text = MainWindow.Instance.MainSave.Get("DownloadPath");
+ //if (MainWindow.Instance.MainSave.Has("DarkTheme"))
+ DarkThemeCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("DarkTheme"));
+
+ BlockedKeywordsTextBox.Text = MainWindow.Instance.MainSave.Get("BlockedKeywords");
+ BlockRedirectTextBox.Text = MainWindow.Instance.MainSave.Get("BlockRedirect");
+ BlockKeywordsCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("BlockKeywords"));
+
+ RestoreTabsCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("RestoreTabs"));
+ AskForDownloadPathCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("AFDP"));
+ ATSADSECheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("ATSADSE"));
+ DarkTheme(bool.Parse(MainWindow.Instance.MainSave.Get("DarkTheme")));
+ SearchEngineComboBox.SelectionChanged += SearchEngineComboBox_SelectionChanged;
+ HideTabsCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("HideTabs"));
+ WeblightCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("Weblight"));
+ TabUnloadingCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("TabUnloading"));
+ FullAddressCheckBox.IsChecked = bool.Parse(MainWindow.Instance.MainSave.Get("FullAddress"));
+ }
+
+ public void DarkTheme(bool Toggle)
+ {
+ if (Toggle)
+ {
+ Resources["PrimaryBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#202225"));
+ Resources["FontBrush"] = new SolidColorBrush(Colors.White);
+ Resources["BorderBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#36393F"));
+ Resources["UnselectedTabBrush"] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F3136"));
+ Resources["ControlFontBrush"] = new SolidColorBrush(Colors.Gainsboro);
+ }
+ else
+ {
+ Resources["PrimaryBrush"] = new SolidColorBrush(Colors.White);
+ Resources["FontBrush"] = new SolidColorBrush(Colors.Black);
+ Resources["BorderBrush"] = new SolidColorBrush(Colors.Gainsboro);
+ Resources["UnselectedTabBrush"] = new SolidColorBrush(Colors.WhiteSmoke);
+ Resources["ControlFontBrush"] = new SolidColorBrush(Colors.Gray);
+ }
+ }
+
+ private void SearchEngineComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ ComboBox _ComboBox = (ComboBox)sender;
+ MainWindow.Instance.MainSave.Set("Search_Engine", _ComboBox.SelectedValue.ToString());
+ NewMessage("The default search provider has been successfully changed and saved.", false);
+ }
+
+ private void HomepageTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter && HomepageTextBox.Text.Trim().Length > 0)
+ {
+ HomepageTextBox.Text = Utils.FixUrl(HomepageTextBox.Text, false);
+ /*if (HomepageTextBox.Text.Contains("."))
+ {
+ MainWindow.Instance.MainSave.Set("Homepage", HomepageTextBox.Text);
+ }
+ else
+ {
+ MainWindow.Instance.MainSave.Set("Homepage", new Uri(MainWindow.Instance.MainSave.Get("Search_Engine")).Host);
+ }*/
+ NewMessage("The homepage has been successfully changed and saved.", false);
+ }
+ }
+
+ private void ASEPrefixTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Enter && ASEPrefixTextBox.Text.Trim().Length > 0)
+ {
+ if (ASEPrefixTextBox.Text.Contains("."))
+ {
+ string Url = Utils.FixUrl(ASEPrefixTextBox.Text.Trim().Replace(" ", ""), false);
+ if (!Url.Contains("{0}"))
+ Url += "{0}";
+ MainWindow.Instance.SearchEngines.Add(Url);
+ if (!SearchEngineComboBox.Items.Contains(Url))
+ SearchEngineComboBox.Items.Add(Url);
+ SearchEngineComboBox.SelectedValue = Url;
+ MainWindow.Instance.MainSave.Set("Search_Engine", Url);
+ ASEPrefixTextBox.Text = string.Empty;
+ NewMessage("The entered search provider url has been successfully added to the list.", false);
+ }
+ }
+ }
+
+ private void DownloadPathTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ var _TextBox = sender as TextBox;
+ MainWindow.Instance.MainSave.Set("DownloadPath", _TextBox.Text);
+ NewMessage("Download path has been successfully changed and saved.", false);
+ }
+
+ private void BlockedKeywordsTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ var _TextBox = sender as TextBox;
+
+ if (e.Key == Key.Enter/* && _TextBox.Text.Trim().Length > 0*/)
+ {
+ _TextBox.Text = _TextBox.Text.Trim().ToLower();
+ //if (_TextBox.Text.Contains("slt,") || _TextBox.Text.Contains("sltworld,") || _TextBox.Text.Contains(",slt") || _TextBox.Text.Contains(",sltworld"))
+ //{
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, ",sltworld", false, true);
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, "sltworld,", false, false);
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, ",slt", false, true);
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, "slt,", false, false);
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, ",slbr", false, true);
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, "slbr,", false, false);
+ _TextBox.Text = _TextBox.Text.Replace(",sltworld,", ",");
+ _TextBox.Text = _TextBox.Text.Replace(",slt,", ",");
+ _TextBox.Text = _TextBox.Text.Replace(",slbr,", ",");
+ //}
+ //_TextBox.Text = Utils.RemovePrefix(_TextBox.Text, ",");
+ _TextBox.Text = Utils.RemovePrefix(_TextBox.Text, ",", false, true);
+ MainWindow.Instance.MainSave.Set("BlockedKeywords", _TextBox.Text);
+ NewMessage("Blocked Keywords has been successfully changed and saved.", false);
+ }
+ }
+
+ private void BlockRedirectTextBox_KeyDown(object sender, KeyEventArgs e)
+ {
+ var _TextBox = sender as TextBox;
+ if (e.Key == Key.Enter)
+ {
+ if (_TextBox.Text.Trim().Length == 0)
+ _TextBox.Text = MainWindow.Instance.MainSave.Get("Homepage");
+ else
+ _TextBox.Text = Utils.FixUrl(_TextBox.Text, false);
+ }
+ MainWindow.Instance.MainSave.Set("BlockRedirect", _TextBox.Text);
+ NewMessage($"SLBr will redirect to the entered url when a blocked keyword is detected.", false);
+ }
+
+ private void DarkThemeCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("DarkTheme", _CheckBox.IsChecked.ToString());
+ DarkTheme(bool.Parse(MainWindow.Instance.MainSave.Get("DarkTheme")));
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.DarkTheme(bool.Parse(MainWindow.Instance.MainSave.Get("DarkTheme")));
+ if (NewsPage.Instance != null)
+ {
+ NewsPage.Instance.DarkTheme(bool.Parse(MainWindow.Instance.MainSave.Get("DarkTheme")));
+ }
+ }));
+ //NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "" : "not")} enable dark theme.", false);
+ NewMessage($"SLBr Dark Theme has been {((bool)_CheckBox.IsChecked ? "enabled" : "disabled")}.", false);
+ }
+ private void BlockKeywordsCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("BlockKeywords", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "" : "not ")}block the entered keywords.", false);
+ //NewMessage($"Restore tabs has been {((bool)_CheckBox.IsChecked ? "enabled" : "disabled")}.", false);
+ }
+ private void RestoreTabsCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("RestoreTabs", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "" : "not ")}restore tabs.", false);
+ }
+ private void ATSADSECheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("ATSADSE", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "" : "not ")}ask if to set a search provider as the default search provider.", false);
+ }
+ private void HideTabsCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.HideTabs(_CheckBox.IsChecked == true ? true : false);
+ }));
+ }
+ private void AFDPCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("AFDP", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "" : "not ")}ask for download path on each download.", false);
+ }
+ private void RelaunchButton_Click(object sender, RoutedEventArgs e)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Relaunch();
+ }));
+ }
+ private void ResetButton_Click(object sender, RoutedEventArgs e)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Reset();
+ }));
+ }
+ private void CloseNoSaveButton_Click(object sender, RoutedEventArgs e)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Relaunch(false);
+ }));
+ }
+ private void WeblightCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("Weblight", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "" : "not ")}load websites with Weblight.", false);
+ }
+ private void TabUnloadingCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("TabUnloading", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "unload tabs free up resources and memory" : "not unload tabs")}.", false);
+ }
+ private void FullAddressCheckBox_Click(object sender, RoutedEventArgs e)
+ {
+ var _CheckBox = sender as CheckBox;
+ MainWindow.Instance.MainSave.Set("FullAddress", _CheckBox.IsChecked.ToString());
+ NewMessage($"SLBr will {((bool)_CheckBox.IsChecked ? "always " : "not ")}show full URLs.", false);
+ }
+ public void NewMessage(string Content, bool IncludeButton = true, string ButtonContent = "", string ButtonArguments = "", string ToolTip = "")
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ MainWindow.Instance.Prompt(Content, IncludeButton, ButtonContent, ButtonArguments, ToolTip);
+ }));
+ }
+ }
+}
diff --git a/SLBr/SLBr/SettingsWindow.xaml b/SLBr/SLBr/SettingsWindow.xaml
new file mode 100644
index 0000000..2bc864f
--- /dev/null
+++ b/SLBr/SLBr/SettingsWindow.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/SLBr/SLBr/SettingsWindow.xaml.cs b/SLBr/SLBr/SettingsWindow.xaml.cs
new file mode 100644
index 0000000..0e1089a
--- /dev/null
+++ b/SLBr/SLBr/SettingsWindow.xaml.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace SLBr
+{
+ ///
+ /// Interaction logic for SettingsWindow.xaml
+ ///
+ public partial class SettingsWindow : Window
+ {
+ public SettingsWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/SLBr/SLBr/TabPanel.cs b/SLBr/SLBr/TabPanel.cs
new file mode 100644
index 0000000..8978efe
--- /dev/null
+++ b/SLBr/SLBr/TabPanel.cs
@@ -0,0 +1,93 @@
+// 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.
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Input;
+
+namespace SLBr
+{
+ public class TabPanel : Panel
+ {
+ private double _rowHeight;
+ private double _scaleFactor;
+
+ // Ensure tabbing works correctly
+ static TabPanel()
+ {
+ KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(TabPanel), new FrameworkPropertyMetadata(KeyboardNavigationMode.Once));
+ KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(TabPanel), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
+ }
+
+ // This Panel lays its children out horizontally.
+ // If all children cannot fit in the allocated space,
+ // the available space is divided proportionally between them.
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ // See how much room the children want
+ double width = 0.0;
+ this._rowHeight = 0.0;
+ foreach (UIElement element in this.Children)
+ {
+ element.Measure(availableSize);
+ Size size = this.GetDesiredSizeLessMargin(element);
+ this._rowHeight = Math.Max(this._rowHeight, size.Height);
+ width += size.Width;
+ }
+
+ // If not enough room, scale the
+ // children to the available width
+ if (width > availableSize.Width)
+ {
+ this._scaleFactor = availableSize.Width / width;
+ width = 0.0;
+ foreach (UIElement element in this.Children)
+ {
+ element.Measure(new Size(element.DesiredSize.Width * this._scaleFactor, availableSize.Height));
+ width += element.DesiredSize.Width;
+ }
+ }
+ else
+ this._scaleFactor = 1.0;
+
+ return new Size(width, this._rowHeight);
+ }
+
+ // Perform arranging of children based on the final size
+ protected override Size ArrangeOverride(Size arrangeSize)
+ {
+ Point point = new Point();
+ foreach (UIElement element in this.Children)
+ {
+ Size size1 = element.DesiredSize;
+ Size size2 = this.GetDesiredSizeLessMargin(element);
+ Thickness margin = (Thickness)element.GetValue(FrameworkElement.MarginProperty);
+ double width = size2.Width;
+ if (element.DesiredSize.Width != size2.Width)
+ width = arrangeSize.Width - point.X; // Last-tab-selected "fix"
+ element.Arrange(new Rect(
+ point,
+ new Size(Math.Min(width, size2.Width), this._rowHeight)));
+ double leftRightMargin = Math.Max(0.0, -(margin.Left + margin.Right));
+ point.X += size1.Width + (leftRightMargin * this._scaleFactor);
+ }
+
+ return arrangeSize;
+ }
+
+ // Return element's size
+ // after subtracting margin
+ private Size GetDesiredSizeLessMargin(UIElement element)
+ {
+ Thickness margin = (Thickness)element.GetValue(FrameworkElement.MarginProperty);
+ Size size = new Size();
+ size.Height = Math.Max(0.0, element.DesiredSize.Height - (margin.Top + margin.Bottom));
+ size.Width = Math.Max(0.0, element.DesiredSize.Width - (margin.Left + margin.Right));
+ return size;
+ }
+ }
+}
diff --git a/SLBr/SLBr/Utils.cs b/SLBr/SLBr/Utils.cs
new file mode 100644
index 0000000..b441377
--- /dev/null
+++ b/SLBr/SLBr/Utils.cs
@@ -0,0 +1,488 @@
+// 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.
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Xml;
+using System.Xml.Linq;
+using System.Management;
+using System.Drawing;
+using CefSharp.Wpf;
+using System.Windows.Input;
+
+namespace SLBr
+{
+ public class Utils
+ {
+ public static uint ColorToUInt(Color color) =>
+ (uint)((color.A << 24) | (color.R << 16) | (color.G << 8) | (color.B << 0));
+ public static bool HasDebugger() =>
+ Debugger.IsAttached;
+ public static bool IsSystemUrl(string Url) =>
+ (IsInternalUrl(Url) || Url.StartsWith("file:") || Url.StartsWith("localhost:") || IsAboutUrl(Url) || Url.StartsWith("view-source:") || Url.StartsWith("devtools:") || Url.StartsWith("data:"));
+ public static bool IsProgramUrl(string Url) =>
+ (Url.StartsWith("callto:") || Url.StartsWith("mailto:") || Url.StartsWith("news:") || Url.StartsWith("feed:"));
+ public static bool IsInternalUrl(string Url) =>
+ Url.StartsWith("slbr:");
+ public static bool IsAboutUrl(string Url) =>
+ Url.StartsWith("about:");
+ public static bool IsBrowserUrlScheme(string Url) =>//NoHttps//WithCEFandChrome
+ IsSystemUrl(Url) || IsProgramUrl(Url) || IsInternalUrl(Url) || IsAboutUrl(Url) || IsChromeScheme(Url);
+ public static bool IsHttpScheme(string Url) =>//NoHttps
+ Url.StartsWith("https:") || Url.StartsWith("http:");
+ public static bool IsChromeScheme(string Url) =>
+ Url.StartsWith("cef:") || Url.StartsWith("chrome:");
+ public static bool IsSchemeNotHttp(string Url)
+ {
+ if (IsHttpScheme(Url))
+ return false;
+ if (Url.Contains(":"))
+ {
+ if (Url.Contains("."))
+ {
+ if (Url.IndexOf(".") < Url.IndexOf(":"))
+ {
+ return false;
+ }
+ else
+ return true;
+ }
+ else
+ return true;
+ }
+ return false;
+ }
+
+ public static string RemovePrefix(string Url, string Prefix, bool CaseSensitive = false, bool Back = false, bool ReturnCaseSensitive = true)
+ {
+ /*if (Url.Length >= Prefix.Length)
+ {*/
+ string NewUrl = CaseSensitive ? Url : Url.ToLower();
+ string CaseSensitiveUrl = Url;
+ string NewPrefix = CaseSensitive ? Prefix : Prefix.ToLower();
+ if ((Back ? NewUrl.EndsWith(NewPrefix) : NewUrl.StartsWith(NewPrefix)))
+ {
+ if (ReturnCaseSensitive)
+ return (Back ? CaseSensitiveUrl.Substring(0, CaseSensitiveUrl.Length - Prefix.Length) : CaseSensitiveUrl.Substring(Prefix.Length));
+ return (Back ? NewUrl.Substring(0, NewUrl.Length - Prefix.Length) : NewUrl.Substring(Prefix.Length));
+ }
+ //}
+ return Url;
+ }
+ public static string RemoveCharsAfterLastChar(string Content, string Prefix, bool KeepPrefix)
+ {
+ int Index = Content.LastIndexOf(Prefix);
+ if (Index >= 0)
+ Content = Content.Substring(0, Index + (KeepPrefix ? Prefix.Length : 0));
+ return Content;
+ }
+ public static string FilterUrlForBrowser(string Url, string SearchEngineUrl, bool Weblight, bool IsChromiumMode)
+ {
+ if (Url.Trim().Length > 0)
+ {
+ //MessageBox.Show($"{Url},{!Url.StartsWith("domain:")},{!Url.StartsWith("search:")}");
+ if (!Url.StartsWith("domain:") && !Url.StartsWith("search:"))
+ {
+ if (IsProgramUrl(Url))
+ {
+ Process.Start(Url);
+ return Url;
+ }
+ else if (!IsChromiumMode && Url.StartsWith("cef:"))
+ Url = "domain:chrome:" + Url.Substring(4);
+ else if ((Url.Contains(".") || IsSystemUrl(Url) || (IsChromiumMode && Url.StartsWith("chrome:"))) && !Url.Contains(" "))
+ Url = "domain:" + Url;
+ else
+ Url = "search:" + Url;
+ }
+ bool ContinueCheck = true;
+ if (Url.StartsWith("domain:"))
+ {
+ ContinueCheck = false;
+ string SubstringUrl = Url.Substring(7);
+ if (IsBrowserUrlScheme(SubstringUrl))
+ {
+ if (IsAboutUrl(SubstringUrl))
+ Url = FixUrl(SubstringUrl.Replace("about://", "slbr://").Replace("about:", "slbr://"), false);
+ else
+ Url = FixUrl(SubstringUrl, false);
+ }
+ else if (IsHttpScheme(SubstringUrl))
+ Url = FixUrl(SubstringUrl, Weblight);
+ else
+ {
+ if (IsSchemeNotHttp(SubstringUrl))
+ {
+ Url = "search:" + SubstringUrl;
+ ContinueCheck = true;
+ }
+ else
+ Url = FixUrl(SubstringUrl, Weblight);
+ }
+ }
+ if (ContinueCheck && Url.StartsWith("search:"))
+ Url = FixUrl(string.Format(SearchEngineUrl, Url.Substring(7)), Weblight);
+
+ //if (Url.ToLower().Contains("cefsharp.browsersubprocess"))
+ // MessageBox.Show("cefsharp.browsersubprocess is necessary for the browser engine to function accordingly.");
+ }
+ return Url;
+ }
+
+ public static string CleanUrl(string Url)
+ {
+ if (string.IsNullOrEmpty(Url))
+ return Url;
+ if (Url.StartsWith("chrome://"))
+ {
+ if (!MainWindow.Instance.IsChromiumMode)
+ Url = "cef" + Url.Substring(6);
+ }
+ int ToRemoveIndex = Url.LastIndexOf("?");
+ if (ToRemoveIndex >= 0)
+ Url = Url.Substring(0, ToRemoveIndex);
+ else
+ {
+ ToRemoveIndex = Url.LastIndexOf("#");
+ if (ToRemoveIndex >= 0)
+ Url = Url.Substring(0, ToRemoveIndex);
+ }
+ /*if (Url.EndsWith(".pdf#toolbar=0"))
+ Url = Utils.RemovePrefix(Url, "#toolbar=0", false, true);*/
+ Url = RemovePrefix(Url, "http://");
+ Url = RemovePrefix(Url, "https://");
+ Url = RemovePrefix(Url, "file:///");
+ //if (Url.Replace(new Uri(FixUrl(Url, false, false)).Host, "").Contains("/"))
+ Url = RemovePrefix(Url, "/", false, true);
+ return Url;
+ }
+ public static string FixUrl(string Url, bool Weblight/*, bool SearchEngine = false*/)
+ {
+ if (string.IsNullOrEmpty(Url))
+ return Url;
+
+ Url = Url.Trim();
+
+ //if (SearchEngine)
+ // Url = Url.Replace(" ", "+");
+ //else
+ //{
+ Url = Url.Replace(" ", "%20");//string.Empty
+ if (!IsSystemUrl(Url) && !Url.StartsWith("chrome:") && !Url.StartsWith("cef:"))
+ {
+ if (!Url.StartsWith("https://") && !Url.StartsWith("http://"))
+ Url = "https://" + Url;
+ //Use HTTPS for Incomplete URLs
+ }
+ //}
+ if (Weblight && !IsSystemUrl(Url))
+ Url = "https://googleweblight.com/?lite_url=" + CleanUrl(Url);
+ return Url;
+ }
+
+ public static bool CheckForInternetConnection(int timeoutMs = 1500, string url = null)
+ {
+ try
+ {
+ url = "http://www.gstatic.com/generate_204";
+
+ switch (CultureInfo.InstalledUICulture.Name)
+ {
+ case string s when s.StartsWith("fa"):
+ url = "http://www.aparat.com";
+ break;
+ case string s when s.StartsWith("zh"):
+ url = "http://www.baidu.com";
+ break;
+ };
+
+ var request = (HttpWebRequest)WebRequest.Create(url);
+ request.KeepAlive = false;
+ request.Timeout = timeoutMs;
+ using (var response = (HttpWebResponse)request.GetResponse())
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
+ public class SafeBrowsing
+ {
+ public enum ThreatType
+ {
+ Unknown,
+ Malware,
+ Potentially_Harmful_Application,
+ Social_Engineering,
+ Unwanted_Software,
+ }
+ enum PlatformType
+ {
+ Unknown,
+ All,
+ Android,
+ Any,
+ Chrome,
+ Ios,
+ Linux,
+ MacOS,
+ Windows,
+ }
+ enum ThreatEntryType
+ {
+ Unknown,
+ Executable,
+ IpAddressRange,
+ Url
+ }
+
+ string Payload;
+
+ string APIKey;
+ string ClientId;
+
+ public SafeBrowsing(string API_Key, string Client_Id)
+ {
+ APIKey = API_Key;
+ ClientId = Client_Id;
+ }
+
+ public ThreatType GetThreatType(string _Data)
+ {
+ ThreatType _Type = ThreatType.Unknown;
+ if (_Data.Length > 2)
+ {
+ dynamic Data = JObject.Parse(_Data);
+ try
+ {
+ dynamic Matches = Data.matches;
+ if (Matches[0].threatType == "MALWARE")
+ _Type = ThreatType.Malware;
+ if (Matches[0].threatType == "UNWANTED_SOFTWARE")
+ _Type = ThreatType.Unwanted_Software;
+ else if (Matches[0].threatType == "SOCIAL_ENGINEERING")
+ _Type = ThreatType.Social_Engineering;
+ if (_Type == ThreatType.Unknown)
+ {
+ if (Matches[1].threatType == "MALWARE")
+ _Type = ThreatType.Malware;
+ if (Matches[0].threatType == "UNWANTED_SOFTWARE")
+ _Type = ThreatType.Unwanted_Software;
+ else if (Matches[1].threatType == "SOCIAL_ENGINEERING")
+ _Type = ThreatType.Social_Engineering;
+ }
+ }
+ catch { }
+ }
+ return _Type;
+ }
+
+ public string Response(string Url)
+ {
+ if (APIKey == string.Empty)
+ {
+ Payload = $@"{{}}";
+ return Payload;
+ }
+ using (var _HttpClient = new HttpClient())
+ {
+ Payload = $@"{{
+ ""client"": {{
+ ""clientId"": ""{ClientId}"",
+ ""clientVersion"": ""1.0.0""
+ }},
+ ""threatInfo"": {{
+ ""threatTypes"": [""MALWARE"", ""SOCIAL_ENGINEERING"", ""UNWANTED_SOFTWARE""],
+ ""platformTypes"": [""CHROME"", ""WINDOWS""],
+ ""threatEntryTypes"": [""URL""],
+ ""threatEntries"": [
+ {{""url"": ""{Url}""}}
+ ]
+ }}
+ }}";
+
+ var Content = new StringContent(Payload, Encoding.Default, "application/json");
+
+ var Response = _HttpClient.PostAsync($"https://safebrowsing.googleapis.com/v4/threatMatches:find?key={APIKey}", Content).Result;
+ string ResultContent = Response.Content.ReadAsStringAsync().Result;
+ Payload = string.Empty;
+ return ResultContent;
+ }
+ }
+ }
+
+ public static string GetProcessorID()
+ {
+ ManagementClass mgt = new ManagementClass("Win32_Processor");
+ ManagementObjectCollection procs = mgt.GetInstances();
+ foreach (ManagementObject item in procs)
+ return item.Properties["Name"].Value.ToString();
+ /*var mbs = new ManagementObjectSearcher("Select ProcessorId From Win32_processor");
+ ManagementObjectCollection mbsList = mbs.Get();
+ string id = "";
+ foreach (ManagementObject mo in mbsList)
+ {
+ id = mo["ProcessorId"].ToString();
+ break;
+ }
+ return id;*/
+ return "Unknown";
+ }
+
+ public class Saving
+ {
+ string KeySeparator = "<,>";
+ string ValueSeparator = "<|>";
+ string KeyValueSeparator = "<:>";
+ Dictionary Data = new Dictionary();
+ public string SaveFolderPath;
+ public string SaveFilePath;
+
+ public Saving(bool Custom = false, string FileName = "Save2.bin", string FolderPath = "EXECUTINGASSEMBLYFOLDERPATHUTILSSAVING")
+ {
+ if (Custom)
+ {
+ if (FolderPath != "EXECUTINGASSEMBLYFOLDERPATHUTILSSAVING")
+ SaveFolderPath = FolderPath;
+ else
+ SaveFolderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ SaveFilePath = Path.Combine(SaveFolderPath, FileName);
+ }
+ else
+ SaveFilePath = Path.Combine(SaveFolderPath, "Save.bin");
+ Load();
+ }
+
+ public bool Has(string Key, bool IsValue = false)
+ {
+ //Load();
+ if (IsValue)
+ return Data.ContainsValue(Key);
+ return Data.ContainsKey(Key);
+ }
+ public void Remove(string Key) =>
+ Data.Remove(Key);
+ public void Set(string Key, string Value, bool _Save = true)
+ {
+ Data[Key] = Value;
+ if (_Save)
+ Save();
+ }
+ public void Set(string Key, string Value_1, string Value_2, bool _Save = true)
+ {
+ string Value = string.Join(ValueSeparator, Value_1, Value_2);
+ Set(Key, Value, _Save);
+ }
+ public string Get(string Key)
+ {
+ //Load();
+ if (Has(Key))
+ return Data[Key];
+ return string.Empty;
+ }
+ public string[] Get(string Key, bool UseListParameter)
+ {
+ return Get(Key).Split(new[] { ValueSeparator }, StringSplitOptions.None);
+ }
+ public void Clear() =>
+ Data.Clear();
+
+ public void Save()
+ {
+ if (!Directory.Exists(SaveFolderPath))
+ Directory.CreateDirectory(SaveFolderPath);
+
+ if (!File.Exists(SaveFilePath))
+ File.Create(SaveFilePath).Close();
+ List Contents = new List();
+ foreach (KeyValuePair KVP in Data)
+ Contents.Add(KVP.Key + KeyValueSeparator + KVP.Value);
+ File.WriteAllText(SaveFilePath, string.Join(KeySeparator, Contents));
+ }
+ public void Load()
+ {
+ if (!Directory.Exists(SaveFolderPath))
+ Directory.CreateDirectory(SaveFolderPath);
+ if (!File.Exists(SaveFilePath))
+ File.Create(SaveFilePath).Close();
+
+ List Contents = File.ReadAllText(SaveFilePath).Split(new string[] { KeySeparator }, StringSplitOptions.None).ToList();
+ foreach (string Content in Contents)
+ {
+ if (string.IsNullOrWhiteSpace(Content))
+ continue;
+ string[] Values = Content.Split(new string[] { KeyValueSeparator }, 2, StringSplitOptions.None);
+ Data[Values[0]] = Values[1];
+ }
+ }
+ }
+
+ public class ChromiumBookmarkManager
+ {
+ public class Bookmarks
+ {
+ public string checksum { get; set; }
+ public Bookmark roots { get; set; }
+ }
+ public class Bookmark
+ {
+ public Metadata bookmark_bar { get; set; }
+ }
+ public class Metadata
+ {
+ public List children { get; set; }
+ public string date_added { get; set; }
+ public string id { get; set; }
+ public string name { get; set; }
+ public string type { get; set; }
+ public string url { get; set; }
+ }
+
+ public static Bookmarks Import(string _Path)
+ {
+ string FileContent = File.ReadAllText(_Path);
+ return (Bookmarks)Decode(FileContent);
+ }
+ public static string Encode(T Data)
+ {
+ return JsonConvert.SerializeObject(Data);
+ }
+ public static Object Decode(string JsonData)
+ {
+ return JsonConvert.DeserializeObject(JsonData);
+ }
+ }
+
+ /*public class AdManager
+ {
+ public string EasyList;
+ public AdManager()
+ {
+ EasyList = MainWindow.Instance.TinyDownloader.DownloadString()
+ }
+
+ public bool IsAd(string Url)
+ {
+
+ }
+ }*/
+ /*public static string[] Split(this string value, string[] seperator)
+ {
+ return value.Split(seperator, StringSplitOptions.None);
+ }*/
+ }
+}
diff --git a/SLBr/SLBr/app.manifest b/SLBr/SLBr/app.manifest
new file mode 100644
index 0000000..4fe2ad9
--- /dev/null
+++ b/SLBr/SLBr/app.manifest
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+