mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 23:24:28 +02:00
minor improve
This commit is contained in:
parent
c71611282f
commit
be62437ab3
@ -0,0 +1,25 @@
|
|||||||
|
package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||||
|
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object PivotBarFingerprint : MethodFingerprint(
|
||||||
|
returnType = "L",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_VIRTUAL,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.RETURN_OBJECT
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef ->
|
||||||
|
methodDef.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" &&
|
||||||
|
methodDef.implementation?.instructions?.any { instruction ->
|
||||||
|
instruction.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||||
|
(instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourcdIdPatch.imageWithTextTabId
|
||||||
|
} == true
|
||||||
|
}
|
||||||
|
)
|
@ -3,17 +3,18 @@ package app.revanced.patches.youtube.layout.general.pivotbar.createbutton.byteco
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patches.youtube.layout.general.pivotbar.createbutton.bytecode.fingerprints.PivotBarCreateButtonViewFingerprint
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
|
import app.revanced.patches.youtube.layout.general.pivotbar.createbutton.bytecode.fingerprints.*
|
||||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourcdIdPatch
|
||||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
|
import app.revanced.shared.extensions.toErrorResult
|
||||||
import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
import app.revanced.shared.util.integrations.Constants.GENERAL_LAYOUT
|
||||||
import app.revanced.shared.util.pivotbar.InjectionUtils.injectHook
|
|
||||||
import app.revanced.shared.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
import app.revanced.shared.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||||
|
import app.revanced.shared.util.pivotbar.InjectionUtils.injectHook
|
||||||
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
|
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
|
|
||||||
@ -22,7 +23,10 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
|||||||
@YouTubeCompatibility
|
@YouTubeCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
||||||
listOf(PivotBarCreateButtonViewFingerprint)
|
listOf(
|
||||||
|
PivotBarCreateButtonViewFingerprint,
|
||||||
|
PivotBarFingerprint
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
@ -30,31 +34,35 @@ class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
|||||||
* Resolve fingerprints
|
* Resolve fingerprints
|
||||||
*/
|
*/
|
||||||
|
|
||||||
val createButtonResult = PivotBarCreateButtonViewFingerprint.result ?: return PatchResultError("PivotBarCreateButtonViewFingerprint failed")
|
PivotBarFingerprint.result?.let { result ->
|
||||||
val createButtonMethod = createButtonResult.mutableMethod
|
val startIndex = result.scanResult.patternScanResult!!.startIndex
|
||||||
val createButtonInstructions = createButtonMethod.implementation!!.instructions
|
val pivotBarInstructions = result.mutableMethod.implementation!!.instructions
|
||||||
|
createRef = (pivotBarInstructions.elementAt(startIndex) as ReferenceInstruction).reference as DexBackedMethodReference
|
||||||
|
} ?: return PivotBarFingerprint.toErrorResult()
|
||||||
|
|
||||||
createButtonInstructions.filter { instruction ->
|
PivotBarCreateButtonViewFingerprint.result?.let { result ->
|
||||||
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference
|
with (result.mutableMethod){
|
||||||
fieldReference?.let { it.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" && it.name == "c" } == true
|
val createButtonInstructions = implementation!!.instructions
|
||||||
}.forEach { instruction ->
|
createButtonInstructions.filter { instruction ->
|
||||||
if (!isSeondary) {
|
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference
|
||||||
isSeondary = true;
|
fieldReference?.let { it.definingClass == createRef.definingClass && it.name == createRef.name } == true
|
||||||
return@forEach
|
}.forEach { instruction ->
|
||||||
|
if (!isSeondary) {
|
||||||
|
isSeondary = true;
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inject hooks
|
||||||
|
*/
|
||||||
|
|
||||||
|
injectHook(hook, createButtonInstructions.indexOf(instruction) + 2)
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
return PatchResultError("Could not find the method to hook.")
|
||||||
}
|
}
|
||||||
|
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||||
insertIndex = createButtonInstructions.indexOf(instruction) + 2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inject hooks
|
|
||||||
*/
|
|
||||||
|
|
||||||
createButtonMethod.injectHook(hook, insertIndex)
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
|
||||||
}
|
|
||||||
|
|
||||||
return PatchResultError("Could not find the method to hook.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal companion object {
|
internal companion object {
|
||||||
@ -63,7 +71,8 @@ class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
|||||||
"->" +
|
"->" +
|
||||||
"hideCreateButton(Landroid/view/View;)V"
|
"hideCreateButton(Landroid/view/View;)V"
|
||||||
|
|
||||||
private var insertIndex: Int = 0
|
private lateinit var createRef: DexBackedMethodReference
|
||||||
|
|
||||||
private var isSeondary: Boolean = false
|
private var isSeondary: Boolean = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package app.revanced.patches.youtube.misc.doublebacktoclose.patch
|
package app.revanced.patches.youtube.misc.doublebacktoclose.patch
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Description
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
@ -25,6 +25,7 @@ class SharedResourcdIdPatch : ResourcePatch {
|
|||||||
var educationTextViewResourceId: Long = -1
|
var educationTextViewResourceId: Long = -1
|
||||||
var emptycolorLabelId: Long = -1
|
var emptycolorLabelId: Long = -1
|
||||||
var imageOnlyTabId: Long = -1
|
var imageOnlyTabId: Long = -1
|
||||||
|
var imageWithTextTabId: Long = -1
|
||||||
var layoutCircle: Long = -1
|
var layoutCircle: Long = -1
|
||||||
var layoutIcon: Long = -1
|
var layoutIcon: Long = -1
|
||||||
var layoutVideo: Long = -1
|
var layoutVideo: Long = -1
|
||||||
@ -47,6 +48,7 @@ class SharedResourcdIdPatch : ResourcePatch {
|
|||||||
educationTextViewResourceId = findSharedResourceId("id", "user_education_text_view")
|
educationTextViewResourceId = findSharedResourceId("id", "user_education_text_view")
|
||||||
emptycolorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
emptycolorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
||||||
imageOnlyTabId = findSharedResourceId("layout", "image_only_tab")
|
imageOnlyTabId = findSharedResourceId("layout", "image_only_tab")
|
||||||
|
imageWithTextTabId = findSharedResourceId("layout", "image_with_text_tab")
|
||||||
layoutCircle = findSharedResourceId("layout", "endscreen_element_layout_circle")
|
layoutCircle = findSharedResourceId("layout", "endscreen_element_layout_circle")
|
||||||
layoutIcon = findSharedResourceId("layout", "endscreen_element_layout_icon")
|
layoutIcon = findSharedResourceId("layout", "endscreen_element_layout_icon")
|
||||||
layoutVideo = findSharedResourceId("layout", "endscreen_element_layout_video")
|
layoutVideo = findSharedResourceId("layout", "endscreen_element_layout_video")
|
||||||
|
@ -11,6 +11,7 @@ import app.revanced.patcher.patch.PatchResult
|
|||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patches.youtube.misc.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint
|
import app.revanced.patches.youtube.misc.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint
|
||||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
|
import app.revanced.shared.extensions.toErrorResult
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Name("enable-swipe-refresh")
|
@Name("enable-swipe-refresh")
|
||||||
@ -23,7 +24,7 @@ class SwipeRefreshPatch : BytecodePatch(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
val result = SwipeRefreshLayoutFingerprint.result!!
|
val result = SwipeRefreshLayoutFingerprint.result ?:return SwipeRefreshLayoutFingerprint.toErrorResult()
|
||||||
val method = result.mutableMethod
|
val method = result.mutableMethod
|
||||||
val index = result.scanResult.patternScanResult!!.endIndex
|
val index = result.scanResult.patternScanResult!!.endIndex
|
||||||
val register = (method.instruction(index) as OneRegisterInstruction).registerA
|
val register = (method.instruction(index) as OneRegisterInstruction).registerA
|
||||||
|
Loading…
x
Reference in New Issue
Block a user