feat: Spoof Snap Score

This commit is contained in:
RSR/
2026-03-11 19:47:13 +04:00
parent 181d19424f
commit 6948d86efc
6 changed files with 90 additions and 0 deletions

View File

@@ -1155,6 +1155,16 @@
"settings_menu": {
"name": "قائمة الإعدادات",
"description": "اختر بين تخطيطات قائمة الإعدادات الجديدة والقديمة"
},
"spoof_snap_score": {
"name": "تزييف نقاط سناب شات",
"description": "تزييف نقاط السناب شات الخاصة بك (محلياً فقط)",
"properties": {
"custom_snap_score": {
"name": "نقاط مخصصة",
"description": "يتم عرض هذا الرقم كنقاط السناب شات"
}
}
}
}
},

View File

@@ -1196,6 +1196,16 @@
"settings_menu": {
"name": "Settings Menu",
"description": "Choose between the new and legacy settings menu layouts"
},
"spoof_snap_score": {
"name": "Spoof Snap Score",
"description": "Spoof your Snap Score (locally)",
"properties": {
"custom_snap_score": {
"name": "Custom Snap Score",
"description": "The custom Snap Score to fake"
}
}
}
}
},

View File

@@ -62,4 +62,19 @@ class UserInterfaceTweaks : ConfigContainer() {
}
val preventForcedKeyboard = boolean("prevent_forced_keyboard") { requireRestart() }
val settingsMenu = unique("settings_menu", "default", "legacy") { requireRestart() }.apply { set("default") }
inner class SpoofSnapScore : ConfigContainer(hasGlobalState = true) {
val customSnapScore = string("custom_snap_score") {
requireRestart()
inputCheck = { input ->
if (input.isEmpty()) true
else {
val digits = input.replace(Regex("[^0-9]"), "")
digits.isNotEmpty() && digits.length <= 7 && digits.toLong() <= 9999999L
}
}
}
}
val spoofSnapScore = container("spoof_snap_score", SpoofSnapScore()) { requireRestart() }
}

View File

@@ -159,6 +159,7 @@ class FeatureManager(
PreventForcedKeyboard(),
CustomTheming(),
HideTypingIndicator(),
FakeSnapScore(),
)
features.values.toList().forEach { feature ->

View File

@@ -0,0 +1,54 @@
package me.eternal.purrfectsnap.core.features.impl.ui
import me.eternal.purrfectsnap.core.features.Feature
import me.eternal.purrfectsnap.core.util.hook.HookStage
import me.eternal.purrfectsnap.core.util.hook.hook
class FakeSnapScore : Feature("Fake Snap Score") {
override fun init() {
if (context.config.userInterface.spoofSnapScore.globalState != true) return
val customScoreRaw = context.config.userInterface.spoofSnapScore.customSnapScore.getNullable()?.trim()?.takeIf { it.isNotBlank() }
?: return
val customScore = try {
val digitsOnly = customScoreRaw.replace(Regex("[^0-9]"), "")
if (digitsOnly.isNotEmpty()) {
val clampedVal = digitsOnly.toLong().coerceAtMost(9999999L)
java.text.NumberFormat.getNumberInstance(java.util.Locale.US).format(clampedVal)
} else {
null
}
} catch (e: Exception) {
null
} ?: return
onNextActivityCreate {
android.widget.TextView::class.java.hook("setText", HookStage.BEFORE) { param ->
val text = param.argNullable<CharSequence>(0)?.toString() ?: return@hook
if (text.matches(Regex("^[0-9\\s,.]+$"))) {
val digits = text.replace(Regex("[^0-9]"), "")
if (digits.length >= 4 || text.contains(",")) {
var parent = (param.thisObject() as android.widget.TextView).parent
var isProfile = false
while (parent != null) {
val className = parent.javaClass.simpleName.lowercase()
if (className.contains("profile") || className.contains("identity")) {
isProfile = true
break
}
parent = parent.parent
}
if (isProfile) {
param.setArg(0, customScore)
}
}
}
}
}
}
}