Skip to content

Commit d9e8564

Browse files
committed
upload v1.1
1 parent 0aff51f commit d9e8564

10 files changed

+180
-47
lines changed

AdobeBlockListConverter.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>net9.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<PublishAot>True</PublishAot>
8+
<PublishAot>False</PublishAot>
99
<ApplicationIcon>adobe_ico_256x256.ico</ApplicationIcon>
1010
</PropertyGroup>
1111

Applications/Application.cs

+24-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,29 @@ public async Task RunAsync(string[] args)
1919
{
2020
_ui.WelcomeMessage();
2121

22+
var templates = config.AvailableTemplates;
23+
24+
Console.WriteLine("可用的模板类型:");
25+
foreach (var template in templates.Keys)
26+
{
27+
Console.WriteLine($" - {template}");
28+
}
29+
30+
Console.Write("请选择要使用的模板类型: ");
31+
string? templateType = config.GetMode(args) ?? Console.ReadLine();
32+
33+
while (true)
34+
{
35+
if (!string.IsNullOrWhiteSpace(templateType) && templates.ContainsKey(templateType.ToLower()))
36+
{
37+
config.SetTemplate(templateType);
38+
break;
39+
}
40+
41+
Console.WriteLine($"无效的模板类型,请重新输入:");
42+
templateType = Console.ReadLine();
43+
}
44+
2245
string inputFilePath = _ui.GetInputFilePath(args);
2346
string inputContent = null;
2447
bool isWebSource = false;
@@ -52,7 +75,7 @@ public async Task RunAsync(string[] args)
5275
}
5376
}
5477

55-
string outputFilePath = _ui.GetOutputFilePath(args, _config.OutputFileTemplate);
78+
string outputFilePath = _ui.GetOutputFilePath(args, _config.CurrentTemplate.OutputFileNameTemplate);
5679
await _fileService.ProcessInputFileAsync(inputFilePath, outputFilePath, isWebSource, inputContent);
5780

5881
_ui.DisplaySuccess("\r\n处理完成!");

Configs/AppConfig.cs

+92-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,104 @@
11
using AdobeBlockListConverter.Interfaces;
2+
using System.Text.Json;
23

34
namespace AdobeBlockListConverter.Configs
45
{
56
public class AppConfig : IAppConfig
67
{
8+
private readonly Dictionary<string, ConfigTemplate> _templates;
9+
private readonly string _configFilePath;
10+
private ConfigTemplate _currentTemplate;
711
public string GetBlockListUrl => "https://a.dove.isdumb.one/list.txt";
12+
public Dictionary<string, ConfigTemplate> AvailableTemplates => _templates;
13+
public ConfigTemplate CurrentTemplate => _currentTemplate;
814

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-
";
15+
public AppConfig()
16+
{
17+
_configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");
18+
19+
if (!File.Exists(_configFilePath))
20+
{
21+
Console.WriteLine("配置文件不存在: {0},创建默认配置。", _configFilePath);
22+
CreateDefaultTemplates();
23+
}
24+
25+
_templates = LoadConfigTemplates();
26+
27+
if (_templates?.Count > 0)
28+
_currentTemplate = _templates.Values.First();
29+
}
2530

26-
public string OutputFileCommand => @"
27-
commands:
28-
- proxy-groups.Fucking-Adobe.proxies.0=REJECT
31+
private void CreateDefaultTemplates()
32+
{
33+
string templateJson = @"
34+
{
35+
""cfw"": {
36+
""outputFileHeader"": ""# By KCN-Server.AdobeBlockListConverter \nparsers:\n - url: 你的订阅地址Url\n yaml:\n prepend-proxy-groups:\n - name: Fucking-Adobe\n type: select\n proxies:\n - REJECT\n \n prepend-rules:\n"",
37+
""outputLineTemplate"": "" - DOMAIN-SUFFIX,{0},Fucking-Adobe"",
38+
""outputFileCommand"": ""\n commands:\n - proxy-groups.Fucking-Adobe.proxies.0=REJECT\n"",
39+
""outputFileNameTemplate"": ""KCNServer-AdobeBlockList-CFW-{0}.txt""
40+
},
41+
""verge"": {
42+
""outputFileHeader"": ""# By KCN-Server.AdobeBlockListConverter \n# Clash Verge Merge 格式\n\nprepend-proxy-groups:\n - name: Fucking-Adobe\n type: select\n proxies:\n - REJECT\n\nprepend-rules:\n"",
43+
""outputLineTemplate"": "" - DOMAIN-SUFFIX,{0},Fucking-Adobe"",
44+
""outputFileCommand"": """",
45+
""outputFileNameTemplate"": ""KCNServer-AdobeBlockList-Verge-{0}.txt""
46+
}
47+
}
2948
";
49+
File.WriteAllText(_configFilePath, templateJson);
50+
}
51+
52+
private Dictionary<string, ConfigTemplate> LoadConfigTemplates()
53+
{
54+
try
55+
{
56+
string json = File.ReadAllText(_configFilePath);
57+
var options = new JsonSerializerOptions
58+
{
59+
PropertyNameCaseInsensitive = true
60+
};
61+
var templates = JsonSerializer.Deserialize<Dictionary<string, ConfigTemplate>>(json, options);
3062

63+
Console.WriteLine("已成功加载 {0} 个配置模板", templates.Count);
64+
return templates;
65+
}
66+
catch (Exception ex)
67+
{
68+
Console.WriteLine("加载配置模板时出错: {0}", ex.Message);
69+
return new Dictionary<string, ConfigTemplate>();
70+
}
71+
}
72+
73+
public void SetTemplate(string templateType)
74+
{
75+
if (string.IsNullOrWhiteSpace(templateType))
76+
throw new ArgumentNullException(nameof(templateType));
77+
78+
if (!_templates.TryGetValue(templateType.ToLower(), out var template))
79+
throw new ArgumentException($"未找到模板类型: {templateType}");
80+
81+
template.OutputFileNameTemplate =
82+
Path.Combine(Environment.CurrentDirectory,
83+
string.Format(_currentTemplate.OutputFileNameTemplate, Guid.NewGuid()));
84+
_currentTemplate = template;
85+
86+
Console.WriteLine("已切换到模板: {0}", templateType);
87+
}
88+
89+
public string? GetMode(string[] args)
90+
{
91+
try
92+
{
93+
if(args.Length > 0)
94+
return args[0];
95+
return null;
96+
}
97+
catch (Exception ex)
98+
{
99+
Console.WriteLine("出错了: {0}", ex.Message);
100+
return null;
101+
}
102+
}
31103
}
32-
}
104+
}

Interfaces/IAppConfig.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace AdobeBlockListConverter.Interfaces
2+
{
3+
public interface IAppConfig
4+
{
5+
string GetBlockListUrl { get; }
6+
string? GetMode(string[] args);
7+
ConfigTemplate CurrentTemplate { get; }
8+
Dictionary<string, ConfigTemplate> AvailableTemplates { get; }
9+
void SetTemplate(string templateType);
10+
}
11+
12+
public class ConfigTemplate
13+
{
14+
public string OutputFileHeader { get; set; }
15+
public string OutputLineTemplate { get; set; }
16+
public string OutputFileCommand { get; set; }
17+
public string OutputFileNameTemplate { get; set; }
18+
}
19+
}

Interfaces/Interface.cs

-10
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,4 @@ public interface IUserInterface
3434
string GetInputFilePath(string[] args);
3535
string GetOutputFilePath(string[] args, string defaultPath);
3636
}
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-
4737
}

Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static async Task Main(string[] args)
2424
Console.ResetColor();
2525
}
2626

27-
if (!(args.Length > 2 && args[2] == "-q"))
27+
if (!(args.Length > 3 && args[3] == "-q"))
2828
{
2929
Console.WriteLine($"\r\n按任意键退出。");
3030
Console.ReadKey();

README.md

+32-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,40 @@
44
# FuckingAdobe - KCNServer.AdobeBlockListConverter
55

66
</strong></div>
7-
- 杜绝Adobe非正版弹窗 - 自动拉取Adobe反盗版弹窗域名列表并生成适用于Clash的预处理屏蔽配置文件。
7+
> 杜绝Adobe非正版弹窗 - 自动拉取Adobe反盗版弹窗域名列表并生成适用于Clash的预处理屏蔽配置文件。
8+
>
9+
> 今天下午我用着用着Ps突然给我弹了一个反盗版弹窗,然后软件就用不了了。频繁重装很讨厌,于是花了一会时间摸了这个小项目。
10+
>
11+
> 使用本软件生成的配置文件可以有效消灭Adobe的非正版弹窗。具体教程请看程序内说明。**记得配合 [AdobeGenp破解补丁](https://github.com/wangzhenjjcn/AdobeGenp) 使用喵!**
812
9-
- 今天下午我用着用着Ps突然给我弹了一个反盗版弹窗,然后软件就用不了了。频繁重装很讨厌,于是花了一会时间摸了这个小项目。
13+
## 配置模板说明
1014

11-
- 使用本软件生成的配置文件可以有效消灭Adobe的非正版弹窗。具体教程请看程序内说明。记得配合 [AdobeGenp破解补丁](https://github.com/wangzhenjjcn/AdobeGenp) 使用喵!
15+
`v1.1`版本起,本程序使用 `config.json` 文件存储不同客户端的配置模板。您可以根据需要修改此文件以自定义配置模板。
16+
17+
### 配置文件结构
18+
19+
```json
20+
{
21+
"模板名称": {
22+
"outputFileHeader": "配置文件头部内容",
23+
"outputLineTemplate": "每个域名的行模板,使用 {0} 作为域名占位符",
24+
"outputFileCommand": "配置文件尾部内容",
25+
"outputFileNameTemplate": "文件名模板,使用 {0} 作为唯一ID占位符"
26+
}
27+
}
28+
```
29+
30+
### 预设模板
31+
32+
1. `cfw` - 适用于 Clash For Windows 的配置模板
33+
2. `verge` - 适用于 Clash Verge 的配置模板
34+
35+
### 如何添加新模板
36+
37+
1. 打开 `config.json` 文件
38+
2. 按照上述结构添加新的模板
39+
3. 保存文件
40+
4. 重新启动程序
1241

1342
## ⚠️ 免责声明
1443
本项目仅供研究交流用,禁止用于商业及非法用途。使用本项目造成的事故与损失,与作者无关。本项目完全免费,如果您是花钱买的,说明您被骗了。请尽快退款,以减少您的损失。

Services/ConsoleUserInterface.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public string GetUserInput(string prompt, string defaultValue = null)
1515

1616
public void WelcomeMessage()
1717
{
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");
18+
Console.Title = "KCN-Server Adobe全家桶屏蔽域名表转换程序 -V1.1.0";
19+
Console.WriteLine("\r\nKCN-Server Adobe全家桶屏蔽域名表转换程序 -V1.1.0\r\nFucking Adobe!通过配置Clash使你的Adobe全家桶不再弹窗。\r\n");
20+
Console.WriteLine("Usage: AdobeBlockListConverter mode<转换模式,根据json配置自定义> input<本地源文件路径,web为联网自动获取> output<输出文件路径,auto为创建在程序运行根目录下> [-q]<静默结束>\r\n");
2121
Console.WriteLine($"请前往 {_config.GetBlockListUrl} 查看屏蔽域名列表。");
22-
Console.WriteLine("配置步骤: \r\n1. 打开导出的预处理配置文本,复制文本。\r\n2. 打开Clash程序,点击左边栏配置项。\r\n3. 右键你正在使用的订阅(绿色),唤出二级菜单,点击配置文件预处理。\r\n5. 在编辑器里粘贴,把导出配置的url处改成你的订阅地址,然后保存。\r\n6. 回到主页,打开TUN模式,配置完成。");
22+
Console.WriteLine("配置步骤[仅适用于Clash For Windows]: \r\n1. 打开导出的预处理配置文本,复制文本。\r\n2. 打开Clash程序,点击左边栏配置项。\r\n3. 右键你正在使用的订阅(绿色),唤出二级菜单,点击配置文件预处理。\r\n5. 在编辑器里粘贴,把导出配置的url处改成你的订阅地址,然后保存。\r\n6. 回到主页,打开TUN模式,配置完成。");
2323
Console.WriteLine("记得把导出配置的url处改成你的订阅地址再保存!要否则无法使用!\r\n");
2424
}
2525

@@ -46,9 +46,9 @@ public string GetInputFilePath(string[] args)
4646
{
4747
string inputFilePath;
4848

49-
if (args.Length > 0 && args[0] != null)
49+
if (args.Length > 1 && args[1] != null)
5050
{
51-
inputFilePath = args[0];
51+
inputFilePath = args[1];
5252
DisplayMessage($"输入文件路径: {inputFilePath}");
5353
}
5454
else
@@ -63,9 +63,9 @@ public string GetOutputFilePath(string[] args, string defaultPath)
6363
{
6464
string outputFilePath;
6565

66-
if (args.Length > 1 && args[1] != null)
66+
if (args.Length > 2 && args[2] != null)
6767
{
68-
outputFilePath = args[1];
68+
outputFilePath = args[2];
6969
DisplayMessage($"输出文件路径: {outputFilePath}");
7070
}
7171
else

Services/DataProcessor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public string ProcessLine(string line)
2020
if (match.Success)
2121
domain = match.Groups[1].Value.Trim();
2222

23-
return string.Format(_config.OutputLineTemplate, domain);
23+
return string.Format(_config.CurrentTemplate.OutputLineTemplate, domain);
2424
}
2525

2626
public async Task<string> ProcessDataAsync(string inputData)

Services/FileService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public async Task WriteToFileAsync(string path, string content)
3535

3636
public async Task ProcessInputFileAsync(string inputPath, string outputPath, bool isWebSource, string webContent = null)
3737
{
38-
string processedContent = _config.OutputFileHeader;
38+
string processedContent = _config.CurrentTemplate.OutputFileHeader;
3939

4040
if (isWebSource && !string.IsNullOrEmpty(webContent))
4141
{
@@ -47,7 +47,7 @@ public async Task ProcessInputFileAsync(string inputPath, string outputPath, boo
4747
processedContent += await _dataProcessor.ProcessDataAsync(fileContent);
4848
}
4949

50-
processedContent += _config.OutputFileCommand;
50+
processedContent += _config.CurrentTemplate.OutputFileCommand;
5151

5252
await WriteToFileAsync(outputPath, processedContent);
5353
}

0 commit comments

Comments
 (0)