Restructured the rest of the features to their own environment
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
29
Moonlight/Features/Advertisement/Services/AdBlockService.cs
Normal file
29
Moonlight/Features/Advertisement/Services/AdBlockService.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user