mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 15:14:34 +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.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
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.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.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
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.injectHook
|
||||
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@ -22,7 +23,10 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
||||
listOf(PivotBarCreateButtonViewFingerprint)
|
||||
listOf(
|
||||
PivotBarCreateButtonViewFingerprint,
|
||||
PivotBarFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
@ -30,31 +34,35 @@ class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
val createButtonResult = PivotBarCreateButtonViewFingerprint.result ?: return PatchResultError("PivotBarCreateButtonViewFingerprint failed")
|
||||
val createButtonMethod = createButtonResult.mutableMethod
|
||||
val createButtonInstructions = createButtonMethod.implementation!!.instructions
|
||||
PivotBarFingerprint.result?.let { result ->
|
||||
val startIndex = result.scanResult.patternScanResult!!.startIndex
|
||||
val pivotBarInstructions = result.mutableMethod.implementation!!.instructions
|
||||
createRef = (pivotBarInstructions.elementAt(startIndex) as ReferenceInstruction).reference as DexBackedMethodReference
|
||||
} ?: return PivotBarFingerprint.toErrorResult()
|
||||
|
||||
createButtonInstructions.filter { instruction ->
|
||||
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference
|
||||
fieldReference?.let { it.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" && it.name == "c" } == true
|
||||
}.forEach { instruction ->
|
||||
if (!isSeondary) {
|
||||
isSeondary = true;
|
||||
return@forEach
|
||||
PivotBarCreateButtonViewFingerprint.result?.let { result ->
|
||||
with (result.mutableMethod){
|
||||
val createButtonInstructions = implementation!!.instructions
|
||||
createButtonInstructions.filter { instruction ->
|
||||
val fieldReference = (instruction as? ReferenceInstruction)?.reference as? DexBackedMethodReference
|
||||
fieldReference?.let { it.definingClass == createRef.definingClass && it.name == createRef.name } == true
|
||||
}.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.")
|
||||
}
|
||||
|
||||
insertIndex = createButtonInstructions.indexOf(instruction) + 2
|
||||
|
||||
/*
|
||||
* Inject hooks
|
||||
*/
|
||||
|
||||
createButtonMethod.injectHook(hook, insertIndex)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
return PatchResultError("Could not find the method to hook.")
|
||||
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
@ -63,7 +71,8 @@ class CreateButtonRemoverBytecodePatch : BytecodePatch(
|
||||
"->" +
|
||||
"hideCreateButton(Landroid/view/View;)V"
|
||||
|
||||
private var insertIndex: Int = 0
|
||||
private lateinit var createRef: DexBackedMethodReference
|
||||
|
||||
private var isSeondary: Boolean = false
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
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.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
|
@ -25,6 +25,7 @@ class SharedResourcdIdPatch : ResourcePatch {
|
||||
var educationTextViewResourceId: Long = -1
|
||||
var emptycolorLabelId: Long = -1
|
||||
var imageOnlyTabId: Long = -1
|
||||
var imageWithTextTabId: Long = -1
|
||||
var layoutCircle: Long = -1
|
||||
var layoutIcon: Long = -1
|
||||
var layoutVideo: Long = -1
|
||||
@ -47,6 +48,7 @@ class SharedResourcdIdPatch : ResourcePatch {
|
||||
educationTextViewResourceId = findSharedResourceId("id", "user_education_text_view")
|
||||
emptycolorLabelId = findSharedResourceId("color", "inline_time_bar_colorized_bar_empty_color_dark")
|
||||
imageOnlyTabId = findSharedResourceId("layout", "image_only_tab")
|
||||
imageWithTextTabId = findSharedResourceId("layout", "image_with_text_tab")
|
||||
layoutCircle = findSharedResourceId("layout", "endscreen_element_layout_circle")
|
||||
layoutIcon = findSharedResourceId("layout", "endscreen_element_layout_icon")
|
||||
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.patches.youtube.misc.swiperefresh.fingerprint.SwipeRefreshLayoutFingerprint
|
||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.shared.extensions.toErrorResult
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("enable-swipe-refresh")
|
||||
@ -23,7 +24,7 @@ class SwipeRefreshPatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val result = SwipeRefreshLayoutFingerprint.result!!
|
||||
val result = SwipeRefreshLayoutFingerprint.result ?:return SwipeRefreshLayoutFingerprint.toErrorResult()
|
||||
val method = result.mutableMethod
|
||||
val index = result.scanResult.patternScanResult!!.endIndex
|
||||
val register = (method.instruction(index) as OneRegisterInstruction).registerA
|
||||
|
Loading…
x
Reference in New Issue
Block a user