Skip to content

Commit

Permalink
Added auto-updating patch groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceiridge committed Apr 29, 2020
1 parent f9feb1c commit f0e571e
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CommandLineOptions.cs" />
<Compile Include="CustomCheckBox.cs" />
<Compile Include="InstallationFinder\Defaults\CustomPath.cs" />
<Compile Include="Patches\BytePatch.cs" />
<Compile Include="DllPatcher.cs" />
Expand Down
30 changes: 30 additions & 0 deletions ChromeDevExtWarningPatcher/CustomCheckBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Windows.Controls;
using System.Windows.Media;

namespace ChromeDevExtWarningPatcher {
class CustomCheckBox : CheckBox {
public int Group;

public CustomCheckBox(string text, string tooltip, int group) : base() {
Content = text;
Foreground = BorderBrush = new SolidColorBrush(Color.FromRgb(202, 62, 71));
Group = group;

if (tooltip != null)
ToolTip = tooltip;
}

public CustomCheckBox(GuiPatchGroupData patchGroupData) : this(patchGroupData.Name, patchGroupData.Tooltip, patchGroupData.Group) {
IsChecked = patchGroupData.Default;
}

public CustomCheckBox(string text) : this(text, null, -1) {}
}

struct GuiPatchGroupData {
public string Name, Tooltip;
public int Group;
public bool Default;
}
}
7 changes: 1 addition & 6 deletions ChromeDevExtWarningPatcher/PatcherGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@
</LinearGradientBrush>
</GroupBox.Foreground>
<Grid Margin="2,7,2,0">
<ListBox Height="325" Margin="10,0" Background="{x:Null}" Foreground="#FFCA3E47" FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Top" FontWeight="Normal" Width="184">
<CheckBox x:Name="RemoveExtWarning" Content="Remove extension warning" BorderBrush="#FFCA3E47" Background="White" Foreground="#FFCA3E47" IsChecked="True" ToolTip="This patch removes the warning of developer mode extensions when starting a Chromium browser"/>
<CheckBox x:Name="RemoveDebugWarning" Content="Remove debugging warning" BorderBrush="#FFCA3E47" Background="White" Foreground="#FFCA3E47" IsChecked="True" ToolTip="This patch gets rid of the debugging warning when using chrome.debugger in extensions"/>
<CheckBox x:Name="RemoveElision" Content="Disable Elision" BorderBrush="#FFCA3E47" Background="White" Foreground="#FFCA3E47" IsChecked="True" ToolTip="This patch forces Chromium to show WWW and HTTPS again in the url bar!"/>
<CheckBox x:Name="RemoveCrash" Content="Remove crash warning" BorderBrush="#FFCA3E47" Background="White" Foreground="#FFCA3E47" ToolTip="This patch removes the warning after a Chromium crash (does not work for some browsers like Brave)"/>
</ListBox>
<ListBox x:Name="PatchGroupList" Height="325" Margin="10,0" Background="{x:Null}" Foreground="#FFCA3E47" FontSize="12" HorizontalAlignment="Center" VerticalAlignment="Top" FontWeight="Normal" Width="184"/>
<Button x:Name="PatchBtn" Content="Patch" HorizontalAlignment="Center" Height="27" Margin="9,0,10,5" VerticalAlignment="Bottom" Width="185" Background="#FF525252" BorderBrush="White" FontWeight="Normal" FontSize="14" Click="PatchBtn_Click">
<Button.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
Expand Down
20 changes: 9 additions & 11 deletions ChromeDevExtWarningPatcher/PatcherGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ private void SelectFolderBtn_Click(object sender, RoutedEventArgs e) {

private void PatchBtn_Click(object sender, RoutedEventArgs e) {
Program.bytePatchManager.DisabledGroups.Clear();
if (RemoveExtWarning.IsChecked == false)
Program.bytePatchManager.DisabledGroups.Add(0);
if (RemoveDebugWarning.IsChecked == false)
Program.bytePatchManager.DisabledGroups.Add(1);
if (RemoveElision.IsChecked == false)
Program.bytePatchManager.DisabledGroups.Add(2);
if (RemoveCrash.IsChecked == false)
Program.bytePatchManager.DisabledGroups.Add(3);
foreach(CustomCheckBox patchBox in PatchGroupList.Items) {
if (patchBox.IsChecked == false)
Program.bytePatchManager.DisabledGroups.Add(patchBox.Group);
}

foreach (CheckBox installationBox in InstallationList.Items) {
if (installationBox.IsChecked == true) {
Expand Down Expand Up @@ -66,6 +62,10 @@ protected override void OnInitialized(EventArgs e) {
foreach(string path in new InstallationFinder.InstallationManager().FindAllChromiumInstallations()) {
AddChromiumInstallation(path);
}

foreach(GuiPatchGroupData patchGroup in Program.bytePatchManager.PatchGroups) {
PatchGroupList.Items.Add(new CustomCheckBox(patchGroup));
}
}

public void Log(string str) {
Expand All @@ -79,10 +79,8 @@ public void Log(string str) {
}

private void AddChromiumInstallation(string chromeDll) {
CheckBox installationBox = new CheckBox();
installationBox.Content = chromeDll;
CustomCheckBox installationBox = new CustomCheckBox(chromeDll);
installationBox.IsChecked = true;
installationBox.Foreground = installationBox.BorderBrush = new SolidColorBrush(Color.FromRgb(202, 62, 71));

InstallationList.Items.Add(installationBox);
Log("Added Chromium installation at " + chromeDll);
Expand Down
15 changes: 14 additions & 1 deletion ChromeDevExtWarningPatcher/Patches/BytePatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ class BytePatchManager {
private Dictionary<string, BytePatchPattern> BytePatterns = new Dictionary<string, BytePatchPattern>();

public List<int> DisabledGroups = new List<int>();
public List<GuiPatchGroupData> PatchGroups = new List<GuiPatchGroupData>();

public delegate MessageBoxResult WriteLineOrMessageBox(string str, string title);
public BytePatchManager(WriteLineOrMessageBox log) {
BytePatches.Clear();
BytePatterns.Clear();

XDocument xmlDoc = null;
string xmlFile = Path.GetTempPath() + "chrome_patcher_patterns.xml";
string xmlFile = Program.DEBUG ? @"..\..\..\patterns.xml" : (Path.GetTempPath() + "chrome_patcher_patterns.xml");

try {
if (Program.DEBUG)
throw new Exception("Forcing to use local patterns.xml");

using (WebClient web = new WebClient()) {
string xmlStr;
xmlDoc = XDocument.Parse(xmlStr = web.DownloadString("https://raw.githubusercontent.com/Ceiridge/Chrome-Developer-Mode-Extension-Warning-Patcher/master/patterns.xml")); // Hardcoded defaults xml file; This makes quick fixes possible
Expand Down Expand Up @@ -102,6 +106,15 @@ public BytePatchManager(WriteLineOrMessageBox log) {
}
BytePatches.Add(new BytePatch(pattern, origX64, patchX64, offsetX64, aoffsetX64, origX86, patchX86, offsetX86, aoffsetX86, group));
}

foreach(XElement patchGroup in xmlDoc.Root.Element("GroupedPatches").Elements("GroupedPatch")) {
PatchGroups.Add(new GuiPatchGroupData {
Group = int.Parse(patchGroup.Attribute("group").Value),
Default = bool.Parse(patchGroup.Attribute("default").Value),
Name = patchGroup.Element("Name").Value,
Tooltip = patchGroup.Element("Tooltip").Value
});
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions ChromeDevExtWarningPatcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Program
private static Window guiWindow;
public static BytePatchManager bytePatchManager;

public const bool DEBUG = false;

[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
private static extern bool FreeConsole();

Expand Down
4 changes: 2 additions & 2 deletions ChromeDevExtWarningPatcher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
[assembly: Guid("0254db23-b64d-4d54-8ff8-f4d570e95ad4")]


[assembly: AssemblyVersion("3.5.0.0")]
[assembly: AssemblyFileVersion("3.5.0.0")]
[assembly: AssemblyVersion("3.6.0.0")]
[assembly: AssemblyFileVersion("3.6.0.0")]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Disable Chromium's and Chrome's Developer Mode Extension Warning Popup & Elision WWW/HTTPS Hiding & Debugging Extension Popup
**Download** it in the [release section](https://github.com/Ceiridge/Chrome-Developer-Mode-Extension-Warning-Patcher/releases).
**Download** it in the [release section](https://github.com/Ceiridge/Chrome-Developer-Mode-Extension-Warning-Patcher/releases). The patterns and patches auto-update with the `patterns.xml`.

## Supported browsers
See below for the custom paths (commandline option).
Expand Down
25 changes: 24 additions & 1 deletion patterns.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Create a new issue if a pattern stops working with any browser.
-->

<Defaults version="3.5">
<Defaults version="3.6">
<Patterns>
<Pattern name="Remove Extension Warning">
<!-- ShouldIncludeExtension; "ProxyOverriddenBubble.UserSelection" 2nd function in the vtable -->
Expand Down Expand Up @@ -95,4 +95,27 @@
<PatchData type="x86" offset="0x00" orig="0x55" patch="0xC3"></PatchData>
</Patch>
</Patches>


<GroupedPatches> <!-- This list represents the checkboxes in the gui. Commandline arguments aren't affected by this -->
<GroupedPatch group="0" default="true">
<Name>Remove extension warning</Name>
<Tooltip>This patch removes the warning of developer mode extensions when starting a Chromium browser</Tooltip>
</GroupedPatch>

<GroupedPatch group="1" default="true">
<Name>Remove debugging warning</Name>
<Tooltip>This patch gets rid of the debugging warning when using chrome.debugger in extensions</Tooltip>
</GroupedPatch>

<GroupedPatch group="2" default="true">
<Name>Disable Elision</Name>
<Tooltip>This patch forces Chromium to show WWW and HTTPS again in the url bar!</Tooltip>
</GroupedPatch>

<GroupedPatch group="3" default="false">
<Name>Remove crash warning</Name>
<Tooltip>This patch removes the warning after a Chromium crash (doesn't work for some browsers like Brave)</Tooltip>
</GroupedPatch>
</GroupedPatches>
</Defaults>

0 comments on commit f0e571e

Please sign in to comment.