Skip to content

Commit d513194

Browse files
committed
fix: confirm story like on newer Instagram versions
1 parent d77216d commit d513194

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/Features/Confirm/LikeConfirm.x

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,39 @@
107107
- (void)inputView:(id)arg1 didTapLikeButton:(id)arg2 {
108108
CONFIRMPOSTLIKE(%orig);
109109
}
110+
111+
// For some stupid reason they removed the "liketapped" methods on newer Instagram versions
112+
// Now we have to do a shitty workaround instead :(
113+
// Works 99% of the time, but sometimes clicks get through directly to the like button (somehow)
114+
- (void)layoutSubviews {
115+
%orig;
116+
117+
if (![SCIUtils getBoolPref:@"like_confirm"]) return;
118+
119+
UIButton *likeButton = [self valueForKey:@"likeButton"];
120+
if (!likeButton) return;
121+
122+
// 129115 = L(12) I(9) K(11) E(5)
123+
static NSInteger kOverlayTag = 129115;
124+
if ([likeButton viewWithTag:kOverlayTag]) return;
125+
126+
UIButton *overlay = [UIButton buttonWithType:UIButtonTypeCustom];
127+
overlay.tag = kOverlayTag;
128+
overlay.frame = likeButton.bounds;
129+
overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
130+
[overlay addTarget:self action:@selector(overlayTapped:) forControlEvents:UIControlEventTouchUpInside];
131+
[likeButton addSubview:overlay];
132+
}
133+
134+
%new - (void)overlayTapped:(UIButton *)overlay {
135+
UIButton *likeButton = (UIButton *)overlay.superview;
136+
137+
[SCIUtils showConfirmation:^{
138+
dispatch_async(dispatch_get_main_queue(), ^{
139+
[likeButton sendActionsForControlEvents:UIControlEventTouchUpInside];
140+
});
141+
}];
142+
}
110143
%end
111144

112145
// DM like button (seems to be hidden)

0 commit comments

Comments
 (0)