From 7f30e66c0c896dadbaa71fd79817eb191776917b Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Sun, 24 Jul 2022 15:24:15 +0300 Subject: [PATCH] new profile buttons injector --- .../ru/vtosters/lite/hooks/JsonInjectors.java | 109 ++++++++++++++++-- .../java/ru/vtosters/lite/utils/Globals.java | 5 +- .../lite/api/ExtendedUserProfile$d.smali | 4 - .../lite/api/execute/GetFullProfile.smali | 4 + 4 files changed, 106 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/ru/vtosters/lite/hooks/JsonInjectors.java b/app/src/main/java/ru/vtosters/lite/hooks/JsonInjectors.java index f9c3eed18..9416a90f0 100644 --- a/app/src/main/java/ru/vtosters/lite/hooks/JsonInjectors.java +++ b/app/src/main/java/ru/vtosters/lite/hooks/JsonInjectors.java @@ -24,10 +24,14 @@ import static ru.vtosters.lite.utils.Preferences.getBoolValue; import static ru.vtosters.lite.utils.Preferences.hasVerification; import static ru.vtosters.lite.utils.Preferences.postsrecomm; +import android.net.Uri; import android.util.Log; import com.vk.core.network.Network; import com.vk.core.util.DeviceIdProvider; +import com.vk.core.util.LangUtils; +import com.vk.core.util.UriExt; +import com.vk.webapp.VkUiFragment; import org.json.JSONArray; import org.json.JSONException; @@ -48,22 +52,105 @@ public class JsonInjectors{ private static final OkHttpClient mClient = new OkHttpClient(); public static JSONObject profileButton(JSONObject orig) throws JSONException{ - if (haveDonateButton()) return orig; + var id = orig.getInt("id"); - var pic = "https://sun1-18.userapi.com/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ/5R-DEF37PFs.png"; + var newItem = new JSONArray(); + + if (orig.has("buttons")) { + newItem = orig.getJSONArray("buttons"); + } + + if (!haveDonateButton() && id == getUserId()) { + newItem.put(donateRecomm()); + } + + newItem.put(vktesters(id)); + + orig.put("buttons", newItem); + + return orig; + } + + public static JSONObject donateRecomm() throws JSONException{ var title = "Помоги проекту донатом и получи бонус!"; var link = "https://vk.com/vtosters_official"; var text_color = "2D81E0"; - // JSONObject jsonObj = new JSONObject("{\"action\":{\"target\":\"internal\",\"type\":\"open_url\",\"url\":\"" + link + "\"},\"title\":\"" + title + "\",\"icons\":[{\"url\":\"" + pic + "\",\"width\":20,\"height\":20},{\"url\":\"" + pic + "\",\"width\":40,\"height\":40},{\"url\":\"" + pic + "\",\"width\":60,\"height\":60},{\"url\":\"" + pic + "\",\"width\":80,\"height\":80}],\"text_color\":\"" + text_color + "\"}"); - return new JSONObject(decode("eyJhY3Rpb24iOnsidGFyZ2V0IjoiaW50ZXJuYWwiLCJ0eXBlIjoib3Blbl91cmwiLCJ1cmwiOiI=") - + link + decode("In0sInRpdGxlIjoi") - + title + decode("IiwiaWNvbnMiOlt7InVybCI6Ig==") - + pic + decode("Iiwid2lkdGgiOjIwLCJoZWlnaHQiOjIwfSx7InVybCI6Ig==") - + pic + decode("Iiwid2lkdGgiOjQwLCJoZWlnaHQiOjQwfSx7InVybCI6Ig==") - + pic + decode("Iiwid2lkdGgiOjYwLCJoZWlnaHQiOjYwfSx7InVybCI6Ig==") - + pic + decode("Iiwid2lkdGgiOjgwLCJoZWlnaHQiOjgwfV0sInRleHRfY29sb3IiOiI=") - + text_color + decode("In0=")); + var json = new JSONObject(); + var icons = new JSONArray(); + + var action = new JSONObject(); + action.put("target", "internal"); + action.put("type", "open_url"); // may be open_url, open_internal_vkui, open_game, help_hint, show_full_post, open_vkapp, show_recommendations_for_post and groups_advertisement + action.put("url", link); + json.put("action", action); + + json.put("title", title); + + var icon1 = new JSONObject(); + icon1.put("url", "https://sun2-10.userapi.com/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ/5R-DEF37PFs.png"); + icon1.put("width", "20"); + icon1.put("height", "20"); + icons.put(icon1); + + var icon2 = new JSONObject(); + icon2.put("url", "https://sun2-12.userapi.com/N8y9pU1meJq_eug-wB1u-HUuGyMqDfdq7A025w/A4Aio-xuLY8.png"); + icon2.put("width", "40"); + icon2.put("height", "40"); + icons.put(icon2); + + var icon3 = new JSONObject(); + icon3.put("url", "https://sun2-9.userapi.com/3Hx4hff63_2Lt6wjjthJMF_3QLUswNNlQKoAXQ/oyzEu1NL9T8.png"); + icon3.put("width", "80"); + icon3.put("height", "80"); + icons.put(icon3); + + json.put("icons", icons); + + json.put("text_color", text_color); + + return json; + } + + public static JSONObject vktesters(int id) throws JSONException{ + var title = "Профиль VK Testers"; + var text_color = "2D81E0"; + var link = "https://static.vk.com/bugs?lang=" + LangUtils.a() + "#/reporter" + id; + + var json = new JSONObject(); + var icons = new JSONArray(); + + var action = new JSONObject(); + action.put("target", "internal"); + action.put("type", "open_internal_vkui"); + action.put("url", link); + json.put("action", action); + + json.put("title", title); + + var icon1 = new JSONObject(); + icon1.put("url", "https://sun2-10.userapi.com/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ/5R-DEF37PFs.png"); + icon1.put("width", "20"); + icon1.put("height", "20"); + icons.put(icon1); + + var icon2 = new JSONObject(); + icon2.put("url", "https://sun2-12.userapi.com/N8y9pU1meJq_eug-wB1u-HUuGyMqDfdq7A025w/A4Aio-xuLY8.png"); + icon2.put("width", "40"); + icon2.put("height", "40"); + icons.put(icon2); + + var icon3 = new JSONObject(); + icon3.put("url", "https://sun2-9.userapi.com/3Hx4hff63_2Lt6wjjthJMF_3QLUswNNlQKoAXQ/oyzEu1NL9T8.png"); + icon3.put("width", "80"); + icon3.put("height", "80"); + icons.put(icon3); + + json.put("icons", icons); + + json.put("text_color", text_color); + + return json; } public static JSONObject convBar(JSONObject orig) throws JSONException{ diff --git a/app/src/main/java/ru/vtosters/lite/utils/Globals.java b/app/src/main/java/ru/vtosters/lite/utils/Globals.java index 50de4b1f8..44546506b 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Globals.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Globals.java @@ -41,7 +41,6 @@ import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.annotation.RequiresApi; import androidx.annotation.StringRes; import com.vk.dto.user.UserProfile; @@ -132,6 +131,10 @@ public class Globals{ return VKAccountManager.d().D0(); } // Current UserId + public static boolean isVKTester(){ + return VKAccountManager.d().i(); + } // is vk tester + public static String getUserSecret(){ return VKAccountManager.d().l0(); } diff --git a/smali/smali_classes4/com/vtosters/lite/api/ExtendedUserProfile$d.smali b/smali/smali_classes4/com/vtosters/lite/api/ExtendedUserProfile$d.smali index e84086259..4d42508f4 100644 --- a/smali/smali_classes4/com/vtosters/lite/api/ExtendedUserProfile$d.smali +++ b/smali/smali_classes4/com/vtosters/lite/api/ExtendedUserProfile$d.smali @@ -39,10 +39,6 @@ .method public static a(Lorg/json/JSONObject;)Lcom/vtosters/lite/api/ExtendedUserProfile$d; .locals 3 - invoke-static {p0}, Lru/vtosters/lite/hooks/JsonInjectors;->profileButton(Lorg/json/JSONObject;)Lorg/json/JSONObject; - - move-result-object p0 - .line 1 new-instance v0, Lcom/vtosters/lite/api/ExtendedUserProfile$d; diff --git a/smali/smali_classes4/com/vtosters/lite/api/execute/GetFullProfile.smali b/smali/smali_classes4/com/vtosters/lite/api/execute/GetFullProfile.smali index 455e38f90..db305b199 100644 --- a/smali/smali_classes4/com/vtosters/lite/api/execute/GetFullProfile.smali +++ b/smali/smali_classes4/com/vtosters/lite/api/execute/GetFullProfile.smali @@ -1513,6 +1513,10 @@ iput-object v0, v15, Lcom/vtosters/lite/api/ExtendedUserProfile;->l1:Ljava/util/ArrayList; :cond_22 + invoke-static {v14}, Lru/vtosters/lite/hooks/JsonInjectors;->profileButton(Lorg/json/JSONObject;)Lorg/json/JSONObject; + + move-result-object v14 + const-string v0, "buttons" .line 122