Skip to content

Commit

Permalink
Merge branch 'dev' into feat/music-permanent-shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX authored Aug 3, 2023
2 parents 6046c0c + 76bab10 commit b2f824c
Show file tree
Hide file tree
Showing 14 changed files with 198 additions and 104 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# [2.187.0](https://github.com/ReVanced/revanced-patches/compare/v2.186.0...v2.187.0) (2023-08-02)


### Bug Fixes

* Remove version numbers from individual patches ([#2709](https://github.com/ReVanced/revanced-patches/issues/2709)) ([7a828ea](https://github.com/ReVanced/revanced-patches/commit/7a828ea8826864505fac9b2bdb3a1261d9f4dc35))
* **Sync for Reddit - Change OAuth client id:** Disable piracy detection ([cd103dd](https://github.com/ReVanced/revanced-patches/commit/cd103dd9b8ff2667246d4abaf75577f28bf1a11b))
* Use clearer descriptions ([8dbb0e2](https://github.com/ReVanced/revanced-patches/commit/8dbb0e212e8ceeb0381a3509e45afca095ddee53))
* **YouTube - Spoof app version:** Fix grammar in description ([#2711](https://github.com/ReVanced/revanced-patches/issues/2711)) ([dd249e6](https://github.com/ReVanced/revanced-patches/commit/dd249e62243e57733a6ff4d3a17d30db0e08a84d))
* **YouTube - Spoof App Version:** Remove 17.30.35 target (version no longer works correctly) ([#2703](https://github.com/ReVanced/revanced-patches/issues/2703)) ([210108b](https://github.com/ReVanced/revanced-patches/commit/210108bd8f86f583f5cd5d5538480b76d51d7776))
* **YouTube - Theme:** only set splash screen color if background colors are set ([f058db4](https://github.com/ReVanced/revanced-patches/commit/f058db4ba4300400ac92b4a9790708eb8bde7092))


### Features

* **Joey for Reddit:** Add `Change OAuth client id` patch ([1bac47d](https://github.com/ReVanced/revanced-patches/commit/1bac47df889b5221bef1c03e652f894be8d39385))
* **Joey for Reddit:** Add `Disable ads` patch ([ad7e147](https://github.com/ReVanced/revanced-patches/commit/ad7e14771208dcab08fd6dc29403b1a4cf602111))
* **Reddit is Fun - Spoof client:** Spoof the user agent ([b9aaf61](https://github.com/ReVanced/revanced-patches/commit/b9aaf610ad9f1f45a72265a3782d2cf996020139))
* **Sync for Reddit:** add `Disable Sync for Lemmy bottom sheet` patch ([56b535b](https://github.com/ReVanced/revanced-patches/commit/56b535b2a136d4b0afbddf2c8e251889c2555056))
* **YouTube - Hide layout components:** Hide `chips shelf` ([#2699](https://github.com/ReVanced/revanced-patches/issues/2699)) ([8e6058b](https://github.com/ReVanced/revanced-patches/commit/8e6058b62350b3d14d79e6fe52b0ad781b66b5de))
* **YouTube:** add `Player Flyout Menu` patch ([#2295](https://github.com/ReVanced/revanced-patches/issues/2295)) ([aea0af0](https://github.com/ReVanced/revanced-patches/commit/aea0af059784ae4820a0e73ff91f97bbc3ebc4c7))

# [2.187.0-dev.10](https://github.com/ReVanced/revanced-patches/compare/v2.187.0-dev.9...v2.187.0-dev.10) (2023-08-02)


### Features

* **Reddit is Fun - Spoof client:** Spoof the user agent ([b9aaf61](https://github.com/ReVanced/revanced-patches/commit/b9aaf610ad9f1f45a72265a3782d2cf996020139))

# [2.187.0-dev.9](https://github.com/ReVanced/revanced-patches/compare/v2.187.0-dev.8...v2.187.0-dev.9) (2023-07-30)


Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 2.187.0-dev.9
version = 2.187.0
2 changes: 1 addition & 1 deletion patches.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.*
import java.io.File

abstract class AbstractChangeOAuthClientIdPatch(
abstract class AbstractSpoofClientPatch(
private val redirectUri: String,
private val options: ChangeOAuthClientIdOptionsContainer,
private val fingerprints: List<MethodFingerprint>
) : BytecodePatch(fingerprints) {
private val options: SpoofClientOptionsContainer,
private val clientIdFingerprints: List<MethodFingerprint>,
private val userAgentFingerprints: List<MethodFingerprint>? = null,
) : BytecodePatch(buildList {
addAll(clientIdFingerprints)
userAgentFingerprints?.let(::addAll)
}) {
override fun execute(context: BytecodeContext): PatchResult {
if (options.clientId == null) {
// Ensure device runs Android.
Expand All @@ -38,13 +42,39 @@ abstract class AbstractChangeOAuthClientIdPatch(
}.let { options.clientId = it.readText().trim() }
}

return fingerprints.map { it.result ?: throw it.toErrorResult() }.patch(context)
fun List<MethodFingerprint>?.executePatch(
patch: List<MethodFingerprintResult>.(BytecodeContext) -> PatchResult
) {
when (val result = this?.map { it.result ?: throw it.toErrorResult() }?.patch(context)) {
is PatchResultError -> throw result
}
}

clientIdFingerprints.executePatch { patchClientId(context) }
userAgentFingerprints.executePatch { patchUserAgent(context) }

return PatchResultSuccess()
}

abstract fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult
/**
* Patch the client ID. The fingerprints are guaranteed to be in the same order as in [clientIdFingerprints].
*
* @param context The current [BytecodeContext].
*
*/
abstract fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult

/**
* Patch the user agent. The fingerprints are guaranteed to be in the same order as in [userAgentFingerprints].
*
* @param context The current [BytecodeContext].
*/
// Not every client needs to patch the user agent.
open fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext): PatchResult =
PatchResultSuccess()

companion object Options {
open class ChangeOAuthClientIdOptionsContainer : OptionsContainer() {
open class SpoofClientOptionsContainer : OptionsContainer() {
var clientId by option(
PatchOption.StringOption(
"client-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import app.revanced.patcher.patch.annotations.Patch

@Target(AnnotationTarget.CLASS)
@Patch
@Name("Change OAuth client id")
annotation class ChangeOAuthClientIdPatchAnnotation
@Name("Spoof client")
annotation class SpoofClientAnnotation
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.GetAuthorizationUrlFingerprint
import app.revanced.patches.reddit.customclients.baconreader.api.fingerprints.RequestTokenFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction


@ChangeOAuthClientIdPatchAnnotation
@Description("Changes the OAuth client ID. " +
@SpoofClientAnnotation
@Description("Spoofs the client in order to allow logging in. " +
"The OAuth application type has to be \"Installed app\" " +
"and the redirect URI has to be set to \"http://baconreader.com/auth\".")
@Compatibility(
Expand All @@ -26,11 +26,11 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
Package("com.onelouder.baconreader.premium")
]
)
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
class SpoofClientPatch : AbstractSpoofClientPatch(
"http://baconreader.com/auth", Options, listOf(GetAuthorizationUrlFingerprint, RequestTokenFingerprint)
) {

override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
fun MethodFingerprintResult.patch(replacementString: String) {
val clientIdIndex = scanResult.stringsScanResult!!.matches.first().index

Expand All @@ -52,5 +52,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
return PatchResultSuccess()
}

companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.boostforreddit.api.fingerprints.GetClientIdFingerprint

@ChangeOAuthClientIdPatchAnnotation
@Description("Changes the OAuth client ID. " +
@SpoofClientAnnotation
@Description("Spoofs the client in order to allow logging in. " +
"The OAuth application type has to be \"Installed app\" " +
"and the redirect URI has to be set to \"http://rubenmayayo.com\".")
@Compatibility([Package("com.rubenmayayo.reddit")])
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
class SpoofClientPatch : AbstractSpoofClientPatch(
"http://rubenmayayo.com", Options, listOf(GetClientIdFingerprint)
) {
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
first().mutableMethod.addInstructions(
0,
"""
const-string v0, "$clientId"
return-object v0
"""
"""
const-string v0, "$clientId"
return-object v0
"""
)

return PatchResultSuccess()
}

companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHttpBasicAuthHeaderFingerprint
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.LoginActivityOnCreateFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction

@ChangeOAuthClientIdPatchAnnotation
@Description("Changes the OAuth client ID. " +
@SpoofClientAnnotation
@Description("Spoofs the client in order to allow logging in. " +
"The OAuth application type has to be \"Installed app\" " +
"and the redirect URI has to be set to \"infinity://localhost\".")
@Compatibility([Package("ml.docilealligator.infinityforreddit")])
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
class SpoofClientPatch : AbstractSpoofClientPatch(
"infinity://localhost",
Options,
listOf(GetHttpBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint)
) {
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
forEach {
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index
it.mutableMethod.apply {
Expand All @@ -41,5 +41,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
return PatchResultSuccess()
}

companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch.DisablePiracyDetectionPatch

@ChangeOAuthClientIdPatchAnnotation
@SpoofClientAnnotation
@Description(
"Changes the OAuth client ID. " +
"Spoofs the client in order to allow logging in. " +
"The OAuth application type has to be \"Installed app\" " +
"and the redirect URI has to be set to \"https://127.0.0.1:65023/authorize_callback\"."
)
Expand All @@ -28,10 +28,10 @@ import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.
]
)
@DependsOn([DisablePiracyDetectionPatch::class])
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
class SpoofClientPatch : AbstractSpoofClientPatch(
"https://127.0.0.1:65023/authorize_callback", Options, listOf(GetClientIdFingerprint)
) {
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
first().mutableMethod.addInstructions(
0,
"""
Expand All @@ -43,5 +43,5 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
return PatchResultSuccess()
}

companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode

object GetUserAgentFingerprint : MethodFingerprint(
"Ljava/lang/String;",
AccessFlags.PUBLIC or AccessFlags.STATIC,
emptyList(),
listOf(
Opcode.NEW_ARRAY,
Opcode.CONST_4,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.APUT_OBJECT,
Opcode.CONST,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Package
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.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult.MethodFingerprintScanResult.StringsScanResult.StringMatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation
import app.revanced.patches.reddit.customclients.AbstractSpoofClientPatch
import app.revanced.patches.reddit.customclients.SpoofClientAnnotation
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BasicAuthorizationFingerprint
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.BuildAuthorizationStringFingerprint
import app.revanced.patches.reddit.customclients.redditisfun.api.fingerprints.GetUserAgentFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction

@ChangeOAuthClientIdPatchAnnotation
@Description("Changes the OAuth client ID. " +
@SpoofClientAnnotation
@Description("Spoofs the client in order to allow logging in. " +
"The OAuth application type has to be \"Installed app\" " +
"and the redirect URI has to be set to \"redditisfun://auth\".")
@Compatibility([Package("com.andrewshu.android.reddit"), Package("com.andrewshu.android.redditdonation")])
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
class SpoofClientPatch : AbstractSpoofClientPatch(
"redditisfun://auth",
Options,
listOf(
BuildAuthorizationStringFingerprint,
BasicAuthorizationFingerprint,
)
listOf(BuildAuthorizationStringFingerprint, BasicAuthorizationFingerprint),
listOf(GetUserAgentFingerprint)
) {
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult {
override fun List<MethodFingerprintResult>.patchClientId(context: BytecodeContext): PatchResult {
/**
* Replaces a one register instruction with a const-string instruction
* at the index returned by [getReplacementIndex].
Expand Down Expand Up @@ -57,5 +57,20 @@ class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch(
return PatchResultSuccess()
}

companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer()
override fun List<MethodFingerprintResult>.patchUserAgent(context: BytecodeContext): PatchResult {
// Use a random number as the user agent string.
val randomUserAgent = (0..100000).random()

first().mutableMethod.addInstructions(
0,
"""
const-string v0, "$randomUserAgent"
return-object v0
"""
)

return PatchResultSuccess()
}

companion object Options : AbstractSpoofClientPatch.Options.SpoofClientOptionsContainer()
}
Loading

0 comments on commit b2f824c

Please sign in to comment.