mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-07-07 16:16:07 +08:00
Add tweak for prevent logout
This commit is contained in:
parent
5dd8ca7a40
commit
494cbea029
|
@ -17,6 +17,7 @@
|
|||
- 客户端无限多开
|
||||
- 右键 Dock Icon 登录新的微信账号
|
||||
- 命令行执行:`open -n /Applications/WeChat.app`
|
||||
- 阻止退出登录(重新打开应用无需手机认证)
|
||||
|
||||
## 使用
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ A dynamic library tweak for WeChat macOS.
|
|||
- Multiple WeChat Instance
|
||||
- Right click on the Dock icon to login another WeChat account
|
||||
- Run command: `open -n /Applications/WeChat.app`
|
||||
- Prevent logout (Auto login without authority)
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
Binary file not shown.
|
@ -9,14 +9,16 @@
|
|||
#pragma mark - Constructor
|
||||
|
||||
static void __attribute__((constructor)) tweak(void) {
|
||||
[objc_getClass("MessageService") jr_swizzleMethod:NSSelectorFromString(@"onRevokeMsg:") withMethod:@selector(tweak_OnRevokeMsg:) error:nil];
|
||||
[objc_getClass("MessageService") jr_swizzleMethod:NSSelectorFromString(@"onRevokeMsg:") withMethod:@selector(tweak_onRevokeMsg:) error:nil];
|
||||
[objc_getClass("CUtility") jr_swizzleClassMethod:NSSelectorFromString(@"HasWechatInstance") withClassMethod:@selector(tweak_HasWechatInstance) error:nil];
|
||||
class_addMethod(objc_getClass("AppDelegate"), @selector(applicationDockMenu:), method_getImplementation(class_getInstanceMethod(objc_getClass("AppDelegate"), @selector(applicationDockMenu:))), "@:@");
|
||||
class_addMethod(objc_getClass("AppDelegate"), @selector(applicationDockMenu:), method_getImplementation(class_getInstanceMethod(objc_getClass("AppDelegate"), @selector(tweak_applicationDockMenu:))), "@:@");
|
||||
[objc_getClass("AppDelegate") jr_swizzleMethod:NSSelectorFromString(@"applicationDidFinishLaunching:") withMethod:@selector(tweak_applicationDidFinishLaunching:) error:nil];
|
||||
[objc_getClass("AppDelegate") jr_swizzleMethod:NSSelectorFromString(@"applicationShouldTerminate:") withMethod:@selector(tweak_applicationShouldTerminate:) error:nil];
|
||||
}
|
||||
|
||||
#pragma mark - No Revoke Message
|
||||
|
||||
- (void)tweak_OnRevokeMsg:(NSString *)message {
|
||||
- (void)tweak_onRevokeMsg:(NSString *)message {
|
||||
NSRange begin = [message rangeOfString:@"<replacemsg><![CDATA["];
|
||||
NSRange end = [message rangeOfString:@"]]></replacemsg>"];
|
||||
NSRange subRange = NSMakeRange(begin.location + begin.length,end.location - begin.location - begin.length);
|
||||
|
@ -34,7 +36,7 @@ static void __attribute__((constructor)) tweak(void) {
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
|
||||
- (NSMenu *)tweak_applicationDockMenu:(NSApplication *)sender {
|
||||
NSMenu *menu = [[objc_getClass("NSMenu") alloc] init];
|
||||
NSMenuItem *menuItem = [[objc_getClass("NSMenuItem") alloc] initWithTitle:@"登录新的微信账号" action:@selector(openNewWeChatInstace:) keyEquivalent:@""];
|
||||
[menu insertItem:menuItem atIndex:0];
|
||||
|
@ -49,4 +51,22 @@ static void __attribute__((constructor)) tweak(void) {
|
|||
[task launch];
|
||||
}
|
||||
|
||||
#pragma mark - No Logout
|
||||
|
||||
- (void)tweak_applicationDidFinishLaunching:(NSNotification *)notification {
|
||||
[self tweak_applicationDidFinishLaunching:notification];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wobjc-method-access"
|
||||
id serviceCenter = [objc_getClass("MMServiceCenter") defaultCenter];
|
||||
id accountService = [serviceCenter getService:objc_getClass("AccountService")];
|
||||
if ([accountService canAutoAuth]) {
|
||||
[accountService AutoAuth];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)tweak_applicationShouldTerminate:(NSApplication *)sender {
|
||||
return NSTerminateNow;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue
Block a user