Skip to content

Commit

Permalink
Merge pull request #761 from MustangYM/develope
Browse files Browse the repository at this point in the history
v2.8.1
  • Loading branch information
MustangYM authored Dec 26, 2020
2 parents f3deba1 + b899af7 commit 1699adc
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store
.xcuserstate
.xcuserstate
Binary file modified WeChatExtension.pkg
Binary file not shown.
Binary file modified WeChatExtension/Rely/Plugin/WeChatExtension.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.8.0</string>
<string>2.8.1</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down Expand Up @@ -45,6 +45,6 @@
<key>showUpdateWindow</key>
<true/>
<key>versionInfo</key>
<string>v2.8.0(2020-12-23):\n👉🏻 适配微信v2.6.0 (16787)\n👉🏻 暂未适配BigSur\n</string>
<string>v2.8.1(2020-12-26):\n👉🏻 适配微信v2.6.0 (16787)\n👉🏻 修复消息撤回Bug \n👉🏻 适配联系人和会话选择界面和若干问题 \n👉🏻 暂未适配BigSur\n</string>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions WeChatExtension/WeChatExtension/Base.lproj/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.8.0</string>
<string>2.8.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
Expand All @@ -25,6 +25,6 @@
<key>showUpdateWindow</key>
<true/>
<key>versionInfo</key>
<string>v2.8.0(2020-12-23):\n👉🏻 适配微信v2.6.0 (16787)\n👉🏻 暂未适配BigSur\n</string>
<string>v2.8.1(2020-12-26):\n👉🏻 适配微信v2.6.0 (16787)\n👉🏻 修复消息撤回Bug \n👉🏻 适配联系人和会话选择界面和若干问题 \n👉🏻 暂未适配BigSur\n</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define kRGBColor(r,g,b,a) [NSColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]
#define kArc4random_Double_inSpace(a,b) a<b ? rand() / (float)RAND_MAX * (b-a) * 1 + (a) : rand() / (float)RAND_MAX * (a-b) * 1 + (b)
//99 157
#define kFuzzyBacgroundColor kRGBColor(24, 99, 157, 0.01)
#define kFuzzyBacgroundColor kRGBColor(41, 43, 57, 0.01)
#define kDarkBacgroundColor kRGBColor(24, 34, 45, 1.0)
#define kLightDarkBacgroundColor kRGBColor(54, 54, 54, 1.0)
#define kPinkBacgroundColor kRGBColor(229,173,177,1.0)
Expand Down
90 changes: 65 additions & 25 deletions WeChatExtension/WeChatExtension/Sources/Hook/NSObject+ThemeHook.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ + (void)hookTheme
}

if (YMWeChatPluginConfig.sharedConfig.usingTheme) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
hookMethod(objc_getClass("MMTextField"), @selector(setTextColor:), [self class], @selector(hook_setTextColor:));
hookMethod([NSTextField class], @selector(setAttributedStringValue:), [self class], @selector(hook_textFieldSetAttributedStringValue:));
hookMethod(objc_getClass("MMTextView"), NSSelectorFromString(@"shouldDisableSetFrameOrigin"), [self class], @selector(hook_shouldDisableSetFrameOrigin));
Expand All @@ -47,7 +49,6 @@ + (void)hookTheme
hookMethod(objc_getClass("MMFileListViewController"), @selector(viewDidLoad), [self class], @selector(hook_fileListViewDidLoad));
hookMethod(objc_getClass("MMPreferencesWindowController"), @selector(windowDidLoad), [self class], @selector(hook_preferencesWindowDidLoad));
hookMethod(objc_getClass("MMChatMemberListViewController"), @selector(viewDidLoad), [self class], @selector(hook_memberListViewDidLoad));
hookMethod(objc_getClass("MMChatsTableCellView"), @selector(mouseDown:), [self class], @selector(hook_mouseDown:));
hookMethod(objc_getClass("MMChatDetailSplitView"), @selector(setPreferredDividerColor:), [self class], @selector(hook_setPreferredDividerColor:));
hookMethod(objc_getClass("NSViewController"), @selector(viewDidLoad), [self class], @selector(hook_themeViewDidLoad));
hookMethod(objc_getClass("MMComposeTextView"), @selector(setTextColor:), [self class], @selector(hook_composeSetTextColor:));
Expand Down Expand Up @@ -81,7 +82,6 @@ + (void)hookTheme
hookMethod(objc_getClass("MMContactsDetailViewController"), @selector(sendMsgButton), [self class], @selector(hook_sendMsgButton));

hookMethod(objc_getClass("MMChatsTableCellView"), @selector(drawSelectionBackground), [self class], @selector(hook_drawSelectionBackground));

hookMethod(objc_getClass("MMChatsViewController"), @selector(tableView:viewForTableColumn:row:), [self class], @selector(hook_chatsViewControllerTableView:viewForTableColumn:row:));
hookMethod(objc_getClass("MMMainViewController"), @selector(tabbarController:didSelectViewController:), [self class], @selector(hook_tabbarController:didSelectViewController:));
hookMethod(objc_getClass("MMBrandChatsViewController"), @selector(viewDidLoad), [self class], @selector(hook_brandChatsViewDidLoad));
Expand All @@ -90,13 +90,19 @@ + (void)hookTheme
hookMethod(objc_getClass("MMSystemMessageCellView"), @selector(showsContextMenuButton), [self class], @selector(hook_systemCellViewShowsContextMenuButton));
hookMethod(objc_getClass("MMSystemMessageCellView"), @selector(contextMenuButton), [self class], @selector(hook_systemCellViewContextMenuButton));
hookMethod(objc_getClass("MMChatsTableCellView"), @selector(setSelected:), [self class], @selector(hook_ChatsCellSetSelected:));
hookMethod(objc_getClass("MMChatInfoView"), @selector(updateChatDetailButton), [self class], @selector(hook_updateChatDetailButton));
hookMethod(objc_getClass("MMSessionCreateSessionButtonRowView"), @selector(setHighlighted:), [self class], @selector(hook_creatSessionSetHighlighted:));
}
if ([YMWeChatPluginConfig sharedConfig].fuzzyMode) {
hookMethod(objc_getClass("NSVisualEffectView"), @selector(material), [self class], @selector(hook_getMaterial));
}
#pragma clang diagnostic pop
}
}

- (void)hook_creatSessionSetHighlighted:(BOOL)arg1
{}

- (void)hook_systemCellViewShowsContextMenuButton
{
[self hook_systemCellViewShowsContextMenuButton];
Expand Down Expand Up @@ -449,6 +455,11 @@ - (void)hook_textFieldSetAttributedStringValue:(NSAttributedString *)attributedS
Class cc1Class = NSClassFromString(@"MMContactsColumn1CellView");
Class cmtgClass = NSClassFromString(@"MMContactsMgrTagRowView");
Class cc3Class = NSClassFromString(@"MMContactsColumn3CellView");
Class stcClass = NSClassFromString(@"MMSearchTableCellView");
Class sspClass = NSClassFromString(@"MMSessionPickerListRowView");
Class sspccClass = NSClassFromString(@"MMSessionPickerChoosenCellView");
Class sspcClass = NSClassFromString(@"MMSessionPickerChoosenRowView");
Class cbcClass = NSClassFromString(@"MMChatBaseCellView");

for (int i = 0; i < 5; i++) {
if (sv == nil) {
Expand All @@ -463,6 +474,11 @@ - (void)hook_textFieldSetAttributedStringValue:(NSAttributedString *)attributedS
|| [sv isKindOfClass:cc1Class]
|| [sv isKindOfClass:cmtgClass]
|| [sv isKindOfClass:cc3Class]
|| [sv isKindOfClass:stcClass]
|| [sv isKindOfClass:sspClass]
|| [sv isKindOfClass:sspcClass]
|| [sv isKindOfClass:sspccClass]
|| [sv isKindOfClass:cbcClass]
) {
[a addAttributes:@{
NSForegroundColorAttributeName: kMainTextColor
Expand Down Expand Up @@ -533,11 +549,6 @@ - (void)hook_updateChatName
{
[self hook_updateChatName];
MMChatInfoView *infoView = (MMChatInfoView *)self;
if ([YMWeChatPluginConfig sharedConfig].usingDarkTheme) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
infoView.chatDetailButton.image = kImageWithName(@"barbuttonicon_more_white.png");
});
}
@try {
NSTextFieldCell *cell = [infoView.chatNameLabel valueForKey:@"cell"];
NSAttributedString *originalText = [cell valueForKey:@"contents"];
Expand All @@ -548,6 +559,16 @@ - (void)hook_updateChatName
};
}

- (void)hook_updateChatDetailButton
{
dispatch_async(dispatch_get_main_queue(), ^{
MMChatInfoView *infoView = (MMChatInfoView *)self;
if ([YMWeChatPluginConfig sharedConfig].usingDarkTheme) {
infoView.chatDetailButton.image = kImageWithName(@"barbuttonicon_more_white.png");
}
});
}

- (id)hook_chatInfoViewInitWithFrame:(id)arg1
{
MMChatInfoView *infoView = [self hook_chatInfoViewInitWithFrame:arg1];
Expand Down Expand Up @@ -705,15 +726,6 @@ - (void)hook_updateNickName
}
}

- (void)hook_mouseDown:(id)arg1
{
[self hook_mouseDown:arg1];

if ([YMWeChatPluginConfig sharedConfig].usingDarkTheme) {
MMChatsTableCellView *cell = (MMChatsTableCellView *)self;
}
}

- (void)hook_setAttributedStringValue:(NSAttributedString *)arg1
{
struct mach_header *mh_addr = _dyld_get_image_header(0);
Expand Down Expand Up @@ -800,6 +812,9 @@ - (void)hook_ComposeInputViewControllerViewDidLoad
controller.attachmentButton.normalColor = normalColor;
controller.stickerButton.normalColor = normalColor;
controller.multiTalkButton.normalColor = normalColor;
if (LargerOrEqualVersion(@"2.6.0")) {
controller.liveButton.imageColor = normalColor;
}
}
}
}
Expand Down Expand Up @@ -828,6 +843,10 @@ - (void)hook_addSubView:(NSView *)view
return;
}

if ([view isKindOfClass:[objc_getClass("_NSImageViewSimpleImageView") class]]) {
return;
}

if ([self isKindOfClass:[objc_getClass("MMAppReferContainerView") class]]) {
return;
}
Expand Down Expand Up @@ -922,6 +941,24 @@ - (void)addSubViewDealView:(NSView *)view
return;
}

if ([view isKindOfClass:[objc_getClass("MMSessionCreateSessionButtonRowView") class]]) {
MMSessionCreateSessionButtonRowView *rowView = (MMSessionCreateSessionButtonRowView *)view;
[[YMThemeManager shareInstance] changeTheme:rowView.backgroundView];
rowView.backgroundView.layer.cornerRadius = 5;
rowView.backgroundView.layer.borderColor = YM_RGBA(240, 240, 240, 0.2).CGColor;
rowView.backgroundView.layer.borderWidth = 1;
return;
}

if ([view isKindOfClass:[objc_getClass("MMSessionPickerListSwitchSelectMode") class]]) {
for (NSView *sub in view.subviews) {
if (![sub isKindOfClass:[NSTextField class]] && ![sub isKindOfClass:objc_getClass("MMButton")]) {
[[YMThemeManager shareInstance] changeTheme:sub];
}
}
return;
}

if ([view isKindOfClass:[objc_getClass("MMSessionPickerListGroupRowView") class]]) {
for (NSView *sub in view.subviews) {
if (![sub isKindOfClass:[NSTextField class]]) {
Expand Down Expand Up @@ -1056,7 +1093,6 @@ - (void)addSubViewDealControllerWithView:(NSView *)view
return;
}


NSViewController *controller = [self findResponderController:view];
if ([controller isKindOfClass:[objc_getClass("MMChatMessageViewController") class]]) {
MMChatMessageViewController *msgViewController = (MMChatMessageViewController *)controller;
Expand Down Expand Up @@ -1113,6 +1149,10 @@ - (void)addSubViewDealControllerWithView:(NSView *)view
[[YMThemeManager shareInstance] changeTheme:view];
return;
}
if ([controller isKindOfClass:[objc_getClass("MMSessionChoosenView") class]]) {
[[YMThemeManager shareInstance] changeTheme:controller.view];
return;
}
}

#pragma mark - viewDidLoad
Expand Down Expand Up @@ -1180,14 +1220,14 @@ - (void)hook_windowDidLoad
return;
}

// if ([self isKindOfClass:objc_getClass("MMGlobalChatManagerWindowController")]) {
// MMGlobalChatManagerWindowController *window = (MMGlobalChatManagerWindowController *)self;
// for (NSView *sub in window.window.contentView.subviews) {
// if (![sub isKindOfClass:objc_getClass("MMCustomSearchField")]) {
// [[YMThemeManager shareInstance] changeTheme:sub];
// }
// }
// }
if ([self isKindOfClass:objc_getClass("MMGlobalChatManagerWindowController")]) {
MMGlobalChatManagerWindowController *window = (MMGlobalChatManagerWindowController *)self;
for (NSView *sub in window.window.contentView.subviews) {
if (![sub isKindOfClass:objc_getClass("MMCustomSearchField")]) {
[[YMThemeManager shareInstance] changeTheme:sub];
}
}
}

[YMFuzzyManager fuzzyWindowViewController:(NSWindowController *)self];
}
Expand Down
51 changes: 28 additions & 23 deletions WeChatExtension/WeChatExtension/Sources/Hook/WeChat+hook.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ + (void)hookWeChat
{
//微信撤回消息
if (LargerOrEqualVersion(@"2.3.29")) {
hookMethod(objc_getClass("AddMsgSyncCmdHandler"), @selector(handleSyncCmdId: withSyncCmdItems:onComplete:), [self class], @selector(hook_handleSyncCmdId: withSyncCmdItems:onComplete:));
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
hookMethod(objc_getClass("AddMsgSyncCmdHandler"), @selector(handleSyncCmdId: withSyncCmdItems:onComplete:), [self class], @selector(hook_handleSyncCmdId: withSyncCmdItems:onComplete:));
#pragma clang diagnostic pop
hookMethod(objc_getClass("MessageService"), @selector(FFToNameFavChatZZ:sessionMsgList:), [self class], @selector(hook_FFToNameFavChatZZ:sessionMsgList:));

} else {
Expand Down Expand Up @@ -105,8 +108,10 @@ + (void)hookWeChat

hookMethod(objc_getClass("MMMainViewController"), @selector(onUpdateHandoffExpt:), [self class], @selector(hook_onUpdateHandoffExpt:));


#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
hookClassMethod(objc_getClass("MMCGIRequester"), @selector(requestCGI: Body:Response:), [self class], @selector(hook_requestCGI: Body:Response:));
#pragma clang diagnostic pop
//替换沙盒路径
rebind_symbols((struct rebinding[2]) {
{ "NSSearchPathForDirectoriesInDomains", swizzled_NSSearchPathForDirectoriesInDomains, (void *)&original_NSSearchPathForDirectoriesInDomains },
Expand Down Expand Up @@ -231,24 +236,24 @@ - (void)hook_originalImageDidLoadWithUniqueID:(id)arg1 image:(id)arg2; {


#pragma mark - 撤回
- (void)hook_handleSyncCmdId:(id)arg1 withSyncCmdItems:(id)arg2 onComplete:(id)arg3
{
NSArray <CmdItem *>*p_arg2 = (NSArray *)arg2;
__weak __typeof (self) wself = self;
[p_arg2 enumerateObjectsUsingBlock:^(CmdItem * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) {
AddMsg *addMsg = [objc_getClass("AddMsg") parseFromData:item.cmdBuf.buffer];
NSString *msg = addMsg.content.string;
if ([msg rangeOfString:@"<sysmsg"].length <= 0) {
if ([msg containsString:@"开始聊天了"]) {
return;
}
[wself hook_handleSyncCmdId:arg1 withSyncCmdItems:arg2 onComplete:arg3];
return;
}
//- (void)hook_handleSyncCmdId:(id)arg1 withSyncCmdItems:(id)arg2 onComplete:(id)arg3
//{
// NSArray <CmdItem *>*p_arg2 = (NSArray *)arg2;
// __weak __typeof (self) wself = self;
// [p_arg2 enumerateObjectsUsingBlock:^(CmdItem * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) {
// AddMsg *addMsg = [objc_getClass("AddMsg") parseFromData:item.cmdBuf.buffer];
// NSString *msg = addMsg.content.string;
// if ([msg rangeOfString:@"<sysmsg"].length <= 0) {
// if ([msg containsString:@"开始聊天了"]) {
// return;
// }
// [wself hook_handleSyncCmdId:arg1 withSyncCmdItems:arg2 onComplete:arg3];
// return;
// }
//备用撤回
// [wself _doParseRevokeMsg:msg msgData:nil arg1:arg1 arg2:arg2 arg3:arg3];
}];
}
// }];
//}

- (void)hook_FFToNameFavChatZZ:(id)msgData sessionMsgList:(id)arg2
{
Expand Down Expand Up @@ -346,13 +351,13 @@ - (void)hook_receivedMsg:(NSArray *)msgs isFirstSync:(BOOL)arg2
__block BOOL flag = NO;
[msgs enumerateObjectsUsingBlock:^(AddMsg *addMsg, NSUInteger idx, BOOL * _Nonnull stop1) {

if ([addMsg.content.string containsString:@"可以开始聊天了"]) {
ContactStorage *contactStorage = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("ContactStorage")];
BOOL isFriend = [contactStorage IsFriendContact:addMsg.fromUserName.string];
// if ([addMsg.content.string containsString:@"可以开始聊天了"]) {
// ContactStorage *contactStorage = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("ContactStorage")];
// BOOL isFriend = [contactStorage IsFriendContact:addMsg.fromUserName.string];
// if (isFriend) {
return;
// return;
// }
}
// }

//群管理中阻止群消息
[[YMWeChatPluginConfig sharedConfig].banModels enumerateObjectsUsingBlock:^(YMZGMPBanModel *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"assistant.menu.freeLogin" = "Free-Login";
"assistant.menu.systemBrowser" = "System Browser";
"assistant.menu.forbidCheck" = "Forbid Update";
"assistant.menu.other" = "Wechat Assistant🌚";
"assistant.menu.other" = "Wechat Assistant🇨🇳";
"assistant.menu.enableAlfred" = "Enable Alfred";
"assistant.menu.updateAssistant" = "Update Wechat Assistant…";
"assistant.menu.aboutAssistant" = "About Wechat Assistant";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"assistant.menu.freeLogin" = "Free-Login";
"assistant.menu.systemBrowser" = "System Browser";
"assistant.menu.forbidCheck" = "Forbid Update";
"assistant.menu.other" = "Wechat Assistant🌚";
"assistant.menu.other" = "Wechat Assistant🇨🇳";
"assistant.menu.enableAlfred" = "Enable Alfred";
"assistant.menu.updateAssistant" = "Update Wechat Assistant…";
"assistant.menu.aboutAssistant" = "About And Contribute";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"assistant.menu.freeLogin" = "免认证登录";
"assistant.menu.systemBrowser" = "使用系统浏览器";
"assistant.menu.forbidCheck" = "禁止更新";
"assistant.menu.other" = "小助手🌚";
"assistant.menu.other" = "小助手🇨🇳";
"assistant.menu.enableAlfred" = "开启 Alfred 功能";
"assistant.menu.updateAssistant" = "更新小助手…";
"assistant.menu.aboutAssistant" = "关于与捐赠";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"assistant.menu.freeLogin" = "免认证登录";
"assistant.menu.systemBrowser" = "使用系统浏览器";
"assistant.menu.forbidCheck" = "禁止更新";
"assistant.menu.other" = "小助手🌚";
"assistant.menu.other" = "小助手🇨🇳";
"assistant.menu.enableAlfred" = "开启 Alfred 功能";
"assistant.menu.updateAssistant" = "更新小助手…";
"assistant.menu.aboutAssistant" = "关于与捐赠";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ + (void)fuzzyWindowViewController:(NSWindowController *)window
[effView fillSuperView];
}
}

[[YMThemeManager shareInstance] changeTheme:window.window.contentView];

do {
[[YMThemeManager shareInstance] changeTheme:window.window.contentView color:kMainBackgroundColor];
[window.window setBackgroundColor:kMainBackgroundColor];
NSLog(@"yanmao - %@",window);
} while (CGRectEqualToRect(window.window.contentView.frame, CGRectZero));
}

+ (void)fuzzyViewController:(NSViewController *)viewController
Expand All @@ -74,7 +78,8 @@ + (void)fuzzyViewController:(NSViewController *)viewController
|| [viewController isKindOfClass:objc_getClass("MMContactsListViewController")]
|| [viewController isKindOfClass:objc_getClass("MMContactsLeftMasterViewController")]
|| [viewController isKindOfClass:objc_getClass("MMContactsRightDetailViewController")]
|| [viewController isKindOfClass:objc_getClass("MMChatMessageViewController")] ) {
|| [viewController isKindOfClass:objc_getClass("MMChatMessageViewController")]
|| [viewController isKindOfClass:objc_getClass("MMSessionChoosenView")]) {
NSVisualEffectView *effView = [YMThemeManager creatFuzzyEffectView];
if (viewController.view.subviews.count > 0) {
NSView *firstSubView = viewController.view.subviews[0];
Expand Down
Loading

0 comments on commit 1699adc

Please sign in to comment.