generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Infinity for Reddit - Spoof client): Support latest version
- Loading branch information
Showing
5 changed files
with
32 additions
and
72 deletions.
There are no files selected for viewing
75 changes: 30 additions & 45 deletions
75
...otlin/app/revanced/patches/reddit/customclients/infinityforreddit/api/SpoofClientPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,54 @@ | ||
package app.revanced.patches.reddit.customclients.infinityforreddit.api | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction | ||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprintResult | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable | ||
import app.revanced.patcher.util.smali.toInstructions | ||
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch | ||
import app.revanced.patches.reddit.customclients.Constants.OAUTH_USER_AGENT | ||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHttpBasicAuthHeaderFingerprint | ||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.LoginActivityOnCreateFingerprint | ||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.SetWebViewSettingsFingerprint | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.APIUtilsFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethod | ||
import com.android.tools.smali.dexlib2.immutable.ImmutableMethodImplementation | ||
|
||
@Patch( | ||
name = "Spoof client", | ||
description = "Restores functionality of the app by using custom client ID's.", | ||
compatiblePackages = [ | ||
CompatiblePackage( | ||
"ml.docilealligator.infinityforreddit", [ | ||
"5.4.0", | ||
"5.4.1", | ||
"5.4.2", | ||
"6.0.1", | ||
"6.0.2", | ||
"6.0.4", | ||
"6.0.6", | ||
"6.1.1" | ||
] | ||
) | ||
CompatiblePackage("ml.docilealligator.infinityforreddit") | ||
] | ||
) | ||
@Suppress("unused") | ||
object SpoofClientPatch : AbstractSpoofClientPatch( | ||
"infinity://localhost", | ||
clientIdFingerprints = listOf(GetHttpBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint), | ||
userAgentFingerprints = listOf(SetWebViewSettingsFingerprint) | ||
clientIdFingerprints = listOf(APIUtilsFingerprint), | ||
) { | ||
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) { | ||
forEach { | ||
// First is index of the clientId string. | ||
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index | ||
it.mutableMethod.apply { | ||
val oAuthClientIdRegister = getInstruction<OneRegisterInstruction>(clientIdIndex).registerA | ||
first().mutableClass.methods.apply { | ||
val getClientIdMethod = single { it.name == "getId" }.also(::remove) | ||
|
||
replaceInstruction( | ||
clientIdIndex, | ||
"const-string v$oAuthClientIdRegister, \"$clientId\"" | ||
) | ||
} | ||
} | ||
} | ||
|
||
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext) { | ||
first().let { result -> | ||
val insertIndex = result.scanResult.stringsScanResult!!.matches.first().index | ||
val newGetClientIdMethod = ImmutableMethod( | ||
getClientIdMethod.definingClass, | ||
getClientIdMethod.name, | ||
null, | ||
getClientIdMethod.returnType, | ||
AccessFlags.PUBLIC or AccessFlags.STATIC, | ||
null, | ||
null, | ||
ImmutableMethodImplementation( | ||
1, | ||
""" | ||
const-string v0, "$clientId" | ||
return-object v0 | ||
""".toInstructions(getClientIdMethod), | ||
null, | ||
null, | ||
), | ||
).toMutable() | ||
|
||
result.mutableMethod.addInstructions( | ||
insertIndex, | ||
""" | ||
const-string v0, "$OAUTH_USER_AGENT" | ||
invoke-virtual {p1, v0}, Landroid/webkit/WebSettings;->setUserAgentString(Ljava/lang/String;)V | ||
""" | ||
) | ||
add(newGetClientIdMethod) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
...es/reddit/customclients/infinityforreddit/api/fingerprints/AbstractClientIdFingerprint.kt
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...dit/customclients/infinityforreddit/api/fingerprints/GetHttpBasicAuthHeaderFingerprint.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...ddit/customclients/infinityforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt
This file was deleted.
Oops, something went wrong.