Restructured the rest of the features to their own environment

This commit is contained in:
Marcel Baumgartner
2024-01-26 13:53:34 +01:00
parent 63b2b40227
commit 12bc66a95b
91 changed files with 181 additions and 147 deletions

View File

@@ -0,0 +1,11 @@
using System.ComponentModel;
using Newtonsoft.Json;
namespace Moonlight.Features.Advertisement.Configuration;
public class AdvertisementData
{
[JsonProperty("PreventAdBlockers")]
[Description("This prevents users from using ad blockers while using moonlight. (Note: The detection might not always work)")]
public bool PreventAdBlockers { get; set; }
}

View File

@@ -0,0 +1,29 @@
using Microsoft.JSInterop;
using Moonlight.Core.Helpers;
namespace Moonlight.Features.Advertisement.Services;
public class AdBlockService
{
private readonly IJSRuntime JsRuntime;
public AdBlockService(IJSRuntime jsRuntime)
{
JsRuntime = jsRuntime;
}
public async Task<bool> Detect()
{
try
{
return await JsRuntime.InvokeAsync<bool>("moonlight.utils.vendo"); // lat. vendo = advertisement xd
}
catch (Exception e)
{
Logger.Warn("An unexpected error occured while trying to detect possible ad blockers");
Logger.Warn(e);
return false;
}
}
}

View File

@@ -0,0 +1,16 @@
<div class="w-100">
<div class="card-body">
<div class="text-start mb-8">
<h1 class="text-dark mb-3 fs-3x">
AdBlocker detected
</h1>
<div class="text-gray-400 fw-semibold fs-6">
We have detected that you are using an adblocker. Disable your adblocker or add this site as an exception and reload the page to proceed
</div>
</div>
<div class="d-flex flex-stack">
<a href="javascript:location.reload()" class="btn btn-primary me-2 flex-shrink-0">I have disabled my adblocker</a>
</div>
</div>
</div>