Files
Moonlight/Moonlight/App/Services/Interop/AdBlockService.cs
Marcel Baumgartner 0e1ddfbccb Implemented basic adblocker prevention
Tested with uBlockOrigin
2024-01-05 11:43:37 +01:00

29 lines
666 B
C#

using Microsoft.JSInterop;
using Moonlight.App.Helpers;
namespace Moonlight.App.Services.Interop;
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;
}
}
}