Skip to content

Commit

Permalink
feat(Sync for Reddit - Client spoof): Restore upload functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Oct 3, 2023
1 parent ef644e4 commit 9344c8a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class AbstractSpoofClientPatch(
"The Reddit OAuth client ID. " +
"You can get your client ID from https://www.reddit.com/prefs/apps. " +
"The application type has to be \"Installed app\" " +
"and the redirect URI has to be set to \"$redirectUri\"",
"and the redirect URI has to be set to \"$redirectUri\".",
true
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.patch.options.types.StringPatchOption.Companion.stringPatchOption
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetAuthorizationStringFingerprint
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.GetBearerTokenFingerprint
import app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints.ImgurImageAPIFingerprint
import app.revanced.patches.reddit.customclients.syncforreddit.detection.piracy.DisablePiracyDetectionPatch
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
Expand All @@ -31,7 +31,9 @@ import java.util.*
)
@Suppress("unused")
object SpoofClientPatch : AbstractSpoofClientPatch(
"http://redditsync/auth", listOf(GetAuthorizationStringFingerprint)
"http://redditsync/auth",
clientIdFingerprints = listOf(GetAuthorizationStringFingerprint),
miscellaneousFingerprints = listOf(ImgurImageAPIFingerprint)
) {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext) {
forEach { fingerprintResult ->
Expand Down Expand Up @@ -67,4 +69,14 @@ object SpoofClientPatch : AbstractSpoofClientPatch(
}
}
}

// Use the non-commercial Imgur API endpoint.
override fun List<MethodFingerprintResult>.patchMiscellaneous(context: BytecodeContext) = first().let {
val apiUrlIndex = it.scanResult.stringsScanResult!!.matches.first().index

it.mutableMethod.replaceInstruction(
apiUrlIndex,
"const-string v1, \"https://api.imgur.com/3/image\""
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.revanced.patches.reddit.customclients.syncforreddit.api.fingerprints

import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

object ImgurImageAPIFingerprint : MethodFingerprint(
strings = listOf(
"https://imgur-apiv3.p.rapidapi.com/3/image",
)
)

0 comments on commit 9344c8a

Please sign in to comment.