Skip to content

Commit

Permalink
feat: update hide meta ai functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
SoCuul committed Sep 27, 2024
1 parent f014f3a commit 066c63f
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 187 deletions.
228 changes: 41 additions & 187 deletions src/Features/General/HideMetaAI.xm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// Meta AI button functionality on direct search bar
%hook IGDirectInboxViewController
- (void)searchBarMetaAIButtonTappedOnSearchBar:(id)arg1 {
if ([SCIManager getPref:@"hide_meta_ai"]) {
if ([SCIManager getPref:@"hide_meta_ai"])
{
NSLog(@"[SCInsta] Hiding meta ai: direct search bar functionality");

return;
Expand All @@ -19,7 +20,8 @@
// AI agents in direct new message view
%hook IGDirectRecipientGenAIBotsResult
- (id)initWithGenAIBots:(id)arg1 lastFetchedTimestamp:(id)arg2 {
if ([SCIManager getPref:@"hide_meta_ai"]) {
if ([SCIManager getPref:@"hide_meta_ai"])
{
NSLog(@"[SCInsta] Hiding meta ai: direct recipient ai agents");

return nil;
Expand All @@ -35,21 +37,21 @@
NSMutableArray *newObjs = [%orig mutableCopy];

[newObjs enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([SCIManager getPref:@"hide_meta_ai"]) {

if ([obj isKindOfClass:%c(IGDirectRecipientCellViewModel)]) {
if ([obj isKindOfClass:%c(IGDirectRecipientCellViewModel)]) {

// Meta AI suggested user
if ([[[obj recipient] threadName] isEqualToString:@"Meta AI"]) {
if ([SCIManager getPref:@"hide_meta_ai"]) {
// Meta AI suggested user
if ([[[obj recipient] threadName] isEqualToString:@"Meta AI"]) {
NSLog(@"[SCInsta] Hiding meta ai: explore search results ai suggestion");

[newObjs removeObjectAtIndex:idx];

}

}

}

}

}];

return [newObjs copy];
Expand All @@ -75,8 +77,7 @@
tag:(NSInteger)arg2
uniqueIdentifier:(id)arg3
configuration:(id)arg4
accessibilityTraits:(NSUInteger)arg5
{
accessibilityTraits:(NSUInteger)arg5 {
self = %orig;

if ([[self labelTitle] isEqualToString:@"Ask Meta AI"]) {
Expand Down Expand Up @@ -106,55 +107,38 @@
}
%end

// Meta AI search bar: opening meta ai chat on return key
%hook IGDirectInboxSearchController
- (void)_presentMetaAiWithPrompt:(id)arg1 presentationCompletion:(id)arg2 entryPoint:(NSInteger)arg3 {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: present meta ai thread from direct search");

return;
}

return %orig;
}
%end

// Meta AI in message composer
%hook IGDirectCommandSystemListViewController
- (id)objectsForListAdapter:(id)arg1 {
NSMutableArray *newObjs = [%orig mutableCopy];

[newObjs enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([SCIManager getPref:@"hide_meta_ai"]) {

if ([obj isKindOfClass:%c(IGDirectCommandSystemViewModel)]) {
if ([obj isKindOfClass:%c(IGDirectCommandSystemViewModel)]) {

IGDirectCommandSystemViewModel *typedObj = (IGDirectCommandSystemViewModel *)obj;
IGDirectCommandSystemRow *cmdSystemRow = (IGDirectCommandSystemRow *)[typedObj row];
IGDirectCommandSystemViewModel *typedObj = (IGDirectCommandSystemViewModel *)obj;
IGDirectCommandSystemRow *cmdSystemRow = (IGDirectCommandSystemRow *)[typedObj row];

IGDirectCommandSystemResult *_commandResult_command = MSHookIvar<IGDirectCommandSystemResult *>(cmdSystemRow, "_commandResult_command");
IGDirectCommandSystemResult *_commandResult_command = MSHookIvar<IGDirectCommandSystemResult *>(cmdSystemRow, "_commandResult_command");

// Meta AI
if ([[_commandResult_command title] isEqualToString:@"Meta AI"]) {
if ([SCIManager getPref:@"hide_meta_ai"]) {
// Meta AI
if ([[_commandResult_command title] isEqualToString:@"Meta AI"]) {
NSLog(@"[SCInsta] Hiding meta ai: direct message composer suggestion");

[newObjs removeObjectAtIndex:idx];
}

}

// Meta AI (Imagine)
if ([[_commandResult_command commandString] isEqualToString:@"/imagine"]) {
if ([SCIManager getPref:@"hide_meta_ai"]) {
// Meta AI (Imagine)
else if ([[_commandResult_command commandString] isEqualToString:@"/imagine"]) {
NSLog(@"[SCInsta] Hiding meta ai: direct message composer /imagine suggestion");

[newObjs removeObjectAtIndex:idx];
}

}

}

}

}];

return [newObjs copy];
Expand All @@ -165,153 +149,46 @@

// Explore

// Meta AI search bar: explore/user search results data
%hook IGSearchListKitDataSource
- (id)objectsForListAdapter:(id)arg1 {
NSMutableArray *newObjs = [%orig mutableCopy];

[newObjs enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

// Section header
if ([obj isKindOfClass:%c(IGLabelItemViewModel)]) {

// "Ask Meta AI" search results header
if ([[obj labelTitle] isEqualToString:@"Ask Meta AI"]) {

if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: explore search results header");

[newObjs removeObjectAtIndex:idx];
}

}

}

// Meta AI suggested search results
if ([obj isKindOfClass:%c(IGSearchResultViewModel)]) {

// itemType 6 is meta ai suggestions
if ([obj itemType] == 6) {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: explore search results ai suggestion");

[newObjs removeObjectAtIndex:idx];
}

}

// Meta AI user account in search results
else if ([[[obj title] string] isEqualToString:@"meta.ai"]) {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: explore search results meta ai user account suggestion");

[newObjs removeObjectAtIndex:idx];
}
}

}

}];
// Meta AI search bar ring button
%hook IGSearchBarDonutButton
- (void)didMoveToWindow {
%orig;

return [newObjs copy];
}
%end
// Meta AI explore suggested topics clouds
%hook IGSearchResultCloudSectionController
- (id)initWithUserSession:(id)arg1 analyticsModule:(id)arg2 loggingProvider:(id)arg3 {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: explore suggested topics clouds");

return nil;
[self removeFromSuperview];
}

return %orig;
}
%end

/////////////////////////////////////////////////////////////////////////////
/* %hook IGGrowingTextView
// Search / Buttons
%end */

// In-app search bars
%hook IGSearchBar
- (void)didMoveToWindow {
- (void)_setupTextView {
%orig;

if ([SCIManager getPref:@"hide_meta_ai"]) {

// Right meta ai button (in direct search)
UIView *_secondaryRightButton = MSHookIvar<UIView *>(self, "_secondaryRightButton");
if (_secondaryRightButton) {
NSLog(@"[SCInsta] Hiding meta ai: secondary right search bar icon");

[_secondaryRightButton removeFromSuperview];
}

}
}

- (void)_didTapDirectSendButton {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: tap on direct send button");

return;
}
IGGrowingTextView *_textView = MSHookIvar<IGGrowingTextView *>(self, "_textView");

return %orig;
}

- (void)_didTapMetaAIButton {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: tap on meta ai button");

return;
}

return %orig;
}

// This removes the padding added to the placeholder text, for the meta ai button
- (CGFloat)_getTextFieldOrginXForSearchBarWithLeftIcon {
if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: search bar padding for meta ai button");

// 43 (orig width) - 22 (meta ai button width) = 21
return 21;
}

return %orig;
}
%end

// Search bar donut button
%hook IGSearchBarDonutButton
- (void)didMoveToWindow {
%orig;

if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: search bar donut button");

[self removeFromSuperview];
// Get rid of meta ai search text
if ([[_textView placeholderText] containsString:@"Meta AI"]) {
[_textView setPlaceholderText:@"Search"];
}
}
}
%end

// Search typeahead
%hook IGSearchTypeaheadViewController
- (void)_presentMetaAIThreadWithDirectEntryPoint:(NSInteger)arg1 searchEntryPoint:(NSInteger)arg2 prompt:(id)arg3 {
%hook IGAnimatablePlaceholderTextFieldContainer
- (id)initWithConfig:(id)arg1 {
NSLog(@"[SCInsta Test] %@", arg1);

if ([SCIManager getPref:@"hide_meta_ai"]) {
NSLog(@"[SCInsta] Hiding meta ai: present meta ai thread from search");

return;
}

return %orig;
}
%end

/////////////////////////////////////////////////////////////////////////////

// Themed in-app buttons
%hook IGTapButton
- (void)didMoveToWindow {
Expand All @@ -328,27 +205,4 @@

}
}
%end

// Animated spinning icon
%hook IGKeyframeAnimationViewController
- (id)initWithUserSession:(id)arg1 assetURL:(id)assetURL cacheKey:(id)arg3 {
if ([SCIManager getPref:@"hide_meta_ai"]) {

if ([[assetURL absoluteString] isEqualToString:@"https://lookaside.facebook.com/ras/v2/?id=AQABh50YCM9z"]) {
NSLog(@"[SCInsta] Hiding meta ai: animated spining icon");

return nil;
}

else if ([[assetURL absoluteString] isEqualToString:@"https://lookaside.facebook.com/ras/v2/?id=AQAGo_cgnUHA"]) {
NSLog(@"[SCInsta] Hiding meta ai: animated spinning icon");

return nil;
}

}

return %orig;
}
%end
6 changes: 6 additions & 0 deletions src/InstagramHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@
- (id)commandString;
@end

@interface IGGrowingTextView : UIView
- (id)placeholderText;
- (void)setPlaceholderText:(id)arg1;
@end
@end



/////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 066c63f

Please sign in to comment.