This commit is contained in:
inotia00 2023-05-02 18:44:46 +09:00
parent 4c84e3ae12
commit 2a55033fd5
11 changed files with 2 additions and 245 deletions

View File

@ -29,7 +29,6 @@ class OverlayButtonsBytecodePatch : BytecodePatch() {
"$BUTTON_PATH/AutoRepeat;",
"$BUTTON_PATH/CopyWithTimeStamp;",
"$BUTTON_PATH/Copy;",
"$BUTTON_PATH/Whitelists;",
"$BUTTON_PATH/Speed;"
).forEach { descriptor ->
PlayerControlsPatch.initializeControl(descriptor)

View File

@ -12,7 +12,6 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.button.autorepeat.patch.AutoRepeatPatch
import app.revanced.patches.youtube.button.overlaybuttons.bytecode.patch.OverlayButtonsBytecodePatch
import app.revanced.patches.youtube.button.whitelist.patch.WhitelistPatch
import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
import app.revanced.util.resources.ResourceUtils
@ -27,8 +26,7 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode
AutoRepeatPatch::class,
OverlayButtonsBytecodePatch::class,
OverrideSpeedHookPatch::class,
SettingsPatch::class,
WhitelistPatch::class
SettingsPatch::class
]
)
@YouTubeCompatibility
@ -65,7 +63,6 @@ class OverlayButtonsPatch : ResourcePatch {
"revanced_copy_icon_with_time.png",
"revanced_download_icon.png",
"revanced_speed_icon.png",
"revanced_whitelist_icon.png",
"yt_fill_arrow_repeat_white_24.png",
"yt_outline_arrow_repeat_1_white_24.png",
"yt_outline_arrow_shuffle_1_white_24.png",

View File

@ -1,16 +0,0 @@
package app.revanced.patches.youtube.button.whitelist.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object PlayerResponseModelFingerprint : MethodFingerprint(
returnType = "Z",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("J", "L"),
strings = listOf(
"Attempting to seek during an ad",
"currentPositionMs.",
)
)

View File

@ -1,14 +0,0 @@
package app.revanced.patches.youtube.button.whitelist.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object PlayerResponseModelParentFingerprint : MethodFingerprint(
"V", AccessFlags.PUBLIC or AccessFlags.FINAL, listOf("L"),
strings = listOf(
"setMetadata may only be called once",
"Person",
)
)

View File

@ -1,23 +0,0 @@
package app.revanced.patches.youtube.button.whitelist.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object PrimaryInjectFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf(),
opcodes = listOf(
Opcode.IF_NEZ,
Opcode.CONST_STRING,
Opcode.INVOKE_STATIC,
Opcode.RETURN_VOID,
Opcode.IGET_OBJECT
),
strings = listOf(
"play() called when the player wasn\'t loaded.",
)
)

View File

@ -1,26 +0,0 @@
package app.revanced.patches.youtube.button.whitelist.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object SecondaryInjectFingerprint : MethodFingerprint(
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.CHECK_CAST,
Opcode.INVOKE_VIRTUAL,
Opcode.GOTO,
Opcode.IPUT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT
)
)

View File

@ -1,134 +0,0 @@
package app.revanced.patches.youtube.button.whitelist.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.or
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.util.smali.toInstructions
import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.youtube.button.whitelist.fingerprint.*
import app.revanced.util.integrations.Constants.VIDEO_PATH
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference
import org.jf.dexlib2.iface.reference.MethodReference
import org.jf.dexlib2.immutable.ImmutableMethod
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
@Name("channel-whitelist")
@YouTubeCompatibility
@Version("0.0.1")
class WhitelistPatch : BytecodePatch(
listOf(
PlayerResponseModelFingerprint,
PlayerResponseModelParentFingerprint,
PrimaryInjectFingerprint,
SecondaryInjectFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
PlayerResponseModelParentFingerprint.result?.mutableMethod?.let { method ->
val instructions = method.implementation!!.instructions
val injectIndex = instructions.indexOfFirst {
it.opcode == Opcode.CONST_STRING &&
(it as BuilderInstruction21c).reference.toString() == "Person"
} + 2
fourthRef = (instructions.elementAt(injectIndex) as ReferenceInstruction).reference as DexBackedMethodReference
} ?: return PlayerResponseModelParentFingerprint.toErrorResult()
PlayerResponseModelFingerprint.result?.let { result ->
with (result.method.implementation!!.instructions) {
firstRef = (elementAt(2) as ReferenceInstruction).reference as FieldReference
secondRef = (elementAt(3) as ReferenceInstruction).reference as FieldReference
thirdRef = (elementAt(4) as ReferenceInstruction).reference as MethodReference
}
with (result.mutableClass) {
methods.add(
ImmutableMethod(
type,
"setCurrentVideoInformation",
listOf(),
"V",
AccessFlags.PRIVATE or AccessFlags.FINAL,
null,
null,
ImmutableMethodImplementation(
2, """
iget-object v0, v1, ${result.classDef.type}->${firstRef.name}:${firstRef.type}
iget-object v0, v0, ${firstRef.type}->${secondRef.name}:${secondRef.type}
invoke-interface {v0}, $thirdRef
move-result-object v0
invoke-interface {v0}, $fourthRef
move-result-object v0
invoke-static {v0}, $VIDEO_PATH/VideoInformation;->setChannelName(Ljava/lang/String;)V
return-void
""".toInstructions(), null, null
)
).toMutable()
)
}
listOf(
PrimaryInjectFingerprint,
SecondaryInjectFingerprint
).map {
it.result ?: return it.toErrorResult()
}.forEach {
val method = it.mutableMethod
val index = it.scanResult.patternScanResult!!.endIndex + 1
method.addInstruction(
index,
"invoke-direct {p0}, ${result.classDef.type}->setCurrentVideoInformation()V"
)
}
} ?: return PlayerResponseModelFingerprint.toErrorResult()
val PlayerResponseModelResult = PlayerResponseModelFingerprint.result!!
val classDef = PlayerResponseModelResult.mutableClass
classDef.methods.add(
ImmutableMethod(
classDef.type,
"setCurrentVideoInformation",
listOf(),
"V",
AccessFlags.PRIVATE or AccessFlags.FINAL,
null,
null,
ImmutableMethodImplementation(
2, """
iget-object v0, v1, ${PlayerResponseModelResult.classDef.type}->${firstRef.name}:${firstRef.type}
iget-object v0, v0, ${firstRef.type}->${secondRef.name}:${secondRef.type}
invoke-interface {v0}, $thirdRef
move-result-object v0
invoke-interface {v0}, $fourthRef
move-result-object v0
invoke-static {v0}, $VIDEO_PATH/VideoInformation;->setChannelName(Ljava/lang/String;)V
return-void
""".toInstructions(), null, null
)
).toMutable()
)
return PatchResultSuccess()
}
companion object {
private lateinit var firstRef: FieldReference
private lateinit var secondRef: FieldReference
private lateinit var thirdRef: MethodReference
private lateinit var fourthRef: DexBackedMethodReference
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yt="http://schemas.android.com/apk/res-auto" android:id="@+id/youtube_controls_bottom_ui_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layoutDirection="ltr">
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/speed_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_speed_icon" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/whitelist_button" style="@style/YouTubePlayerButton"/>
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/whitelist_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_whitelist_icon" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/copy_button" style="@style/YouTubePlayerButton"/>
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/speed_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_speed_icon" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/copy_button" style="@style/YouTubePlayerButton"/>
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/copy_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_copy_icon" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/copy_with_timestamp_button" style="@style/YouTubePlayerButton"/>
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/copy_with_timestamp_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_copy_icon_with_time" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/autoreplay_button" style="@style/YouTubePlayerButton"/>
<com.google.android.libraries.youtube.common.ui.TouchImageView android:id="@+id/autoreplay_button" android:paddingLeft="12dp" android:paddingTop="22dp" android:paddingRight="12dp" android:paddingBottom="16dp" android:longClickable="false" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/revanced_repeat_icon" android:scaleType="center" yt:layout_constraintBottom_toTopOf="@+id/quick_actions_container" yt:layout_constraintRight_toLeftOf="@+id/download_button" style="@style/YouTubePlayerButton"/>

View File

@ -471,9 +471,6 @@ Please do not report any issues you encounter while using this feature."</string
<string name="revanced_overlay_button_speed_summary_off">Speed button is hidden</string>
<string name="revanced_overlay_button_speed_summary_on">Speed button is shown</string>
<string name="revanced_overlay_button_speed_title">Show speed button</string>
<string name="revanced_overlay_button_whitelist_summary_off">Whitelist button is hidden</string>
<string name="revanced_overlay_button_whitelist_summary_on">Whitelist button is shown</string>
<string name="revanced_overlay_button_whitelist_title">Show whitelist button</string>
<string name="revanced_override_premium_header_summary_off">Current Header: Default Header</string>
<string name="revanced_override_premium_header_summary_on">Current Header: Premium Header</string>
<string name="revanced_override_premium_header_title">Premium Header</string>
@ -536,24 +533,6 @@ Since these setting is quite outdated, it may not be valid"</string>
<string name="revanced_video_ads_removal_summary_off">Video ads are shown</string>
<string name="revanced_video_ads_removal_summary_on">Video ads are hidden</string>
<string name="revanced_video_ads_removal_title">Hide video ads</string>
<string name="revanced_whitelisting_added" formatted="false">Channel %s was added to the %s whitelist</string>
<string name="revanced_whitelisting_add_failed" formatted="false">Failed to add channel %s to the %s whitelist</string>
<string name="revanced_whitelisting_ads">Video Ads</string>
<string name="revanced_whitelisting_ads_button">Ads</string>
<string name="revanced_whitelisting_channel_name">Channel Name</string>
<string name="revanced_whitelisting_empty">There are no whitelisted channels</string>
<string name="revanced_whitelisting_excluded">Not added to whitelist</string>
<string name="revanced_whitelisting_fetch_failed">Failed to retrieve channel details, received code %d</string>
<string name="revanced_whitelisting_included">Added to whitelist</string>
<string name="revanced_whitelisting_reboot">Reboot to apply channel whitelist settings</string>
<string name="revanced_whitelisting_removed" formatted="false">Channel %s was removed from the %s whitelist</string>
<string name="revanced_whitelisting_remove_failed" formatted="false">Failed to remove channel %s from the %s whitelist</string>
<string name="revanced_whitelisting_settings_summary">Check or remove the list of channels added to the whitelist</string>
<string name="revanced_whitelisting_settings_title">Whitelist settings</string>
<string name="revanced_whitelisting_speed">Video Speed</string>
<string name="revanced_whitelisting_sponsorblock">SponsorBlock</string>
<string name="revanced_whitelisting_sponsorblock_button">SB</string>
<string name="revanced_whitelisting_title">Channel Whitelist</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>

View File

@ -371,7 +371,6 @@
<PreferenceScreen android:title="@string/revanced_overlay_button" android:key="overlay_button">
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_overlay_button" />
<SwitchPreference android:title="@string/revanced_overlay_button_speed_title" android:key="revanced_overlay_button_speed" android:defaultValue="true" android:summaryOn="@string/revanced_overlay_button_speed_summary_on" android:summaryOff="@string/revanced_overlay_button_speed_summary_off" />
<SwitchPreference android:title="@string/revanced_overlay_button_whitelist_title" android:key="revanced_overlay_button_whitelist" android:defaultValue="false" android:summaryOn="@string/revanced_overlay_button_whitelist_summary_on" android:summaryOff="@string/revanced_overlay_button_whitelist_summary_off" />
<SwitchPreference android:title="@string/revanced_overlay_button_copy_url_title" android:key="revanced_overlay_button_copy_url" android:defaultValue="false" android:summaryOn="@string/revanced_overlay_button_copy_url_summary_on" android:summaryOff="@string/revanced_overlay_button_copy_url_summary_off" />
<SwitchPreference android:title="@string/revanced_overlay_button_copy_url_with_timestamp_title" android:key="revanced_overlay_button_copy_url_with_timestamp" android:defaultValue="false" android:summaryOn="@string/revanced_overlay_button_copy_url_with_timestamp_summary_on" android:summaryOff="@string/revanced_overlay_button_copy_url_with_timestamp_summary_off" />
<SwitchPreference android:title="@string/revanced_overlay_button_auto_repeat_title" android:key="revanced_overlay_button_auto_repeat" android:defaultValue="false" android:summaryOn="@string/revanced_overlay_button_auto_repeat_summary_on" android:summaryOff="@string/revanced_overlay_button_auto_repeat_summary_off" />
@ -381,9 +380,6 @@
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_downloader_settings_title" />
<EditTextPreference android:hint="ussr.razar.youtube_dl" android:title="@string/revanced_downloader_package_name_title" android:key="revanced_downloader_package_name" android:summary="@string/revanced_downloader_package_name_summary" android:inputType="text" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/revanced_whitelisting_settings_title" android:key="whitelisting" android:summary="@string/revanced_whitelisting_settings_summary">
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_whitelisting_settings_title" />
</PreferenceScreen>
</PreferenceScreen>PREFERENCE: OVERLAY_BUTTONS -->