mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
refactor(sponsorblock): reflect the official ReVanced's source code
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.sponsorblock.bytecode.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.util.MethodUtil
|
||||
|
||||
object NextGenWatchLayoutFingerprint : MethodFingerprint(
|
||||
returnType = "V", // constructors return void, in favour of speed of matching, this fingerprint has been added
|
||||
customFingerprint = { MethodUtil.isConstructor(it) && it.parameterTypes.size == 3 && it.definingClass.endsWith("NextGenWatchLayout;") }
|
||||
)
|
@ -4,7 +4,7 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object PlayerControllerFingerprint : MethodFingerprint(
|
||||
customFingerprint = {
|
||||
it.definingClass == "Lapp/revanced/integrations/sponsorblock/PlayerController;"
|
||||
it.definingClass == "Lapp/revanced/integrations/sponsorblock/SegmentPlaybackController;"
|
||||
&& it.name == "setSponsorBarRect"
|
||||
}
|
||||
)
|
||||
|
@ -43,7 +43,6 @@ import org.jf.dexlib2.iface.reference.MethodReference
|
||||
@Version("0.0.1")
|
||||
class SponsorBlockBytecodePatch : BytecodePatch(
|
||||
listOf(
|
||||
NextGenWatchLayoutFingerprint,
|
||||
PlayerControllerFingerprint
|
||||
)
|
||||
) {
|
||||
@ -57,16 +56,11 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
||||
INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR,
|
||||
"setVideoTime"
|
||||
)
|
||||
highPrecisionTimeHook(
|
||||
INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR,
|
||||
"setHighPrecisionVideoTime"
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
* Inject VideoIdPatch
|
||||
*/
|
||||
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
|
||||
MainstreamVideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
|
||||
|
||||
|
||||
@ -137,18 +131,11 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
||||
* Voting & Shield button
|
||||
*/
|
||||
|
||||
arrayOf("ShieldButton", "VotingButton").forEach {
|
||||
PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/$it;")
|
||||
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/$it;")
|
||||
arrayOf("CreateSegmentButtonController", "VotingButtonController").forEach {
|
||||
PlayerControlsPatch.initializeSB("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
|
||||
PlayerControlsPatch.injectVisibility("$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/ui/$it;")
|
||||
}
|
||||
|
||||
// set SegmentHelperLayout.context to the player layout instance
|
||||
val instanceRegister = 0
|
||||
NextGenWatchLayoutFingerprint.result?.mutableMethod?.addInstruction(
|
||||
3,
|
||||
"invoke-static/range {p$instanceRegister}, $INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->addSkipSponsorView15(Landroid/view/View;)V"
|
||||
) ?: return NextGenWatchLayoutFingerprint.toErrorResult()
|
||||
|
||||
|
||||
/*
|
||||
* Replace strings
|
||||
@ -178,7 +165,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
||||
"Lapp/revanced/integrations/sponsorblock"
|
||||
|
||||
const val INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR =
|
||||
"$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/PlayerController;"
|
||||
"$INTEGRATIONS_BUTTON_CLASS_DESCRIPTOR/SegmentPlaybackController;"
|
||||
|
||||
lateinit var insertMethod: MutableMethod
|
||||
lateinit var insertInstructions: List<BuilderInstruction>
|
||||
|
@ -49,7 +49,7 @@ class SponsorBlockSecondaryBytecodePatch : BytecodePatch() {
|
||||
|
||||
mutableMethod.addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$targetRegister}, Lapp/revanced/integrations/sponsorblock/SponsorBlockUtils;->appendTimeWithoutSegments(Ljava/lang/String;)Ljava/lang/String;
|
||||
invoke-static {v$targetRegister}, Lapp/revanced/integrations/sponsorblock/SegmentPlaybackController;->appendTimeWithoutSegments(Ljava/lang/String;)Ljava/lang/String;
|
||||
move-result-object v$targetRegister
|
||||
"""
|
||||
)
|
||||
@ -66,7 +66,7 @@ class SponsorBlockSecondaryBytecodePatch : BytecodePatch() {
|
||||
|
||||
mutableMethod.addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {p0}, Lapp/revanced/integrations/sponsorblock/player/ui/SponsorBlockView;->initialize(Ljava/lang/Object;)V"
|
||||
"invoke-static {p0}, Lapp/revanced/integrations/sponsorblock/ui/SponsorBlockViewController;->initialize(Ljava/lang/Object;)V"
|
||||
)
|
||||
|
||||
patchSuccessArray[1] = true
|
||||
|
@ -84,9 +84,9 @@ class SponsorBlockResourcePatch : ResourcePatch {
|
||||
if (!(view.hasAttributes() && view.attributes.getNamedItem("android:id").nodeValue.endsWith("player_video_heading"))) continue
|
||||
|
||||
// voting button id from the voting button view from the youtube_controls_layout.xml host file
|
||||
val SBButtonId = "@+id/sponsorblock_button"
|
||||
val votingButtonId = "@+id/sb_voting_button"
|
||||
|
||||
view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = SBButtonId
|
||||
view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId
|
||||
|
||||
break
|
||||
}
|
||||
|
Reference in New Issue
Block a user