Skip to content

Commit

Permalink
Function to block the notifications API
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Jan 5, 2025
1 parent 81036fe commit d6ed54f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static void Handle(string inputCommand, string inputSource, string reques
else if (inputData[1] == "system" && inputData[2] == "details") { outputResponse = modSystem.GetSystemDetails(); } break;
case "disable" when inputData.Length == 2:
if (inputData[1] == "autoupdate") { outputResponse = modUpdate.DisableAutoupdate(); }
if (inputData[1] == "rundialog") { outputResponse = modSystem.ConfigureRunDialog(inputData[0]); } break;
if (inputData[1] == "rundialog") { outputResponse = modSystem.ConfigureRunDialog(inputData[0]); }
if (inputData[1] == "webnotifications") { outputResponse = modSystem.DisableWebNotifications(); } break;
case "enable" when inputData.Length == 2:
if (inputData[1] == "autoupdate") { outputResponse = modUpdate.EnableAutoupdate(); }
if (inputData[1] == "rundialog") { outputResponse = modSystem.ConfigureRunDialog(inputData[0]); } break;
Expand Down
17 changes: 17 additions & 0 deletions modSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,22 @@ public static string ConfigureRunDialog(string action)
modSync.SendSingleConfig("Security_RunDialog", action + "d");
return "Run dialog " + action + "d";
}

/// <summary>
/// Disables the browser Notifications API on Chrome, Edge, and Firefox
/// </summary>
/// <returns>(string) Response</returns>
public static string DisableWebNotifications()
{
RegistryKey chromePolicies = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Google\Chrome", true);
chromePolicies.SetValue("DefaultNotificationsSetting", 2, RegistryValueKind.DWord);
RegistryKey edgePolicies = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Microsoft\Edge", true);
edgePolicies.SetValue("DefaultNotificationsSetting", 2, RegistryValueKind.DWord);
RegistryKey firefoxPolicies = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Mozilla\Firefox\Permissions\Notifications", true);
firefoxPolicies.SetValue("BlockNewRequests", 1, RegistryValueKind.DWord);

modSync.SendSingleConfig("Security_WebNotifications", "disabled");
return "Browser notifications disabled";
}
}
}

0 comments on commit d6ed54f

Please sign in to comment.