feat(sponsorblock): automatically hide skip button

This commit is contained in:
inotia00 2023-04-28 16:38:16 +09:00
parent be9d745d9c
commit 183b806bdb
5 changed files with 50 additions and 38 deletions

View File

@ -29,7 +29,6 @@ class SharedResourceIdPatch : ResourcePatch {
var compactLinkLabelId: Long = -1
var controlsLayoutStubResourceId: Long = -1
var donationCompanionResourceId: Long = -1
var emptyColorLabelId: Long = -1
var fabLabelId: Long = -1
var filterBarHeightLabelId: Long = -1
var floatyBarQueueLabelId: Long = -1
@ -71,7 +70,6 @@ class SharedResourceIdPatch : ResourcePatch {
compactLinkLabelId = find(LAYOUT, "compact_link")
controlsLayoutStubResourceId = find(ID, "controls_layout_stub")
donationCompanionResourceId = find(LAYOUT, "donation_companion")
emptyColorLabelId = find(COLOR, "inline_time_bar_colorized_bar_empty_color_dark")
fabLabelId = find(ID, "fab")
filterBarHeightLabelId = find(DIMEN, "filter_bar_height")
floatyBarQueueLabelId = find(STRING, "floaty_bar_queue_status")

View File

@ -8,6 +8,7 @@ import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
@ -33,6 +34,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
@Name("sponsorblock-bytecode-patch")
@DependsOn(
[
HookTimebarPatch::class,
LegacyVideoIdPatch::class,
MainstreamVideoIdPatch::class,
OverrideSpeedHookPatch::class,
@ -112,6 +114,9 @@ class SponsorBlockBytecodePatch : BytecodePatch(
insertInstructions.indexOf(it) to (it as FiveRegisterInstruction).registerD
}
if (drawRectangleInstructions.size < 4)
return PatchResultError("Couldn't find drawRect reference")
mapOf(
"setSponsorBarAbsoluteLeft" to 3,
"setSponsorBarAbsoluteRight" to 0

View File

@ -1,17 +1,20 @@
package app.revanced.patches.youtube.misc.timebar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
import org.jf.dexlib2.Opcode
object EmptyColorFingerprint : MethodFingerprint(
returnType = "V",
opcodes = listOf(Opcode.DIV_LONG_2ADDR),
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode.ordinal == Opcode.CONST.ordinal &&
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.emptyColorLabelId
} == true
}
opcodes = listOf(
Opcode.MOVE_RESULT_WIDE,
Opcode.CMP_LONG,
Opcode.IF_LEZ,
Opcode.IGET_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE,
Opcode.GOTO,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_WIDE
)
)

View File

@ -8,14 +8,11 @@ import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.youtube.misc.timebar.fingerprints.*
@Name("hook-timebar-patch")
@DependsOn([SharedResourceIdPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class HookTimebarPatch : BytecodePatch(

View File

@ -543,38 +543,56 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="sb_enable_sb">Enable SponsorBlock</string>
<string name="sb_enable_sb_sum">SponsorBlock is a crowd-sourced system for skipping annoying parts of YouTube videos</string>
<string name="sb_appearance_category">Appearance</string>
<string name="sb_enable_voting">Show voting button</string>
<string name="sb_enable_voting_sum_on">Segment voting button is shown</string>
<string name="sb_enable_voting_sum_off">Segment voting button is not shown</string>
<string name="sb_enable_create_segment">Show create new segment button</string>
<string name="sb_enable_create_segment_sum_on">Create new segment button is shown</string>
<string name="sb_enable_create_segment_sum_off">Create new segment button is not shown</string>
<string name="sb_enable_compact_skip_button">Use compact skip button</string>
<string name="sb_enable_compact_skip_button_sum_on">Skip button styled for minimum width</string>
<string name="sb_enable_compact_skip_button_sum_off">Skip button styled for best appearance</string>
<string name="sb_diff_segments">What to do with different segments</string>
<string name="sb_general">General</string>
<string name="sb_general_skiptoast">Show a toast when skipping segment automatically</string>
<string name="sb_enable_auto_hide_skip_segment_button">Automatically hide skip button</string>
<string name="sb_enable_auto_hide_skip_segment_button_sum_on">Skip button hides after a few seconds</string>
<string name="sb_enable_auto_hide_skip_segment_button_sum_off">Skip button displayed for entire segment</string>
<string name="sb_general_skiptoast">Show a toast when skipping automatically</string>
<string name="sb_general_skiptoast_sum_on">Toast shown when a segment is automatically skipped. Tap here to see an example</string>
<string name="sb_general_skiptoast_sum_off">Toast not shown. Tap here to see an example</string>
<string name="sb_general_skipcount">Enable skip count tracking</string>
<string name="sb_general_skipcount_sum_on">Lets the SponsorBlock leaderboard know how much time is saved. A message is sent to the leaderboard each time a segment is skipped</string>
<string name="sb_general_skipcount_sum_off">Skip count tracking is not enabled</string>
<string name="sb_general_time_without">Show video length without segments</string>
<string name="sb_general_time_without_sum_on">Video length minus all segments, shown in parentheses next to the full video length</string>
<string name="sb_general_time_without_sum_off">Full video length shown</string>
<string name="sb_create_segment_category">Creating new segments</string>
<string name="sb_enable_create_segment">Show create new segment button</string>
<string name="sb_enable_create_segment_sum_on">Create new segment button is shown</string>
<string name="sb_enable_create_segment_sum_off">Create new segment button is not shown</string>
<string name="sb_general_adjusting">Adjust new segment step</string>
<string name="sb_general_adjusting_sum">Number of milliseconds the time adjustment buttons move when creating new segments</string>
<string name="sb_general_adjusting_invalid">Value must be a positive number</string>
<string name="sb_guidelines_preference_title">View guidelines</string>
<string name="sb_guidelines_preference_sum">Guidelines contain rules and tips for creating new segments</string>
<string name="sb_guidelines_popup_title">Follow the guidelines</string>
<string name="sb_guidelines_popup_content">Read the SponsorBlock guidelines before creating new segments</string>
<string name="sb_guidelines_popup_already_read">Already read</string>
<string name="sb_guidelines_popup_open">Show me</string>
<string name="sb_general">General</string>
<string name="sb_general_skipcount">Enable skip count tracking</string>
<string name="sb_general_skipcount_sum_on">Lets the SponsorBlock leaderboard know how much time is saved. A message is sent to the leaderboard each time a segment is skipped</string>
<string name="sb_general_skipcount_sum_off">Skip count tracking is not enabled</string>
<string name="sb_general_min_duration">Minimum segment duration</string>
<string name="sb_general_min_duration_sum">Segments shorter than this value (in seconds) will not be shown or skipped</string>
<string name="sb_general_uuid">Your private user id</string>
<string name="sb_general_uuid_sum">This should be kept private. This is like a password and should not be shared with anyone. If someone has this, they can impersonate you</string>
<string name="sb_general_uuid_invalid">User id cannot be blank</string>
<string name="sb_settings_ie_sum">Your SponsorBlock JSON configuration that can be imported/exported to ReVanced and other SponsorBlock platforms. This includes your private user id. Be sure to share this wisely</string>
<string name="sb_general_api_url">Change API URL</string>
<string name="sb_general_api_url_sum">The address SponsorBlock uses to make calls to the server. &lt;b>Don\'t change this unless you know what you\'re doing&lt;/b></string>
<string name="sb_general_api_url_sum">The address SponsorBlock uses to make calls to the server. Do not change this unless you know what you\'re doing</string>
<string name="sb_api_url_reset">API URL reset</string>
<string name="sb_api_url_invalid">API URL is invalid</string>
<string name="sb_api_url_changed">API URL changed</string>
<string name="sb_settings_ie_sum">Your SponsorBlock JSON configuration that can be imported/exported to ReVanced and other SponsorBlock platforms. This includes your private user id. Be sure to share this wisely</string>
<string name="sb_diff_segments">Change segment behavior</string>
<string name="sb_segments_sponsor">Sponsor</string>
<string name="sb_segments_sponsor_sum">Paid promotion, paid referrals and direct advertisements. Not for self-promotion or free shout-outs to causes/creators/websites/products they like</string>
<string name="sb_segments_selfpromo">Unpaid/Self Promotion</string>
@ -625,9 +643,6 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="sb_skip_seekbaronly">Show in seek bar</string>
<string name="sb_skip_ignore">Disable</string>
<string name="sb_about_api_sum">Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms</string>
<string name="sb_about_made_by">Integration made by JakubWeg</string>
<string name="sb_submit_failed_invalid" formatted="false">Can\'t submit the segment: %s</string>
<string name="sb_submit_failed_timeout">Unable to submit segments (API timed out)</string>
<string name="sb_submit_failed_unknown_error" formatted="false">Unable to submit segments (status: %d %s)</string>
@ -661,13 +676,6 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="sb_new_segment_edit_by_hand_content">Do you want to edit the timing for the start or end of the segment?</string>
<string name="sb_new_segment_edit_by_hand_parse_error">Invalid time given</string>
<string name="sb_guidelines_preference_title">View guidelines</string>
<string name="sb_guidelines_preference_sum">Guidelines contain rules and tips for creating new segments</string>
<string name="sb_guidelines_popup_title">Follow the guidelines</string>
<string name="sb_guidelines_popup_content">Read the SponsorBlock guidelines before creating new segments</string>
<string name="sb_guidelines_popup_already_read">Already read</string>
<string name="sb_guidelines_popup_open">Show me</string>
<string name="sb_stats">Stats</string>
<string name="sb_stats_connection_failure">Stats temporarily not available (API is down)</string>
<string name="sb_stats_sb_disabled">SponsorBlock is disabled</string>
@ -687,6 +695,7 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="sb_stats_saved_hour_format" formatted="false">%d hours %d minutes</string>
<string name="sb_stats_saved_minute_format" formatted="false">%d minutes %d seconds</string>
<string name="sb_stats_saved_second_format" formatted="false">%d seconds</string>
<string name="sb_color_dot_label">Color:</string>
<string name="sb_color_changed">Color changed</string>
<string name="sb_color_reset">Color reset</string>
@ -694,9 +703,9 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="sb_reset_color">Reset color</string>
<string name="sb_reset">Reset</string>
<string name="sb_api_url_reset">API URL reset</string>
<string name="sb_api_url_invalid">API URL is invalid</string>
<string name="sb_api_url_changed">API URL changed</string>
<string name="sb_about_api_sum">Data is provided by the SponsorBlock API. Tap here to learn more and see downloads for other platforms</string>
<string name="sb_about_made_by">Integration made by JakubWeg</string>
<string name="seconds">sec</string>
<string name="settings_export_failed">Failed to export settings</string>