From b1d8c5b81a5f469b772e6f5467ba45b55e66124b Mon Sep 17 00:00:00 2001
From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com>
Date: Thu, 22 Jun 2023 20:57:07 -0500
Subject: [PATCH] [FuckCohtmlResourceHandler] fucking annoying
stop
---
.../FuckCohtmlResourceHandler.csproj | 2 +
FuckCohtmlResourceHandler/HarmonyPatches.cs | 53 +++++++++++++++++++
FuckCohtmlResourceHandler/Main.cs | 46 ++++++++++++++++
.../Properties/AssemblyInfo.cs | 30 +++++++++++
FuckCohtmlResourceHandler/README.md | 16 ++++++
FuckCohtmlResourceHandler/format.json | 23 ++++++++
6 files changed, 170 insertions(+)
create mode 100644 FuckCohtmlResourceHandler/FuckCohtmlResourceHandler.csproj
create mode 100644 FuckCohtmlResourceHandler/HarmonyPatches.cs
create mode 100644 FuckCohtmlResourceHandler/Main.cs
create mode 100644 FuckCohtmlResourceHandler/Properties/AssemblyInfo.cs
create mode 100644 FuckCohtmlResourceHandler/README.md
create mode 100644 FuckCohtmlResourceHandler/format.json
diff --git a/FuckCohtmlResourceHandler/FuckCohtmlResourceHandler.csproj b/FuckCohtmlResourceHandler/FuckCohtmlResourceHandler.csproj
new file mode 100644
index 0000000..66a50a8
--- /dev/null
+++ b/FuckCohtmlResourceHandler/FuckCohtmlResourceHandler.csproj
@@ -0,0 +1,2 @@
+
+
diff --git a/FuckCohtmlResourceHandler/HarmonyPatches.cs b/FuckCohtmlResourceHandler/HarmonyPatches.cs
new file mode 100644
index 0000000..af23914
--- /dev/null
+++ b/FuckCohtmlResourceHandler/HarmonyPatches.cs
@@ -0,0 +1,53 @@
+using cohtml;
+using cohtml.Net;
+using HarmonyLib;
+
+namespace NAK.FuckCohtmlResourceHandler.HarmonyPatches;
+
+class DefaultResourceHandlerPatches
+{
+ private const string BadgesUrl = "https://files.abidata.io/static_web/Badges/";
+ private const string UserImagesUrl = "https://files.abidata.io/user_images/";
+ private const string WorldImagesUrl = "https://files.abidata.io/user_content/";
+ private const string AllUrl = "https://files.abidata.io/";
+
+ private static Dictionary blockedUrls = new Dictionary();
+
+ public static void Initialize()
+ {
+ UpdateBlockedUrls();
+
+ FuckCohtmlResourceHandler.EntryBlockBadgesUrl.OnValueChanged += (_, __) => UpdateBlockedUrls();
+ FuckCohtmlResourceHandler.EntryBlockUserImagesUrl.OnValueChanged += (_, __) => UpdateBlockedUrls();
+ FuckCohtmlResourceHandler.EntryBlockWorldImagesUrl.OnValueChanged += (_, __) => UpdateBlockedUrls();
+ FuckCohtmlResourceHandler.EntryBlockAllUrl.OnValueChanged += (_, __) => UpdateBlockedUrls();
+ }
+
+ private static void UpdateBlockedUrls()
+ {
+ blockedUrls[BadgesUrl] = FuckCohtmlResourceHandler.EntryBlockBadgesUrl.Value;
+ blockedUrls[UserImagesUrl] = FuckCohtmlResourceHandler.EntryBlockUserImagesUrl.Value;
+ blockedUrls[WorldImagesUrl] = FuckCohtmlResourceHandler.EntryBlockWorldImagesUrl.Value;
+ blockedUrls[AllUrl] = FuckCohtmlResourceHandler.EntryBlockAllUrl.Value;
+ FuckCohtmlResourceHandler.Logger.Msg("Updated Blocked Urls!");
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch(typeof(DefaultResourceHandler), nameof(DefaultResourceHandler.OnResourceRequest))]
+ static bool Prefix_DefaultResourceHandler_OnResourceRequest(ref IAsyncResourceRequest request, ref IAsyncResourceResponse response)
+ {
+ if (FuckCohtmlResourceHandler.EntryEnabled.Value)
+ {
+ foreach (var url in blockedUrls)
+ {
+ if (!string.IsNullOrEmpty(url.Key) && request.GetURL().Contains(url.Key) && url.Value)
+ {
+ response.Finish(IAsyncResourceResponse.Status.Failure);
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/FuckCohtmlResourceHandler/Main.cs b/FuckCohtmlResourceHandler/Main.cs
new file mode 100644
index 0000000..6445a50
--- /dev/null
+++ b/FuckCohtmlResourceHandler/Main.cs
@@ -0,0 +1,46 @@
+using MelonLoader;
+
+namespace NAK.FuckCohtmlResourceHandler;
+
+public class FuckCohtmlResourceHandler : MelonMod
+{
+ internal static MelonLogger.Instance Logger;
+
+ public static readonly MelonPreferences_Category Category =
+ MelonPreferences.CreateCategory(nameof(FuckCohtmlResourceHandler));
+
+ public static readonly MelonPreferences_Entry EntryEnabled =
+ Category.CreateEntry("Enabled", true, description: "Toggle FuckCohtmlResourceHandler entirely.");
+
+ public static readonly MelonPreferences_Entry EntryBlockBadgesUrl =
+ Category.CreateEntry("BlockBadgesUrl", true, description: "Toggle whether to block Badges URL.");
+
+ public static readonly MelonPreferences_Entry EntryBlockUserImagesUrl =
+ Category.CreateEntry("BlockUserImagesUrl", false, description: "Toggle whether to block User Images URL.");
+
+ public static readonly MelonPreferences_Entry EntryBlockWorldImagesUrl =
+ Category.CreateEntry("BlockWorldImagesUrl", false, description: "Toggle whether to block World Images URL.");
+
+ public static readonly MelonPreferences_Entry EntryBlockAllUrl =
+ Category.CreateEntry("BlockAllUrl", false, description: "Toggle whether to block All content URL.");
+
+ public override void OnInitializeMelon()
+ {
+ Logger = LoggerInstance;
+ HarmonyPatches.DefaultResourceHandlerPatches.Initialize();
+ ApplyPatches(typeof(HarmonyPatches.DefaultResourceHandlerPatches));
+ }
+
+ void ApplyPatches(Type type)
+ {
+ try
+ {
+ HarmonyInstance.PatchAll(type);
+ }
+ catch (Exception e)
+ {
+ LoggerInstance.Msg($"Failed while patching {type.Name}!");
+ LoggerInstance.Error(e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/FuckCohtmlResourceHandler/Properties/AssemblyInfo.cs b/FuckCohtmlResourceHandler/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d75dfda
--- /dev/null
+++ b/FuckCohtmlResourceHandler/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using MelonLoader;
+using NAK.FuckCohtmlResourceHandler.Properties;
+using System.Reflection;
+
+[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
+[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
+[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
+[assembly: AssemblyTitle(nameof(NAK.FuckCohtmlResourceHandler))]
+[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
+[assembly: AssemblyProduct(nameof(NAK.FuckCohtmlResourceHandler))]
+
+[assembly: MelonInfo(
+ typeof(NAK.FuckCohtmlResourceHandler.FuckCohtmlResourceHandler),
+ nameof(NAK.FuckCohtmlResourceHandler),
+ AssemblyInfoParams.Version,
+ AssemblyInfoParams.Author,
+ downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/FuckCohtmlResourceHandler"
+)]
+
+[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
+[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
+[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
+[assembly: HarmonyDontPatchAll]
+
+namespace NAK.FuckCohtmlResourceHandler.Properties;
+internal static class AssemblyInfoParams
+{
+ public const string Version = "1.0.0";
+ public const string Author = "NotAKidoS";
+}
\ No newline at end of file
diff --git a/FuckCohtmlResourceHandler/README.md b/FuckCohtmlResourceHandler/README.md
new file mode 100644
index 0000000..850b2aa
--- /dev/null
+++ b/FuckCohtmlResourceHandler/README.md
@@ -0,0 +1,16 @@
+# FuckCohtmlResourceHandler
+
+Dirty AF fix for a super fucking annoying Cohtml bug.
+
+Thank you bono for the patch.
+
+---
+
+Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI.
+https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
+
+> This mod is an independent creation and is not affiliated with, supported by or approved by Alpha Blend Interactive.
+
+> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use.
+
+> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.
diff --git a/FuckCohtmlResourceHandler/format.json b/FuckCohtmlResourceHandler/format.json
new file mode 100644
index 0000000..12a33a2
--- /dev/null
+++ b/FuckCohtmlResourceHandler/format.json
@@ -0,0 +1,23 @@
+{
+ "_id": -1,
+ "name": "FuckCohtmlResourceHandler",
+ "modversion": "1.0.0",
+ "gameversion": "2022r170p1",
+ "loaderversion": "0.6.1",
+ "modtype": "Mod",
+ "author": "NotAKidoS",
+ "description": "Allows your controllers to track while the SteamVR overlay is open. This also fixes Quest/Touch controllers feeling slow during fast movements.",
+ "searchtags": [
+ "vr",
+ "quest",
+ "controller",
+ "tracking"
+ ],
+ "requirements": [
+ "None"
+ ],
+ "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/FuckCohtmlResourceHandler.dll",
+ "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/FuckCohtmlResourceHandler/",
+ "changelog": "Initial Release",
+ "embedcolor": "3498db"
+}
\ No newline at end of file