Compare commits

..

5 Commits

Author SHA1 Message Date
Sunny Young
b9970a1ee5 config: add version 32281 support 2025-12-06 13:43:58 +08:00
Sunny Young
0ded215c3f refactor: use async/await instead of promises
support both local and network config
2025-12-06 13:42:56 +08:00
Sunny Young
bfbfe1bb29 config: add support for multiple instances 2025-12-05 19:44:30 +08:00
Sunny Young
19f1c446a6 fix a config.json reading issue 2025-12-05 17:37:06 +08:00
Sunny Young
c51ccc8ac9 refactor: support WeChat 4.x 2025-12-05 15:52:37 +08:00
6 changed files with 82 additions and 217 deletions

1
.ruby-version Normal file
View File

@ -0,0 +1 @@
2.7.8

5
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,5 @@
# Contributing
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
[![Contributors](https://opencollective.com/WeChatTweak-macOS/contributors.svg?width=890&button=false)](https://github.com/Sunnyyoung/WeChatTweak-macOS/graphs/contributors)

View File

@ -1,10 +1,7 @@
# WeChatTweak
[![README](https://img.shields.io/badge/GitHub-black?logo=github&logoColor=white)](https://github.com/sunnyyoung/WeChatTweak)
[![README](https://img.shields.io/badge/Telegram-black?logo=telegram&logoColor=white)](https://t.me/wechattweak)
[![README](https://img.shields.io/badge/FAQ-black?logo=googledocs&logoColor=white)](https://github.com/sunnyyoung/WeChatTweak/wiki/FAQ)
A command-line tool for tweaking WeChat.
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)
[![README](https://img.shields.io/badge/Telegram-WeChatTweak-brightgreen.svg)](https://t.me/wechattweak)
## 功能
@ -12,20 +9,16 @@ A command-line tool for tweaking WeChat.
- 阻止自动更新
- 客户端多开
## 安装&使用
## 安装
```bash
# 安装
brew install sunnyyoung/tap/wechattweak
```
# 更新
brew upgrade wechattweak
## 使用
# 执行 Patch
```bash
wechattweak patch
# 查看所有支持的 WeChat 版本
wechattweak versions
```
## 参考
@ -36,9 +29,9 @@ wechattweak versions
## 贡献者
This project exists thanks to all the people who contribute.
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
[![Contributors](https://contrib.rocks/image?repo=sunnyyoung/WeChatTweak)](https://github.com/sunnyyoung/WeChatTweak/graphs/contributors)
[![Contributors](https://opencollective.com/WeChatTweak-macOS/contributors.svg?width=890&button=false)](https://github.com/Sunnyyoung/WeChatTweak-macOS/graphs/contributors)
## License

View File

@ -81,7 +81,7 @@ struct Config: Decodable {
let version: String
let targets: [Target]
static func load(url: URL) async throws -> [Config] {
static func load(from url: URL) async throws -> [Config] {
if url.isFileURL {
return try JSONDecoder().decode(
[Config].self,

View File

@ -8,64 +8,7 @@ import Foundation
import Dispatch
import ArgumentParser
// MARK: Versions
extension Tweak {
struct Versions: AsyncParsableCommand {
static let configuration = CommandConfiguration(abstract: "List all supported WeChat versions")
@OptionGroup
var options: Tweak.Options
mutating func run() async throws {
print("------ Current version ------")
print(try await Command.version(app: options.app) ?? "unknown")
print("------ Supported versions ------")
try await Config.load(url: options.config).forEach({ print($0.version) })
Darwin.exit(EXIT_SUCCESS)
}
}
}
// MARK: Patch
extension Tweak {
struct Patch: AsyncParsableCommand {
static let configuration = CommandConfiguration(abstract: "Patch WeChat.app")
@OptionGroup
var options: Tweak.Options
mutating func run() async throws {
print("------ Version ------")
let version = try await Command.version(app: options.app)
print("WeChat version: \(version ?? "unknown")")
print("------ Config ------")
guard let config = (try await Config.load(url: options.config)).first(where: { $0.version == version }) else {
throw Error.unsupportedVersion
}
print("Matched config: \(config)")
print("------ Patch ------")
try await Command.patch(
app: options.app,
config: config
)
print("Done!")
print("------ Resign ------")
try await Command.resign(
app: options.app
)
print("Done!")
Darwin.exit(EXIT_SUCCESS)
}
}
}
// MARK: Tweak
struct Tweak: AsyncParsableCommand {
struct Patch: AsyncParsableCommand {
enum Error: LocalizedError {
case invalidApp
case invalidConfig
@ -86,49 +29,82 @@ struct Tweak: AsyncParsableCommand {
}
}
struct Options: ParsableArguments {
@Option(
name: .shortAndLong,
help: "Path of WeChat.app",
transform: {
guard FileManager.default.fileExists(atPath: $0) else {
throw Error.invalidApp
}
static let configuration = CommandConfiguration(abstract: "Patch WeChat.app")
@Option(
name: .shortAndLong,
help: "Path of WeChat.app",
transform: {
guard FileManager.default.fileExists(atPath: $0) else {
throw Error.invalidApp
}
return URL(fileURLWithPath: $0)
}
)
var app: URL = URL(fileURLWithPath: "/Applications/WeChat.app", isDirectory: true)
@Option(
name: .shortAndLong,
help: "Local path or Remote URL of config.json",
transform: {
if FileManager.default.fileExists(atPath: $0) {
return URL(fileURLWithPath: $0)
}
)
var app: URL = URL(fileURLWithPath: "/Applications/WeChat.app", isDirectory: true)
@Option(
name: .shortAndLong,
help: "Local path or Remote URL of config.json",
transform: {
if FileManager.default.fileExists(atPath: $0) {
return URL(fileURLWithPath: $0)
} else {
guard let url = URL(string: $0) else {
throw Error.invalidConfig
}
return url
} else {
guard let url = URL(string: $0) else {
throw Error.invalidConfig
}
return url
}
)
var config: URL = URL(string:"https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/master/config.json")!
}
}
)
var config: URL = URL(string: "https://raw.githubusercontent.com/sunnyyoung/WeChatTweak/refs/heads/feature/2.0/config.json")!
mutating func run() async throws {
do {
print("------ Version ------")
guard let version = try await Command.version(app: self.app) else {
throw Error.invalidVersion
}
print("\(version)")
print("------ Config ------")
guard let config = (try await Config.load(from: self.config)).first(where: { $0.version == version }) else {
throw Error.unsupportedVersion
}
print("\(config)")
print("------ Patch ------")
try await Command.patch(
app: self.app,
config: config
)
print("Done!")
print("------ Resign ------")
try await Command.resign(
app: self.app
)
print("Done!")
print("------🎉 Done!------")
Darwin.exit(EXIT_SUCCESS)
} catch {
print("------🚨 Error------")
print("\(error.localizedDescription)")
Darwin.exit(EXIT_FAILURE)
}
}
}
struct Tweak: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "wechattweak",
abstract: "A command-line tool for tweaking WeChat.",
subcommands: [
Versions.self,
Patch.self
]
],
defaultSubcommand: Self.self
)
mutating func run() async throws {
print(Tweak.helpMessage())
Darwin.exit(EXIT_SUCCESS)
}
}
Task {

View File

@ -168,115 +168,5 @@
]
}
]
},
{
"version": "32288",
"targets": [
{
"identifier": "revoke",
"entries": [
{
"arch": "arm64",
"addr": "103db34c0",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "startUpdater",
"entries": [
{
"arch": "arm64",
"addr": "1001e9ed0",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "startBackgroundUpdatesCheck",
"entries": [
{
"arch": "arm64",
"addr": "1001ecb10",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "checkForUpdates",
"entries": [
{
"arch": "arm64",
"addr": "1001ec73c",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "enableAutoUpdate",
"entries": [
{
"arch": "arm64",
"addr": "1001ecfc0",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "automaticallyDownloadsUpdates",
"entries": [
{
"arch": "arm64",
"addr": "1001f59e0",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "canCheckForUpdate",
"entries": [
{
"arch": "arm64",
"addr": "1001f59e0",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "multiInstance",
"entries": [
{
"arch": "arm64",
"addr": "1001e1a74",
"asm": "20008052C0035FD6"
}
]
}
]
},
{
"version": "31960",
"targets": [
{
"identifier": "revoke",
"entries": [
{
"arch": "arm64",
"addr": "10408a408",
"asm": "00008052C0035FD6"
}
]
},
{
"identifier": "multiInstance",
"entries": [
{
"arch": "arm64",
"addr": "1001e4a38",
"asm": "20008052C0035FD6"
}
]
}
]
}
]