File size: 2,875 Bytes
b9d5d87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import sys
import re

def patch_opela_client_for_hf(hf_space_domain, source_dir=r"C:\Users\salah\Downloads\angolax86"):
    print("=" * 65)
    print(" Opela Free Fire Client Patching Tool (Hugging Face Edition) ")
    print("=" * 65)
    print(f"Hugging Face Space Domain: {hf_space_domain}")
    print(f"Client Source Path: {source_dir}\n")

    # Clean domain input (e.g. remove https:// or trailing slashes)
    hf_domain = hf_space_domain.replace("https://", "").replace("http://", "").strip("/")

    if not os.path.exists(source_dir):
        print(f"[ERROR] Source directory '{source_dir}' does not exist!")
        return False

    target_bytes = hf_domain.encode('ascii')

    files_to_check = [
        os.path.join(source_dir, "lib", "x86", "libmadoka.so"),
        os.path.join(source_dir, "assets", "google-services.json"),
        os.path.join(source_dir, "assets", "google-services-desktop.json"),
        os.path.join(source_dir, "assets", "bin", "Data", "Managed", "Metadata", "global-metadata.dat")
    ]

    modified_count = 0

    for fpath in files_to_check:
        if os.path.exists(fpath):
            try:
                with open(fpath, "rb") as f:
                    content = f.read()

                # Match raw IPs or domains to replace
                ip_domain_pattern = re.compile(rb'\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b|https?://[a-zA-Z0-9\.\-_:]+')
                matches = list(ip_domain_pattern.finditer(content))

                if matches:
                    new_content = content
                    for m in matches:
                        old_bytes = m.group(0)
                        if len(target_bytes) <= len(old_bytes):
                            padded = target_bytes + b'\x00' * (len(old_bytes) - len(target_bytes))
                            new_content = new_content.replace(old_bytes, padded)
                        else:
                            new_content = new_content.replace(old_bytes, target_bytes)

                    with open(fpath, "wb") as f:
                        f.write(new_content)
                    
                    modified_count += 1
                    print(f"[PATCHED] {os.path.basename(fpath)}: Updated endpoints to '{hf_domain}'")

            except Exception as e:
                print(f"[WARNING] Could not patch {os.path.basename(fpath)}: {e}")

    print("\n" + "=" * 65)
    print(f" SUCCESS: Client configured for Hugging Face Space: '{hf_domain}'")
    print(f" Total files modified: {modified_count}")
    print("=" * 65)
    return True

if __name__ == "__main__":
    if len(sys.argv) > 1:
        domain = sys.argv[1]
    else:
        domain = input("Enter your Hugging Face Space Domain (e.g. username-angola-me.hf.space): ").strip()
    
    if domain:
        patch_opela_client_for_hf(domain)
    else:
        print("[ERROR] No domain provided.")