Skip to content

Commit d6ed54f

Browse files
committed
Function to block the notifications API
1 parent 81036fe commit d6ed54f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

modCommand.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public static void Handle(string inputCommand, string inputSource, string reques
3131
else if (inputData[1] == "system" && inputData[2] == "details") { outputResponse = modSystem.GetSystemDetails(); } break;
3232
case "disable" when inputData.Length == 2:
3333
if (inputData[1] == "autoupdate") { outputResponse = modUpdate.DisableAutoupdate(); }
34-
if (inputData[1] == "rundialog") { outputResponse = modSystem.ConfigureRunDialog(inputData[0]); } break;
34+
if (inputData[1] == "rundialog") { outputResponse = modSystem.ConfigureRunDialog(inputData[0]); }
35+
if (inputData[1] == "webnotifications") { outputResponse = modSystem.DisableWebNotifications(); } break;
3536
case "enable" when inputData.Length == 2:
3637
if (inputData[1] == "autoupdate") { outputResponse = modUpdate.EnableAutoupdate(); }
3738
if (inputData[1] == "rundialog") { outputResponse = modSystem.ConfigureRunDialog(inputData[0]); } break;

modSystem.cs

+17
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,22 @@ public static string ConfigureRunDialog(string action)
277277
modSync.SendSingleConfig("Security_RunDialog", action + "d");
278278
return "Run dialog " + action + "d";
279279
}
280+
281+
/// <summary>
282+
/// Disables the browser Notifications API on Chrome, Edge, and Firefox
283+
/// </summary>
284+
/// <returns>(string) Response</returns>
285+
public static string DisableWebNotifications()
286+
{
287+
RegistryKey chromePolicies = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Google\Chrome", true);
288+
chromePolicies.SetValue("DefaultNotificationsSetting", 2, RegistryValueKind.DWord);
289+
RegistryKey edgePolicies = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Microsoft\Edge", true);
290+
edgePolicies.SetValue("DefaultNotificationsSetting", 2, RegistryValueKind.DWord);
291+
RegistryKey firefoxPolicies = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Mozilla\Firefox\Permissions\Notifications", true);
292+
firefoxPolicies.SetValue("BlockNewRequests", 1, RegistryValueKind.DWord);
293+
294+
modSync.SendSingleConfig("Security_WebNotifications", "disabled");
295+
return "Browser notifications disabled";
296+
}
280297
}
281298
}

0 commit comments

Comments
 (0)