feat(YouTube - SponsorBlock): Add 'Hook' segment category (#5783)

This commit is contained in:
LisoUseInAIKyrios
2025-09-12 05:56:50 +04:00
committed by GitHub
parent 5ace6f587c
commit 9d4aa5cd16
8 changed files with 105 additions and 15 deletions

View File

@@ -1,8 +1,11 @@
package app.revanced.patches.youtube.layout.sponsorblock
import app.revanced.patcher.fingerprint
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversed
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@@ -56,3 +59,20 @@ internal val rectangleFieldInvalidatorFingerprint = fingerprint {
reference?.parameterTypes?.size == 1 && reference.name == "invalidate" // the reference is the invalidate(..) method
}
}
internal val adProgressTextViewVisibilityFingerprint = fingerprint {
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
returns("V")
parameters("Z")
custom { method, _ ->
indexOfAdProgressTextViewVisibilityInstruction(method) >= 0
}
}
internal fun indexOfAdProgressTextViewVisibilityInstruction(method: Method) =
method.indexOfFirstInstructionReversed {
val reference = getReference<MethodReference>()
reference?.definingClass ==
"Lcom/google/android/libraries/youtube/ads/player/ui/AdProgressTextView;"
&& reference.name =="setVisibility"
}

View File

@@ -252,5 +252,16 @@ val sponsorBlockPatch = bytecodePatch(
}
} ?: throw PatchException("Could not find the method which contains the replaceMeWith* strings")
}
adProgressTextViewVisibilityFingerprint.method.apply {
val index = indexOfAdProgressTextViewVisibilityInstruction(this)
val register = getInstruction<FiveRegisterInstruction>(index).registerD
addInstructionsAtControlFlowLabel(
index,
"invoke-static { v$register }, $EXTENSION_SEGMENT_PLAYBACK_CONTROLLER_CLASS_DESCRIPTOR->setAdProgressTextVisibility(I)V"
)
}
}
}

View File

@@ -1143,10 +1143,12 @@ Your user id is like a password and it should never be shared.
<string name="revanced_sb_segments_intro_sum">An interval without actual content. Could be a pause, static frame, or repeating animation. Does not include transitions containing information</string>
<string name="revanced_sb_segments_outro">Endcards / Credits</string>
<string name="revanced_sb_segments_outro_sum">Credits or when the YouTube endcards appear. Not for conclusions with information</string>
<string name="revanced_sb_segments_preview">Preview / Recap / Hook</string>
<string name="revanced_sb_segments_hook">Hook / Greeting</string>
<string name="revanced_sb_segments_hook_sum">Narrated trailers for the upcoming video, greetings and goodbyes. This should not skip conclusions with information</string>
<string name="revanced_sb_segments_preview">Preview / Recap</string>
<string name="revanced_sb_segments_preview_sum">Collection of clips that show what is coming up or what happened in the video or in other videos of a series, where all information is repeated elsewhere</string>
<string name="revanced_sb_segments_filler">Filler Tangent / Jokes</string>
<string name="revanced_sb_segments_filler_sum">Tangential scenes added only for filler or humor that are not required to understand the main content of the video. Does not include segments providing context or background details</string>
<string name="revanced_sb_segments_filler">Tangent / Jokes</string>
<string name="revanced_sb_segments_filler_sum">Tangential scenes or jokes that are not required to understand the main content of the video. This should not include segments providing context or background details</string>
<string name="revanced_sb_segments_nomusic">Music: Non-Music Section</string>
<string name="revanced_sb_segments_nomusic_sum">Only for use in music videos. Sections of music videos without music, that aren\'t already covered by another category</string>
<string name="revanced_sb_skip_button_compact">Skip</string>
@@ -1159,10 +1161,11 @@ Your user id is like a password and it should never be shared.
<string name="revanced_sb_skip_button_intro_middle">Skip intermission</string>
<string name="revanced_sb_skip_button_intro_end">Skip intermission</string>
<string name="revanced_sb_skip_button_outro">Skip outro</string>
<string name="revanced_sb_skip_button_hook">Skip hook</string>
<string name="revanced_sb_skip_button_preview_beginning">Skip preview</string>
<string name="revanced_sb_skip_button_preview_middle">Skip preview</string>
<string name="revanced_sb_skip_button_preview_end">Skip recap</string>
<string name="revanced_sb_skip_button_filler">Skip filler</string>
<string name="revanced_sb_skip_button_filler">Skip tangent</string>
<string name="revanced_sb_skip_button_nomusic">Skip non-music</string>
<string name="revanced_sb_skip_button_unsubmitted">Skip segment</string>
<string name="revanced_sb_skipped_sponsor">Skipped sponsor</string>
@@ -1173,10 +1176,11 @@ Your user id is like a password and it should never be shared.
<string name="revanced_sb_skipped_intro_middle">Skipped intermission</string>
<string name="revanced_sb_skipped_intro_end">Skipped intermission</string>
<string name="revanced_sb_skipped_outro">Skipped outro</string>
<string name="revanced_sb_skipped_hook">Skipped hook</string>
<string name="revanced_sb_skipped_preview_beginning">Skipped preview</string>
<string name="revanced_sb_skipped_preview_middle">Skipped preview</string>
<string name="revanced_sb_skipped_preview_end">Skipped recap</string>
<string name="revanced_sb_skipped_filler">Skipped filler</string>
<string name="revanced_sb_skipped_filler">Skipped tangent</string>
<string name="revanced_sb_skipped_nomusic">Skipped a non-music section</string>
<string name="revanced_sb_skipped_unsubmitted">Skipped unsubmitted segment</string>
<string name="revanced_sb_skipped_multiple_segments">Skipped multiple segments</string>