Update
Added a request handler. Changed the way you block sites. Disabled GPU acceleration and GPU vsync. Enabled webgl. Removed the rick roll blocking because I see it pointless.
This commit is contained in:
parent
7d6b3b5144
commit
f03e0e3bf5
4 changed files with 162 additions and 248 deletions
|
@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using XeroBrowser.Properties;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using System.Linq;
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
|
||||
namespace XeroBrowser
|
||||
|
@ -29,6 +30,7 @@ namespace XeroBrowser
|
|||
chromiumWebBrowser1.LifeSpanHandler = new LifeSpanHandler();
|
||||
chromiumWebBrowser1.MenuHandler = new MenuHandler();
|
||||
chromiumWebBrowser1.DisplayHandler = new DisplayHandler(this);
|
||||
chromiumWebBrowser1.RequestHandler = new RequestHandler();
|
||||
|
||||
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "index.html");
|
||||
_fileUri = new Uri(filePath);
|
||||
|
@ -152,53 +154,6 @@ namespace XeroBrowser
|
|||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
string[] blockedUrls = { "https://www.youtube.com/watch?v=dQw4w9WgXcQ", "https://www.youtube.com/watch?v=xm3YgoEiEDc", "https://www.youtube.com/watch?v=xvFZjo5PgG0", "https://www.youtube.com/watch?v=O91DT1pR1ew", "https://www.youtube.com/watch?v=o-YBDTqX_ZU", "https://www.youtube.com/watch?v=H8ZH_mkfPUY", "https://www.youtube.com/watch?v=o-YBDTqX_ZU", "https://www.youtube.com/watch?v=xvFZjo5PgG0" };
|
||||
string[] blockedDrms = { "https://www.netflix.com/", "http://www.netflix.com/", "https://netflix.com/", "http://netflix.com/", "https://www.disneyplus.com/", "http://www.disneyplus.com/", "https://disneyplus.com/", "http://disneyplus.com/", "https://www.twitch.tv/", "http://www.twitch.tv/", "https://twitch.tv/", "http://twitch.tv/", "https://www.tiktok.com/", "http://www.tiktok.com/", "https://tiktok.com/", "http://tiktok.com/" };
|
||||
string[] incompatibleExtSites = { "https://www.chrome.google.com", "https://chrome.google.com", "https://www.addons.mozilla.org", "https://addons.mozilla.org" };
|
||||
|
||||
string currentAddress = chromiumWebBrowser1.Address;
|
||||
|
||||
if (!_isBlocked)
|
||||
{
|
||||
foreach (string blockedDrm in blockedDrms)
|
||||
{
|
||||
if (currentAddress.StartsWith(blockedDrm))
|
||||
{
|
||||
chromiumWebBrowser1.Stop(); // cancel the navigation
|
||||
_isBlocked = true;
|
||||
chromiumWebBrowser1.LoadHtml("<html> <head> </head> <style> body{ background-color: rgb(214, 214, 214); } .center{ text-align: center; } .text{ margin-top: 20%; font-family: Arial; } div{ background-color: #f5f5f5; border-radius: 15px; width: 500px; margin-left: 35%; padding: 10px; } </style> <body class=\"center\"> <div class=\"text\"> <h1>Error!</h1> <h3 id=\"domain\"></h3> </div> </body> <script> document.getElementById(\"domain\").innerHTML = window.location.hostname + (' requires a DRM (Digital Rights Management) which Xero Browser does not support!'); </script></html>", blockedDrm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string blockedUrl in blockedUrls)
|
||||
{
|
||||
if (currentAddress.StartsWith(blockedUrl))
|
||||
{
|
||||
chromiumWebBrowser1.Stop(); // cancel the navigation
|
||||
_isBlocked = true;
|
||||
chromiumWebBrowser1.LoadHtml("<html> <head> </head> <style> body{ background-color: rgb(214, 214, 214); } .center{ text-align: center; } .text{ margin-top: 20%; font-family: Arial; } div{ background-color: #f5f5f5; border-radius: 15px; width: 500px; margin-left: 35%; padding: 10px; } </style> <body class=\"center\"> <div class=\"text\"> <h1>Rickroll Blocked!</h1> <h3>Being rickrolled is disabled.</h3> </div> </body></html>", blockedUrl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string incompatibleExtSite in incompatibleExtSites)
|
||||
{
|
||||
if (currentAddress.StartsWith(incompatibleExtSite))
|
||||
{
|
||||
chromiumWebBrowser1.Stop(); // cancel the navigation
|
||||
_isBlocked = true;
|
||||
chromiumWebBrowser1.LoadHtml("<html> <head> </head> <style> body{ background-color: rgb(214, 214, 214); } .center{ text-align: center; } .text{ margin-top: 20%; font-family: Arial; } div{ background-color: #f5f5f5; border-radius: 15px; width: 500px; margin-left: 35%; padding: 10px; } </style> <body class=\"center\"> <div class=\"text\"> <h1>Error!</h1> <h3>Xero Browser has no extension support (Yet).</h3> </div> </body></html>", incompatibleExtSite);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (System.Net.WebException) { }
|
||||
catch (ArgumentException) { }
|
||||
}
|
||||
|
||||
private void chromiumWebBrowser1_TitleChanged(object sender, TitleChangedEventArgs e)
|
||||
|
|
Reference in a new issue