feat: 2d bitmoji selfie

This commit is contained in:
rhunk 2023-09-02 12:57:38 +02:00
parent 33131728ca
commit 3ba4e573ad
5 changed files with 36 additions and 5 deletions

View File

@ -191,6 +191,10 @@
"name": "Hide UI Components",
"description": "Select which UI components to hide"
},
"2d_bitmoji_selfie": {
"name": "2D Bitmoji Selfie",
"description": "Brings back the 2D selfie from older Snapchat versions\nYou need to clean the Snapchat cache from debug for this to take effect"
},
"disable_spotlight": {
"name": "Disable Spotlight",
"description": "Disables the Spotlight page"

View File

@ -24,6 +24,7 @@ class UserInterfaceTweaks : ConfigContainer() {
"hide_live_location_share_button",
"hide_call_buttons"
)
val ddBitmojiSelfie = boolean("2d_bitmoji_selfie")
val disableSpotlight = boolean("disable_spotlight")
val startupTab = unique("startup_tab",
"ngs_map_icon_container",

View File

@ -0,0 +1,22 @@
package me.rhunk.snapenhance.features.impl.tweaks
import me.rhunk.snapenhance.core.eventbus.events.impl.NetworkApiRequestEvent
import me.rhunk.snapenhance.features.Feature
import me.rhunk.snapenhance.features.FeatureLoadParams
import me.rhunk.snapenhance.util.snap.BitmojiSelfie
class OldBitmojiSelfie : Feature("OldBitmojiSelfie", loadParams = FeatureLoadParams.INIT_SYNC) {
override fun init() {
val urlPrefixes = arrayOf("https://images.bitmoji.com/3d/render/", "https://cf-st.sc-cdn.net/3d/render/")
val state by context.config.userInterface.ddBitmojiSelfie
context.event.subscribe(NetworkApiRequestEvent::class, { state }) { event ->
if (urlPrefixes.firstOrNull { event.url.startsWith(it) } == null) return@subscribe
val bitmojiURI = event.url.substringAfterLast("/")
event.url =
BitmojiSelfie.BitmojiSelfieType.STANDARD.prefixUrl +
bitmojiURI +
(bitmojiURI.takeIf { !it.contains("?") }?.let { "?" } ?: "&") + "transparent=1"
}
}
}

View File

@ -30,6 +30,7 @@ import me.rhunk.snapenhance.features.impl.tweaks.GooglePlayServicesDialogs
import me.rhunk.snapenhance.features.impl.tweaks.LocationSpoofer
import me.rhunk.snapenhance.features.impl.tweaks.MediaQualityLevelOverride
import me.rhunk.snapenhance.features.impl.tweaks.Notifications
import me.rhunk.snapenhance.features.impl.tweaks.OldBitmojiSelfie
import me.rhunk.snapenhance.features.impl.tweaks.SendOverride
import me.rhunk.snapenhance.features.impl.tweaks.SnapchatPlus
import me.rhunk.snapenhance.features.impl.tweaks.UnlimitedSnapViewTime
@ -95,6 +96,7 @@ class FeatureManager(private val context: ModContext) : Manager {
register(ProfilePictureDownloader::class)
register(AddFriendSourceSpoof::class)
register(DisableReplayInFF::class)
register(OldBitmojiSelfie::class)
initializeFeatures()
}

View File

@ -1,9 +1,11 @@
package me.rhunk.snapenhance.util.snap
object BitmojiSelfie {
enum class BitmojiSelfieType {
STANDARD,
THREE_D
enum class BitmojiSelfieType(
val prefixUrl: String,
) {
STANDARD("https://sdk.bitmoji.com/render/panel/"),
THREE_D("https://images.bitmoji.com/3d/render/")
}
fun getBitmojiSelfie(selfieId: String?, avatarId: String?, type: BitmojiSelfieType): String? {
@ -11,8 +13,8 @@ object BitmojiSelfie {
return null
}
return when (type) {
BitmojiSelfieType.STANDARD -> "https://sdk.bitmoji.com/render/panel/$selfieId-$avatarId-v1.webp?transparent=1"
BitmojiSelfieType.THREE_D -> "https://images.bitmoji.com/3d/render/$selfieId-$avatarId-v1.webp?trim=circle"
BitmojiSelfieType.STANDARD -> "${type.prefixUrl}$selfieId-$avatarId-v1.webp?transparent=1"
BitmojiSelfieType.THREE_D -> "${type.prefixUrl}$selfieId-$avatarId-v1.webp?trim=circle"
}
}
}