Skip to content

Commit 0aff51f

Browse files
committed
upload
1 parent af46d8e commit 0aff51f

12 files changed

+477
-2
lines changed

AdobeBlockListConverter.csproj

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<PublishAot>True</PublishAot>
9+
<ApplicationIcon>adobe_ico_256x256.ico</ApplicationIcon>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<Content Include="adobe_ico_256x256.ico" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.2" />
18+
</ItemGroup>
19+
20+
</Project>

Applications/Application.cs

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using AdobeBlockListConverter.Interfaces;
2+
3+
namespace AdobeBlockListConverter.Applications
4+
{
5+
public class Application(
6+
IUserInterface ui,
7+
IFileService fileService,
8+
INetworkService networkService,
9+
IAppConfig config) : IApplication
10+
{
11+
private readonly IUserInterface _ui = ui ?? throw new ArgumentNullException(nameof(ui));
12+
private readonly IFileService _fileService = fileService ?? throw new ArgumentNullException(nameof(fileService));
13+
private readonly INetworkService _networkService = networkService ?? throw new ArgumentNullException(nameof(networkService));
14+
private readonly IAppConfig _config = config ?? throw new ArgumentNullException(nameof(config));
15+
16+
public async Task RunAsync(string[] args)
17+
{
18+
try
19+
{
20+
_ui.WelcomeMessage();
21+
22+
string inputFilePath = _ui.GetInputFilePath(args);
23+
string inputContent = null;
24+
bool isWebSource = false;
25+
26+
while (true)
27+
{
28+
if (inputFilePath == "web")
29+
{
30+
_ui.DisplayMessage("正在从网络获取数据...");
31+
inputContent = await _networkService.DownloadFileContentAsync(_config.GetBlockListUrl);
32+
33+
if (string.IsNullOrEmpty(inputContent))
34+
{
35+
_ui.DisplayError("无法从网络获取数据,请检查网络连接或尝试手动下载文件。");
36+
inputFilePath = _ui.GetUserInput("请输入本地源文件路径(或输入web重试):");
37+
continue;
38+
}
39+
40+
_ui.DisplaySuccess("网络数据获取成功!");
41+
isWebSource = true;
42+
break;
43+
}
44+
else if (_fileService.FileExists(inputFilePath))
45+
{
46+
break;
47+
}
48+
else
49+
{
50+
_ui.DisplayError("指定文件不存在!");
51+
inputFilePath = _ui.GetUserInput("请输入本地源文件路径(或输入web自动从网络获取):");
52+
}
53+
}
54+
55+
string outputFilePath = _ui.GetOutputFilePath(args, _config.OutputFileTemplate);
56+
await _fileService.ProcessInputFileAsync(inputFilePath, outputFilePath, isWebSource, inputContent);
57+
58+
_ui.DisplaySuccess("\r\n处理完成!");
59+
}
60+
catch (Exception ex)
61+
{
62+
_ui.DisplayError($"\r\n处理过程中发生错误:{ex.Message}");
63+
throw;
64+
}
65+
}
66+
}
67+
}

Configs/AppConfig.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using AdobeBlockListConverter.Interfaces;
2+
3+
namespace AdobeBlockListConverter.Configs
4+
{
5+
public class AppConfig : IAppConfig
6+
{
7+
public string GetBlockListUrl => "https://a.dove.isdumb.one/list.txt";
8+
9+
public string OutputFileTemplate => Path.Combine(Environment.CurrentDirectory, $"KCNServer-AdobeBlockList-{Guid.NewGuid()}.txt");
10+
11+
public string OutputLineTemplate => " - DOMAIN-SUFFIX,{0},Fucking-Adobe";
12+
13+
public string OutputFileHeader => @"# By KCN-Server.AdobeBlockListConverter
14+
parsers:
15+
- url: 你的订阅地址Url
16+
yaml:
17+
prepend-proxy-groups:
18+
- name: Fucking-Adobe
19+
type: select
20+
proxies:
21+
- REJECT
22+
23+
prepend-rules:
24+
";
25+
26+
public string OutputFileCommand => @"
27+
commands:
28+
- proxy-groups.Fucking-Adobe.proxies.0=REJECT
29+
";
30+
31+
}
32+
}

Interfaces/Interface.cs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
namespace AdobeBlockListConverter.Interfaces
2+
{
3+
public interface IApplication
4+
{
5+
Task RunAsync(string[] args);
6+
}
7+
8+
public interface IFileService
9+
{
10+
bool FileExists(string path);
11+
Task<string> ReadFileAsync(string path);
12+
Task WriteToFileAsync(string path, string content);
13+
Task ProcessInputFileAsync(string inputPath, string outputPath, bool isWebSource, string webContent = null);
14+
}
15+
16+
public interface INetworkService
17+
{
18+
Task<string> DownloadFileContentAsync(string url);
19+
}
20+
21+
public interface IDataProcessor
22+
{
23+
string ProcessLine(string line);
24+
Task<string> ProcessDataAsync(string inputData);
25+
}
26+
27+
public interface IUserInterface
28+
{
29+
string GetUserInput(string prompt, string defaultValue = null);
30+
void WelcomeMessage();
31+
void DisplayMessage(string message);
32+
void DisplayError(string message);
33+
void DisplaySuccess(string message);
34+
string GetInputFilePath(string[] args);
35+
string GetOutputFilePath(string[] args, string defaultPath);
36+
}
37+
38+
public interface IAppConfig
39+
{
40+
string GetBlockListUrl { get; }
41+
string OutputFileTemplate { get; }
42+
string OutputLineTemplate { get; }
43+
string OutputFileHeader { get; }
44+
string OutputFileCommand { get; }
45+
}
46+
47+
}

KCNServer.AdobeBlockListConverter.sln

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdobeBlockListConverter", "AdobeBlockListConverter.csproj", "{C9400798-53E9-40F8-9066-D9BF0C5DED0F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{C9400798-53E9-40F8-9066-D9BF0C5DED0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C9400798-53E9-40F8-9066-D9BF0C5DED0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C9400798-53E9-40F8-9066-D9BF0C5DED0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C9400798-53E9-40F8-9066-D9BF0C5DED0F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

Program.cs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using AdobeBlockListConverter.Configs;
2+
using AdobeBlockListConverter.Interfaces;
3+
using AdobeBlockListConverter.Services;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Application = AdobeBlockListConverter.Applications.Application;
6+
7+
namespace AdobeBlockListConverter
8+
{
9+
public static class Program
10+
{
11+
public static async Task Main(string[] args)
12+
{
13+
try
14+
{
15+
var serviceProvider = ConfigureServices();
16+
var app = serviceProvider.GetRequiredService<IApplication>();
17+
await app.RunAsync(args);
18+
}
19+
catch (Exception ex)
20+
{
21+
Console.ForegroundColor = ConsoleColor.Red;
22+
Console.WriteLine($"\r\n未处理的异常:{ex.Message}");
23+
Console.WriteLine(ex.StackTrace);
24+
Console.ResetColor();
25+
}
26+
27+
if (!(args.Length > 2 && args[2] == "-q"))
28+
{
29+
Console.WriteLine($"\r\n按任意键退出。");
30+
Console.ReadKey();
31+
}
32+
}
33+
34+
private static ServiceProvider ConfigureServices()
35+
{
36+
var services = new ServiceCollection();
37+
38+
services.AddSingleton<IAppConfig, AppConfig>();
39+
services.AddTransient<IFileService, FileService>();
40+
services.AddTransient<INetworkService, NetworkService>();
41+
services.AddTransient<IDataProcessor, DataProcessor>();
42+
services.AddTransient<IUserInterface, ConsoleUserInterface>();
43+
services.AddTransient<IApplication, Application>();
44+
45+
return services.BuildServiceProvider();
46+
}
47+
}
48+
}

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1-
# FuckingAdobe
2-
杜绝Adobe非正版弹窗 - 自动拉取Adobe反盗版弹窗域名列表并生成适用于Clash的预处理屏蔽配置文件。
1+
2+
<div align="center"><strong>
3+
4+
# FuckingAdobe - KCNServer.AdobeBlockListConverter
5+
6+
</strong></div>
7+
- 杜绝Adobe非正版弹窗 - 自动拉取Adobe反盗版弹窗域名列表并生成适用于Clash的预处理屏蔽配置文件。
8+
9+
- 今天下午我用着用着Ps突然给我弹了一个反盗版弹窗,然后软件就用不了了。频繁重装很讨厌,于是花了一会时间摸了这个小项目。
10+
11+
- 使用本软件生成的配置文件可以有效消灭Adobe的非正版弹窗。具体教程请看程序内说明。记得配合 [AdobeGenp破解补丁](https://github.com/wangzhenjjcn/AdobeGenp) 使用喵!
12+
13+
## ⚠️ 免责声明
14+
本项目仅供研究交流用,禁止用于商业及非法用途。使用本项目造成的事故与损失,与作者无关。本项目完全免费,如果您是花钱买的,说明您被骗了。请尽快退款,以减少您的损失。

Services/ConsoleUserInterface.cs

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using AdobeBlockListConverter.Interfaces;
2+
3+
namespace AdobeBlockListConverter.Services
4+
{
5+
public class ConsoleUserInterface(IAppConfig config) : IUserInterface
6+
{
7+
private readonly IAppConfig _config = config ?? throw new ArgumentNullException(nameof(config));
8+
9+
public string GetUserInput(string prompt, string defaultValue = null)
10+
{
11+
Console.Write(prompt);
12+
string input = Console.ReadLine()?.Trim();
13+
return string.IsNullOrEmpty(input) ? defaultValue : input;
14+
}
15+
16+
public void WelcomeMessage()
17+
{
18+
Console.Title = "KCN-Server Adobe全家桶屏蔽域名表转换程序 -V1.0.0";
19+
Console.WriteLine("KCN-Server Adobe全家桶屏蔽域名表转换程序 -V1.0.0\r\nFucking Adobe!通过配置Clash使你的Adobe全家桶不再弹窗。\r\n");
20+
Console.WriteLine("Usage: AdobeBlockListConverter input<本地源文件路径,web为联网自动获取> output<输出文件路径,auto为创建在程序运行根目录下> [-q]<静默结束>\r\n");
21+
Console.WriteLine($"请前往 {_config.GetBlockListUrl} 查看屏蔽域名列表。");
22+
Console.WriteLine("配置步骤: \r\n1. 打开导出的预处理配置文本,复制文本。\r\n2. 打开Clash程序,点击左边栏配置项。\r\n3. 右键你正在使用的订阅(绿色),唤出二级菜单,点击配置文件预处理。\r\n5. 在编辑器里粘贴,把导出配置的url处改成你的订阅地址,然后保存。\r\n6. 回到主页,打开TUN模式,配置完成。");
23+
Console.WriteLine("记得把导出配置的url处改成你的订阅地址再保存!要否则无法使用!\r\n");
24+
}
25+
26+
public void DisplayMessage(string message)
27+
{
28+
Console.WriteLine(message);
29+
}
30+
31+
public void DisplayError(string message)
32+
{
33+
Console.ForegroundColor = ConsoleColor.Red;
34+
Console.WriteLine(message);
35+
Console.ResetColor();
36+
}
37+
38+
public void DisplaySuccess(string message)
39+
{
40+
Console.ForegroundColor = ConsoleColor.Green;
41+
Console.WriteLine(message);
42+
Console.ResetColor();
43+
}
44+
45+
public string GetInputFilePath(string[] args)
46+
{
47+
string inputFilePath;
48+
49+
if (args.Length > 0 && args[0] != null)
50+
{
51+
inputFilePath = args[0];
52+
DisplayMessage($"输入文件路径: {inputFilePath}");
53+
}
54+
else
55+
{
56+
inputFilePath = GetUserInput("请输入源文件路径(输入web自动从网络获取):");
57+
}
58+
59+
return inputFilePath;
60+
}
61+
62+
public string GetOutputFilePath(string[] args, string defaultPath)
63+
{
64+
string outputFilePath;
65+
66+
if (args.Length > 1 && args[1] != null)
67+
{
68+
outputFilePath = args[1];
69+
DisplayMessage($"输出文件路径: {outputFilePath}");
70+
}
71+
else
72+
{
73+
outputFilePath = GetUserInput("请输入输出文件路径(输入auto自动创建在程序根目录):");
74+
}
75+
76+
if (string.IsNullOrEmpty(outputFilePath) || outputFilePath.Equals("auto", StringComparison.OrdinalIgnoreCase))
77+
{
78+
outputFilePath = defaultPath;
79+
DisplayMessage($"文件自动创建于 {outputFilePath}");
80+
}
81+
82+
return outputFilePath;
83+
}
84+
}
85+
}

Services/DataProcessor.cs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using AdobeBlockListConverter.Interfaces;
2+
using System.Text;
3+
using System.Text.RegularExpressions;
4+
5+
namespace AdobeBlockListConverter.Services
6+
{
7+
public class DataProcessor(IAppConfig config) : IDataProcessor
8+
{
9+
private readonly IAppConfig _config = config ?? throw new ArgumentNullException(nameof(config));
10+
private readonly Regex _ipPattern = new Regex(@"^0\.0\.0\.0\s+(.+)$", RegexOptions.Compiled);
11+
12+
public string ProcessLine(string line)
13+
{
14+
if (string.IsNullOrWhiteSpace(line) || line.TrimStart().StartsWith("#"))
15+
return null;
16+
17+
string domain = line.Trim();
18+
19+
Match match = _ipPattern.Match(domain);
20+
if (match.Success)
21+
domain = match.Groups[1].Value.Trim();
22+
23+
return string.Format(_config.OutputLineTemplate, domain);
24+
}
25+
26+
public async Task<string> ProcessDataAsync(string inputData)
27+
{
28+
if (string.IsNullOrEmpty(inputData))
29+
return string.Empty;
30+
31+
StringBuilder result = new StringBuilder();
32+
33+
using (StringReader reader = new StringReader(inputData))
34+
{
35+
string line;
36+
while ((line = await reader.ReadLineAsync()) != null)
37+
{
38+
string processedLine = ProcessLine(line);
39+
if (!string.IsNullOrEmpty(processedLine))
40+
{
41+
result.AppendLine(processedLine);
42+
}
43+
}
44+
}
45+
46+
return result.ToString();
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)