feat(PR): Spoof SnapScore by RSR

RSR
This commit is contained in:
ΞTΞRNAL
2026-03-12 05:20:04 +05:30
committed by GitHub
4 changed files with 72 additions and 13 deletions

View File

@@ -1161,8 +1161,8 @@
"description": "تزييف نقاط السناب شات الخاصة بك (محلياً فقط)",
"properties": {
"custom_snap_score": {
"name": "نقاط مخصصة",
"description": "يتم عرض هذا الرقم كنقاط السناب شات"
"name": "النقاط المخصصة",
"description": "تعيين نقاط السناب شات الوهمية (أقصى عدد هو 9,999,999)"
}
}
}

View File

@@ -1203,7 +1203,7 @@
"properties": {
"custom_snap_score": {
"name": "Custom Snap Score",
"description": "The custom Snap Score to fake"
"description": "The custom Snap Score you want to display (max 9,999,999)"
}
}
}

View File

@@ -69,7 +69,22 @@ class UserInterfaceTweaks : ConfigContainer() {
inputCheck = { input ->
if (input.isEmpty()) true
else {
input.replace(Regex("[^0-9]"), "").isNotEmpty()
val digits = input.replace(Regex("[^0-9]"), "")
val isTooLong = digits.isNotEmpty() && (digits.length > 7 || digits.toLong() > 9999999L)
if (isTooLong) {
try {
val context = Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null) as? android.content.Context
context?.let {
val handler = android.os.Handler(android.os.Looper.getMainLooper())
handler.post {
android.widget.Toast.makeText(it, "The maximum Snap Score limit is 9,999,999", android.widget.Toast.LENGTH_SHORT).show()
}
}
} catch (_: Throwable) {}
false
} else {
digits.isNotEmpty()
}
}
}
}

View File

@@ -1,5 +1,8 @@
package me.eternal.purrfectsnap.core.features.impl.ui
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import me.eternal.purrfectsnap.core.features.Feature
import me.eternal.purrfectsnap.core.util.hook.HookStage
import me.eternal.purrfectsnap.core.util.hook.hook
@@ -8,21 +11,36 @@ 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 = customScoreRaw.replace(Regex("[^0-9]"), "")
if (customScore.isEmpty()) return
val customScoreRaw = context.config.userInterface.spoofSnapScore.customSnapScore.getNullable()?.trim() ?: return
val customScore = try {
val digitsOnly = customScoreRaw.replace(Regex("[^0-9]"), "")
if (digitsOnly.isNotEmpty()) {
val clampedVal = digitsOnly.toLong().coerceAtMost(9999999L)
val formatted = StringBuilder()
val reversed = clampedVal.toString().reversed()
for (i in reversed.indices) {
formatted.append(reversed[i])
if ((i + 1) % 3 == 0 && i != reversed.lastIndex) {
formatted.append(",")
}
}
formatted.reverse().toString()
} else {
null
}
} catch (e: Exception) {
null
} ?: return
onNextActivityCreate {
android.widget.TextView::class.java.hook("setText", HookStage.BEFORE) { param ->
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(",")) {
val textView = param.thisObject() as android.widget.TextView
val textView = param.thisObject() as TextView
var parent = textView.parent
var isProfile = false
@@ -37,8 +55,34 @@ class FakeSnapScore : Feature("Fake Snap Score") {
if (isProfile) {
param.setArg(0, customScore)
textView.ellipsize = null
textView.setSingleLine(false)
textView.post {
textView.layoutParams?.let { lp ->
if (lp.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
lp.width = ViewGroup.LayoutParams.WRAP_CONTENT
textView.layoutParams = lp
}
}
val paint = textView.paint
val textWidth = paint.measureText(customScore).toInt() + textView.paddingLeft + textView.paddingRight
if (textView.minWidth < textWidth) {
textView.minWidth = textWidth
}
var currentParent = textView.parent
while (currentParent is ViewGroup) {
if (currentParent is ConstraintLayout) {
currentParent.layoutParams?.let { plp ->
if (plp.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
plp.width = ViewGroup.LayoutParams.WRAP_CONTENT
currentParent.layoutParams = plp
}
}
}
currentParent = currentParent.parent
}
}
}
}
}