Skip to content

Commit eb19a23

Browse files
committed
Function to block browser extensions
1 parent d6ed54f commit eb19a23

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.12")]
36-
[assembly: AssemblyFileVersion("1.0.0.12")]
35+
[assembly: AssemblyVersion("1.0.0.13")]
36+
[assembly: AssemblyFileVersion("1.0.0.13")]

XRFAgent.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<UpdatePeriodically>false</UpdatePeriodically>
2626
<UpdateRequired>false</UpdateRequired>
2727
<MapFileExtensions>true</MapFileExtensions>
28-
<ApplicationRevision>12</ApplicationRevision>
28+
<ApplicationRevision>13</ApplicationRevision>
2929
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
3030
<UseApplicationTrust>false</UseApplicationTrust>
3131
<BootstrapperEnabled>true</BootstrapperEnabled>
@@ -119,7 +119,7 @@
119119
<Version>6.1.0</Version>
120120
</PackageReference>
121121
<PackageReference Include="System.Text.Json">
122-
<Version>9.0.0</Version>
122+
<Version>9.0.2</Version>
123123
</PackageReference>
124124
</ItemGroup>
125125
<ItemGroup>

modCommand.cs

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

modSystem.cs

+20
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,26 @@ public static string ConfigureRunDialog(string action)
278278
return "Run dialog " + action + "d";
279279
}
280280

281+
/// <summary>
282+
/// Disables installing or using any browser extensions on Chrome, Edge, and Firefox
283+
/// but permits uBlock Origin, Privacy Badger, and Facebook Container on Firefox
284+
/// </summary>
285+
/// <returns></returns>
286+
287+
public static string DisableWebExtensions()
288+
{
289+
RegistryKey chromeExtensions = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlocklist", true);
290+
chromeExtensions.SetValue("1", "*", RegistryValueKind.String);
291+
RegistryKey edgeExtensions = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallBlocklist", true);
292+
edgeExtensions.SetValue("1", "*", RegistryValueKind.String);
293+
RegistryKey firefoxExtensions = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Policies\Mozilla\Firefox", true);
294+
string[] firefoxExtensionPolicy = {"{", " \"*\":{", " \"blocked_install_message\": \"Unapproved extensions are not permitted.\",", " \"install_sources\": [\"about:addons\",\"https://addons.mozilla.org/\"],", " \"installation_mode\": \"blocked\",", " \"allowed_types\": [\"extension\"]", " },", " \"[email protected]\":{", " \"installation_mode\": \"allowed\"", " },", " \"jid1-MnnxcxisBPnSXQ@jetpack\":{", " \"installation_mode\": \"allowed\"", " },", " \"@contain-facebook\":{", " \"installation_mode\": \"allowed\"", " }", "}" };
295+
firefoxExtensions.SetValue("ExtensionSettings2", firefoxExtensionPolicy, RegistryValueKind.MultiString);
296+
297+
modSync.SendSingleConfig("Security_WebExtensions", "disabled");
298+
return "Browser extensions disabled";
299+
}
300+
281301
/// <summary>
282302
/// Disables the browser Notifications API on Chrome, Edge, and Firefox
283303
/// </summary>

0 commit comments

Comments
 (0)