mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 21:02:08 +08:00
1.0.1 (beta) 更新
This commit is contained in:
parent
971e7adab7
commit
dff4ce4a70
3
App.xaml
3
App.xaml
@ -1,8 +1,7 @@
|
||||
<Application x:Class="Sheas_Cealer.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Windows/MainWindow.xaml">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
@ -4,5 +4,9 @@ namespace Sheas_Cealer
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
new MainWindow(e.Args).Show();
|
||||
}
|
||||
}
|
||||
}
|
BIN
Cealing-Clash.exe
Normal file
BIN
Cealing-Clash.exe
Normal file
Binary file not shown.
@ -1,11 +1,12 @@
|
||||
[
|
||||
[["*pixiv.net"],"fanbox.cc","172.64.151.90"],
|
||||
[["*pximg.net"],"pxi","210.140.92.149"],
|
||||
[["*pinterest.com"],"pin","2.18.233.9"],
|
||||
[["*e-hentai.org"],"ehe","104.20.134.21"],
|
||||
[["*exhentai.org"],"exh","178.175.129.254"],
|
||||
[["*wikipedia.org","*wikimedia.org"],"wik","91.198.174.192"],
|
||||
[["*steamcommunity.com"],"ste","104.92.74.217"],
|
||||
[["*instagram.com"],"ins","157.240.236.174"],
|
||||
[["*pinterest.com"],"pin","2.18.233.9"],
|
||||
[["*amazon.co.jp"],"ama","52.222.208.138"],
|
||||
[["*pixiv.net"],"fanbox.cc","172.64.151.90"],
|
||||
[["*pximg.net"],"pxi","210.140.92.149"]
|
||||
[["*github.com"],"git","140.82.121.3"]
|
||||
]
|
23
Commons/Clash.cs
Normal file
23
Commons/Clash.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using SheasCore;
|
||||
|
||||
namespace Sheas_Cealer
|
||||
{
|
||||
internal class Clash : Proc
|
||||
{
|
||||
internal Clash() : base("Cealing-Clash.exe")
|
||||
{
|
||||
}
|
||||
|
||||
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
}
|
||||
public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
}
|
||||
public override void Process_Exited(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -6,9 +6,8 @@ namespace Sheas_Cealer
|
||||
{
|
||||
internal class Cmd : Proc
|
||||
{
|
||||
public Cmd() : base("Cmd.exe")
|
||||
internal Cmd() : base("Cmd.exe")
|
||||
{
|
||||
//Control.CheckForIllegalCrossThreadCalls = false;
|
||||
}
|
||||
|
||||
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
|
@ -8,10 +8,10 @@
|
||||
<PackageReleaseNotes>Just Ceal It</PackageReleaseNotes>
|
||||
<Authors>Space Time</Authors>
|
||||
<Company>Space Time</Company>
|
||||
<AssemblyVersion>1.0.0</AssemblyVersion>
|
||||
<Version>1.0.0</Version>
|
||||
<FileVersion>1.0.0</FileVersion>
|
||||
<InformationalVersion>1.0.0</InformationalVersion>
|
||||
<AssemblyVersion>1.0.1</AssemblyVersion>
|
||||
<Version>1.0.1</Version>
|
||||
<FileVersion>1.0.1</FileVersion>
|
||||
<InformationalVersion>1.0.1</InformationalVersion>
|
||||
<PackageTags>Tool;Sheas;Cealer;Sni</PackageTags>
|
||||
<ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon>
|
||||
<PackageIcon>Sheas Cealer Logo.png</PackageIcon>
|
||||
@ -48,6 +48,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove=".gitattributes" />
|
||||
<None Remove=".gitignore" />
|
||||
<None Remove="Cealing-Clash.exe" />
|
||||
<None Remove="Cealing-Host.json" />
|
||||
<None Remove="Clash.exe" />
|
||||
<None Remove="README.md" />
|
||||
<None Remove="Sheas-Cealer-Logo.ico" />
|
||||
</ItemGroup>
|
||||
|
@ -9,14 +9,13 @@ namespace Sheas_Cealer
|
||||
{
|
||||
public partial class AboutWindow : Window
|
||||
{
|
||||
public AboutWindow()
|
||||
internal AboutWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void AboutWin_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try { UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2]; }
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2];
|
||||
}
|
||||
|
||||
private void AboutButton_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -5,7 +5,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Style="{DynamicResource CommonWindow}"
|
||||
WindowStartupLocation="CenterScreen" SizeToContent="Height" ResizeMode="CanMinimize" Width="500" MinWidth="500" Loaded="MainWin_Loaded" KeyDown="MainWin_KeyDown">
|
||||
WindowStartupLocation="CenterScreen" SizeToContent="Height" ResizeMode="CanMinimize" Width="500" MinWidth="500" AllowDrop="True" Loaded="MainWin_Loaded" Closing="MainWin_Closing" KeyDown="MainWin_KeyDown" DragEnter="MainWin_DragEnter" Drop="MainWin_Drop">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
@ -17,7 +17,7 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="ShowBox" Text="(填入任意以 Chromium 为内核的浏览器的路径)" Foreground="#FFBFCDDB" Grid.Column="0" Margin="0,0,10,0" VerticalContentAlignment="Center" GotFocus="ShowBox_GotFocus" LostFocus="ShowBox_LostFocus" TextChanged="ShowBox_TextChanged" />
|
||||
<TextBox x:Name="ShowBox" Text="(填入任意以 Chromium 为内核的浏览器的路径)" Foreground="#FFBFCDDB" Grid.Column="0" Margin="0,0,10,0" VerticalContentAlignment="Center" GotFocus="ShowBox_GotFocus" LostFocus="ShowBox_LostFocus" TextChanged="ShowBox_TextChanged" PreviewDragOver="MainWin_DragEnter" />
|
||||
<Button x:Name="ViewButton" Grid.Column="2" Content="浏览" Click="ViewButton_Click" />
|
||||
</Grid>
|
||||
|
||||
@ -26,10 +26,12 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="EditButton" Content="编辑" Grid.Column="0" Margin="0,0,5,0" Click="EditButton_Click" />
|
||||
<Button x:Name="OpenButton" Content="启动" Grid.Column="1" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" />
|
||||
<Button x:Name="AboutButton" Content="关于" Grid.Column="2" Margin="5,0,0,0" Click="AboutButton_Click" />
|
||||
<Button x:Name="ClashButton" Content="代理" Grid.Column="1" Margin="5,0,5,0" Click="ClashButton_Click" />
|
||||
<Button x:Name="OpenButton" Content="启动" Grid.Column="2" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" />
|
||||
<Button x:Name="AboutButton" Content="关于" Grid.Column="3" Margin="5,0,0,0" Click="AboutButton_Click" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using IWshRuntimeLibrary;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@ -15,8 +16,9 @@ namespace Sheas_Cealer
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private static string? CEALING_ARGUMENT;
|
||||
private static readonly DispatcherTimer MONITOR_TIMER = new() { Interval = new TimeSpan(1000000) }; //0.1s
|
||||
|
||||
public MainWindow()
|
||||
internal MainWindow(string[] args)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -24,17 +26,23 @@ namespace Sheas_Cealer
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
MONITOR_TIMER.Tick += MONITOR_TIMER_Tick;
|
||||
MONITOR_TIMER.Start();
|
||||
|
||||
if (args.Length > 0)
|
||||
Dispatcher.Invoke(() => ShowBox.Text = args[0]);
|
||||
else if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.BrowserPath))
|
||||
Dispatcher.Invoke(() => ShowBox.Text = Properties.Settings.Default.BrowserPath);
|
||||
|
||||
string hostRules = string.Empty, hostResolverRules = string.Empty;
|
||||
FileStream hostStream = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
JArray hostJArray = JArray.Parse(new StreamReader(hostStream).ReadToEnd());
|
||||
|
||||
foreach (var hostJToken in hostJArray)
|
||||
{
|
||||
hostResolverRules += "MAP " + hostJToken[1]!.ToString() + " " + hostJToken[2]!.ToString() + ",";
|
||||
foreach (var hostName in hostJToken[0]!)
|
||||
hostRules += "MAP " + hostName.ToString() + " " + hostJToken[1] + ",";
|
||||
}
|
||||
|
||||
CEALING_ARGUMENT = @"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""" + hostRules[0..^1] + @""" --host-resolver-rules=""" + hostResolverRules[0..^1] + @""" --test-type --ignore-certificate-errors";
|
||||
});
|
||||
}
|
||||
@ -42,40 +50,29 @@ namespace Sheas_Cealer
|
||||
}
|
||||
private void MainWin_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ShowBox.Focus();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.BrowserPath))
|
||||
ShowBox.Text = Properties.Settings.Default.BrowserPath;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
ShowBox.Focus();
|
||||
}
|
||||
private void MainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void ShowBox_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
if (ShowBox.Foreground != Foreground)
|
||||
{
|
||||
if (ShowBox.Foreground != Foreground)
|
||||
{
|
||||
//PlaceHold状态
|
||||
ShowBox.Text = string.Empty;
|
||||
ShowBox.Foreground = Foreground;
|
||||
}
|
||||
//PlaceHold状态
|
||||
ShowBox.Text = string.Empty;
|
||||
ShowBox.Foreground = Foreground;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void ShowBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
if (string.IsNullOrEmpty(ShowBox.Text))
|
||||
{
|
||||
if (string.IsNullOrEmpty(ShowBox.Text))
|
||||
{
|
||||
ShowBox.Text = "(填入任意以 Chromium 为内核的浏览器的路径)";
|
||||
ShowBox.Foreground = new SolidColorBrush(Color.FromRgb(191, 205, 219));
|
||||
}
|
||||
ShowBox.Text = "(填入任意以 Chromium 为内核的浏览器的路径)";
|
||||
ShowBox.Foreground = new SolidColorBrush(Color.FromRgb(191, 205, 219));
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void ShowBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||
{
|
||||
@ -97,6 +94,29 @@ namespace Sheas_Cealer
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
|
||||
private void MainWin_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
e.Handled = true;
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
e.Effects = DragDropEffects.Link;
|
||||
else
|
||||
e.Effects = DragDropEffects.None;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void MainWin_Drop(object sender, DragEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
ShowBox.Text = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
|
||||
private void ViewButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
@ -121,6 +141,28 @@ namespace Sheas_Cealer
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void ClashButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegistryKey proxyKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true)!;
|
||||
if (ClashButton.Content.ToString() == "代理")
|
||||
{
|
||||
proxyKey.SetValue("ProxyEnable", 1);
|
||||
proxyKey.SetValue("ProxyServer", "127.0.0.1:7890");
|
||||
|
||||
new Clash().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyKey.SetValue("ProxyEnable", 0);
|
||||
|
||||
foreach (Process clashProcess in Process.GetProcessesByName("Cealing-Clash"))
|
||||
clashProcess.Kill();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
|
||||
}
|
||||
private void OpenButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
@ -133,14 +175,10 @@ namespace Sheas_Cealer
|
||||
uncealedBrowserShortcut.Description = "Created By Sheas Cealer";
|
||||
uncealedBrowserShortcut.Save();
|
||||
|
||||
string fileName = Path.GetFileNameWithoutExtension(ShowBox.Text);
|
||||
foreach (Process process in Process.GetProcesses())
|
||||
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ShowBox.Text)))
|
||||
{
|
||||
if (process.ProcessName == fileName)
|
||||
{
|
||||
process.Kill();
|
||||
process.WaitForExit();
|
||||
}
|
||||
browserProcess.Kill();
|
||||
browserProcess.WaitForExit();
|
||||
}
|
||||
|
||||
new Cmd().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CEALING_ARGUMENT);
|
||||
@ -152,6 +190,14 @@ namespace Sheas_Cealer
|
||||
new AboutWindow().ShowDialog();
|
||||
}
|
||||
|
||||
private void MONITOR_TIMER_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
if (Process.GetProcessesByName("Cealing-Clash").Length == 0)
|
||||
ClashButton.Content = "代理";
|
||||
else
|
||||
ClashButton.Content = "停代";
|
||||
}
|
||||
|
||||
private void MainWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.W)
|
||||
|
Loading…
Reference in New Issue
Block a user