mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-07-07 16:16:07 +08:00
parent
1f2fd3cd9f
commit
948018196b
|
@ -16,8 +16,6 @@
|
||||||
#import "WTConfigManager.h"
|
#import "WTConfigManager.h"
|
||||||
#import "RecallCacheManager.h"
|
#import "RecallCacheManager.h"
|
||||||
|
|
||||||
static NSString * const WeChatTweakOpenNewWeChatKey = @"WeChatTweakOpenNewWeChatKey";
|
|
||||||
|
|
||||||
// Global Function
|
// Global Function
|
||||||
static NSString *(*original_NSHomeDirectory)(void);
|
static NSString *(*original_NSHomeDirectory)(void);
|
||||||
static NSArray<NSString *> *(*original_NSSearchPathForDirectoriesInDomains)(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde);
|
static NSArray<NSString *> *(*original_NSSearchPathForDirectoriesInDomains)(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, BOOL expandTilde);
|
||||||
|
@ -401,8 +399,7 @@ static void __attribute__((constructor)) tweak(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray<NSRunningApplication *> *)tweak_runningApplicationsWithBundleIdentifier:(NSString *)bundleIdentifier {
|
+ (NSArray<NSRunningApplication *> *)tweak_runningApplicationsWithBundleIdentifier:(NSString *)bundleIdentifier {
|
||||||
BOOL openNewWeChat = [NSUserDefaults.standardUserDefaults boolForKey:WeChatTweakOpenNewWeChatKey];
|
if ([bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier] ) {
|
||||||
if (openNewWeChat && [bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier] ) {
|
|
||||||
return @[NSRunningApplication.currentApplication];
|
return @[NSRunningApplication.currentApplication];
|
||||||
} else {
|
} else {
|
||||||
return [self tweak_runningApplicationsWithBundleIdentifier:bundleIdentifier];
|
return [self tweak_runningApplicationsWithBundleIdentifier:bundleIdentifier];
|
||||||
|
@ -419,16 +416,12 @@ static void __attribute__((constructor)) tweak(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)openNewWeChatInstace:(id)sender {
|
- (void)openNewWeChatInstace:(id)sender {
|
||||||
[NSUserDefaults.standardUserDefaults setBool:YES forKey:WeChatTweakOpenNewWeChatKey];
|
|
||||||
[NSUserDefaults.standardUserDefaults synchronize];
|
|
||||||
NSString *applicationPath = NSBundle.mainBundle.bundlePath;
|
NSString *applicationPath = NSBundle.mainBundle.bundlePath;
|
||||||
NSTask *task = [[NSTask alloc] init];
|
NSTask *task = [[NSTask alloc] init];
|
||||||
task.launchPath = @"/usr/bin/open";
|
task.launchPath = @"/usr/bin/open";
|
||||||
task.arguments = @[@"-n", applicationPath];
|
task.arguments = @[@"-n", applicationPath];
|
||||||
[task launch];
|
[task launch];
|
||||||
[task waitUntilExit];
|
[task waitUntilExit];
|
||||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:WeChatTweakOpenNewWeChatKey];
|
|
||||||
[NSUserDefaults.standardUserDefaults synchronize];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Auto Auth
|
#pragma mark - Auto Auth
|
||||||
|
|
Loading…
Reference in New Issue
Block a user