mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat: return-youtube-dislikes
patch (#175)
* feat: ryd * refactor: use ryd patches class * feat: add video id dependency patch * fix: compatibility with 17.26.35 * refactor: named param variable, simpler mutableClass access
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.youtube.misc.videoid.annotation
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf("17.14.35", "17.22.36", "17.26.35")
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class VideoIdCompatibility
|
@ -0,0 +1,28 @@
|
||||
package app.revanced.patches.youtube.misc.videoid.fingerprint
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.annotation.DirectPatternScanMethod
|
||||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("video-id-fingerprint")
|
||||
@MatchingMethod(
|
||||
"Lcom/google/android/apps/youtube/app/common/player/PlaybackLifecycleMonitor;", "l"
|
||||
)
|
||||
@DirectPatternScanMethod
|
||||
@VideoIdCompatibility
|
||||
@Version("0.0.1")
|
||||
object VideoIdFingerprint : MethodFingerprint(
|
||||
"V",
|
||||
AccessFlags.DECLARED_SYNCHRONIZED or AccessFlags.FINAL or AccessFlags.PUBLIC,
|
||||
listOf("L"),
|
||||
listOf(Opcode.INVOKE_INTERFACE),
|
||||
customFingerprint = {
|
||||
it.definingClass.endsWith("PlaybackLifecycleMonitor;")
|
||||
}
|
||||
)
|
@ -0,0 +1,56 @@
|
||||
package app.revanced.patches.youtube.misc.videoid.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.impl.BytecodeData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Dependencies
|
||||
import app.revanced.patcher.patch.impl.BytecodePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility
|
||||
import app.revanced.patches.youtube.misc.videoid.fingerprint.VideoIdFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
|
||||
|
||||
@Name("video-id-hook")
|
||||
@Description("hook to detect when the video id changes")
|
||||
@VideoIdCompatibility
|
||||
@Version("0.0.1")
|
||||
@Dependencies(dependencies = [IntegrationsPatch::class])
|
||||
class VideoIdPatch : BytecodePatch(
|
||||
listOf(
|
||||
VideoIdFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(data: BytecodeData): PatchResult {
|
||||
injectCall("Lapp/revanced/integrations/videoplayer/VideoInformation;->setCurrentVideoId(Ljava/lang/String;)V")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var offset = 2
|
||||
|
||||
/**
|
||||
* Adds an invoke-static instruction, called with the new id when the video changes
|
||||
* @param methodDescriptor which method to call. Params have to be `Ljava/lang/String;`
|
||||
*/
|
||||
fun injectCall(
|
||||
methodDescriptor: String
|
||||
) {
|
||||
val result = VideoIdFingerprint.result!!
|
||||
|
||||
val method = result.mutableMethod
|
||||
val videoIdRegister =
|
||||
(method.implementation!!.instructions[result.patternScanResult!!.endIndex + 1] as Instruction11x).registerA
|
||||
method.addInstructions(
|
||||
result.patternScanResult!!.endIndex + offset, // after the move-result-object
|
||||
"invoke-static {v$videoIdRegister}, $methodDescriptor"
|
||||
)
|
||||
offset++ // so additional instructions get added later
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user