Skip to content

Commit

Permalink
fix(youtube/return-youtube-dislike): do not fetch voting stats when w…
Browse files Browse the repository at this point in the history
…atching shorts (#1532)

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
LisoUseInAIKyrios and oSumAtrIX committed Jan 28, 2023
1 parent 0d14c46 commit f46fcad
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,28 @@ import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.Retu
import app.revanced.patches.youtube.layout.returnyoutubedislike.fingerprints.*
import app.revanced.patches.youtube.layout.returnyoutubedislike.resource.patch.ReturnYouTubeDislikeResourcePatch
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch

@Patch
@DependsOn([IntegrationsPatch::class, VideoIdPatch::class, ReturnYouTubeDislikeResourcePatch::class])
@DependsOn(
[
IntegrationsPatch::class,
VideoIdPatch::class,
ReturnYouTubeDislikeResourcePatch::class,
PlayerTypeHookPatch::class,
]
)
@Name("return-youtube-dislike")
@Description("Shows the dislike count of videos using the Return YouTube Dislike API.")
@ReturnYouTubeDislikeCompatibility
@Version("0.0.1")
class ReturnYouTubeDislikePatch : BytecodePatch(
listOf(
TextComponentSpecParentFingerprint, LikeFingerprint, DislikeFingerprint, RemoveLikeFingerprint
TextComponentSpecParentFingerprint,
LikeFingerprint,
DislikeFingerprint,
RemoveLikeFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
import org.jf.dexlib2.Opcode
Expand All @@ -35,6 +36,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
dependencies = [
VideoInformationPatch::class, // updates video information and adds method to seek in video
PlayerControlsBytecodePatch::class,
PlayerTypeHookPatch::class,
IntegrationsPatch::class,
SponsorBlockResourcePatch::class,
VideoIdPatch::class
Expand All @@ -50,7 +52,6 @@ class SponsorBlockBytecodePatch : BytecodePatch(
NextGenWatchLayoutFingerprint,
AppendTimeFingerprint,
PlayerOverlaysLayoutInitFingerprint,
ShortsPlayerConstructorFingerprint,
StartVideoInformerFingerprint
)
) {
Expand Down Expand Up @@ -232,23 +233,6 @@ class SponsorBlockBytecodePatch : BytecodePatch(
"invoke-static {p0}, Lapp/revanced/integrations/sponsorblock/player/ui/SponsorBlockView;->initialize(Ljava/lang/Object;)V"
)

val startVideoInformerMethod = StartVideoInformerFingerprint.result!!.mutableMethod
startVideoInformerMethod.addInstructions(
0, """
const/4 v0, 0x0
sput-boolean v0, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->shorts_playing:Z
"""
)

val shortsPlayerConstructorMethod = ShortsPlayerConstructorFingerprint.result!!.mutableMethod

shortsPlayerConstructorMethod.addInstructions(
0, """
const/4 v0, 0x1
sput-boolean v0, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->shorts_playing:Z
"""
)

// TODO: isSBChannelWhitelisting implementation

return PatchResultSuccess()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import app.revanced.util.resources.ResourceUtils.mergeStrings
@DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class, ResourceMappingPatch::class])
@Version("0.0.1")
class SponsorBlockResourcePatch : ResourcePatch {
companion object {
internal var reelButtonGroupResourceId: Long = 0
}

override fun execute(context: ResourceContext): PatchResult {
val youtubePackage = "com.google.android.youtube"
Expand Down Expand Up @@ -107,10 +104,6 @@ class SponsorBlockResourcePatch : ResourcePatch {
}
}.close() // close afterwards

reelButtonGroupResourceId = ResourceMappingPatch.resourceMappings.single {
it.type == "id" && it.name == "reel_persistent_edu_button_group"
}.id

return PatchResultSuccess()
}
}

0 comments on commit f46fcad

Please sign in to comment.