forked from jean-voila/FeurStagram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply_tab_redirection.py
More file actions
42 lines (34 loc) · 1.18 KB
/
apply_tab_redirection.py
File metadata and controls
42 lines (34 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
import os
def patch_smali(file_path):
with open(file_path, 'r') as f:
content = f.read()
old_marker = 'check-cast v7, Ljava/lang/String;'
if old_marker not in content:
print(f"Could not find {old_marker} in {file_path}")
return
# Redirection logic:
# if (v7.equals("fragment_clips")) { v7 = "fragment_direct_tab"; }
# In smali:
# if-eqz v0, :not_reels # if v0 is zero (NOT equals), skip to :not_reels
patch = '''
# InstaFree: Redirect Reels to DMs
const-string/jumbo v0, "fragment_clips"
invoke-virtual {v7, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :not_reels
const-string/jumbo v7, "fragment_direct_tab"
:not_reels
'''
# We need to make sure we dont double patch if we run multiple times
if '# InstaFree' in content:
print(f"Already patched {file_path}")
return
new_content = content.replace(old_marker, old_marker + patch)
with open(file_path, 'w') as f:
f.write(new_content)
print(f"Successfully patched {file_path}")
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit(1)
patch_smali(sys.argv[1])