mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-09 11:04:36 +02:00
add support YouTube v18.16.37
This commit is contained in:
parent
3ab4a9ff63
commit
42a5364050
@ -15,7 +15,8 @@ import app.revanced.patcher.annotation.Package
|
||||
"18.12.35",
|
||||
"18.13.38",
|
||||
"18.14.41",
|
||||
"18.15.40"
|
||||
"18.15.40",
|
||||
"18.16.37"
|
||||
)
|
||||
)]
|
||||
)
|
||||
|
@ -10,6 +10,10 @@ import org.jf.dexlib2.Opcode
|
||||
object PivotBarCreateButtonViewFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.MOVE_OBJECT,
|
||||
Opcode.INVOKE_DIRECT_RANGE, // unique instruction anchor
|
||||
),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
|
@ -13,7 +13,7 @@ object MiniPlayerDimensionsCalculatorFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation?.instructions?.any {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.floatyBarQueueLabelId
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.floatyBarTopMarginLabelId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -1,25 +0,0 @@
|
||||
package app.revanced.patches.youtube.layout.navigation.createbutton.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
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.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 {
|
||||
it.opcode.ordinal == Opcode.CONST.ordinal &&
|
||||
(it as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.imageWithTextTabId
|
||||
} == true
|
||||
}
|
||||
)
|
@ -12,14 +12,12 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.shared.fingerprints.PivotBarCreateButtonViewFingerprint
|
||||
import app.revanced.patches.youtube.layout.navigation.createbutton.fingerprints.PivotBarFingerprint
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.NAVIGATION
|
||||
import app.revanced.util.pivotbar.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.util.pivotbar.InjectionUtils.injectHook
|
||||
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Patch
|
||||
@Name("hide-create-button")
|
||||
@ -34,57 +32,37 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
@Version("0.0.1")
|
||||
class CreateButtonRemoverPatch : BytecodePatch(
|
||||
listOf(
|
||||
PivotBarCreateButtonViewFingerprint,
|
||||
PivotBarFingerprint
|
||||
PivotBarCreateButtonViewFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
/*
|
||||
* Resolve fingerprints
|
||||
*/
|
||||
|
||||
PivotBarFingerprint.result?.let {
|
||||
val startIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val pivotBarInstructions = it.mutableMethod.implementation!!.instructions
|
||||
createRef = (pivotBarInstructions.elementAt(startIndex) as ReferenceInstruction).reference as DexBackedMethodReference
|
||||
} ?: return PivotBarFingerprint.toErrorResult()
|
||||
|
||||
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 (foundIndex == 0) {
|
||||
foundIndex++
|
||||
return@forEach
|
||||
with (result.mutableMethod) {
|
||||
val insertIndex = implementation!!.instructions.let {
|
||||
val scanStart = result.scanResult.patternScanResult!!.endIndex
|
||||
|
||||
scanStart + it.subList(scanStart, it.size - 1).indexOfFirst { instruction ->
|
||||
instruction.opcode == Opcode.INVOKE_STATIC
|
||||
}
|
||||
|
||||
/*
|
||||
* Inject hooks
|
||||
*/
|
||||
|
||||
injectHook(hook, createButtonInstructions.indexOf(instruction) + 2)
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_CREATE_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-create-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
injectHook(hook, insertIndex)
|
||||
}
|
||||
} ?: return PivotBarCreateButtonViewFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: NAVIGATION_SETTINGS",
|
||||
"SETTINGS: HIDE_CREATE_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-create-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
@ -92,9 +70,5 @@ class CreateButtonRemoverPatch : BytecodePatch(
|
||||
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $NAVIGATION" +
|
||||
"->" +
|
||||
"hideCreateButton(Landroid/view/View;)V"
|
||||
|
||||
lateinit var createRef: DexBackedMethodReference
|
||||
|
||||
var foundIndex: Int = 0
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ object PivotBarChangedFingerprint : MethodFingerprint(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT
|
||||
),
|
||||
customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;"
|
||||
customFingerprint = { it.definingClass.endsWith("PivotBar;")
|
||||
&& it.name == "onConfigurationChanged" }
|
||||
)
|
@ -11,5 +11,5 @@ object PivotBarStyleFingerprint : MethodFingerprint(
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.XOR_INT_2ADDR
|
||||
),
|
||||
customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/ui/pivotbar/PivotBar;" }
|
||||
customFingerprint = { it.definingClass.endsWith("PivotBar;") }
|
||||
)
|
@ -31,9 +31,8 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var donationCompanionResourceId: Long = -1
|
||||
var fabLabelId: Long = -1
|
||||
var filterBarHeightLabelId: Long = -1
|
||||
var floatyBarQueueLabelId: Long = -1
|
||||
var floatyBarTopMarginLabelId: Long = -1
|
||||
var imageOnlyTabId: Long = -1
|
||||
var imageWithTextTabId: Long = -1
|
||||
var layoutCircle: Long = -1
|
||||
var layoutIcon: Long = -1
|
||||
var layoutVideo: Long = -1
|
||||
@ -72,9 +71,8 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
donationCompanionResourceId = find(LAYOUT, "donation_companion")
|
||||
fabLabelId = find(ID, "fab")
|
||||
filterBarHeightLabelId = find(DIMEN, "filter_bar_height")
|
||||
floatyBarQueueLabelId = find(STRING, "floaty_bar_queue_status")
|
||||
floatyBarTopMarginLabelId = find(DIMEN, "floaty_bar_button_top_margin")
|
||||
imageOnlyTabId = find(LAYOUT, "image_only_tab")
|
||||
imageWithTextTabId = find(LAYOUT, "image_with_text_tab")
|
||||
layoutCircle = find(LAYOUT, "endscreen_element_layout_circle")
|
||||
layoutIcon = find(LAYOUT, "endscreen_element_layout_icon")
|
||||
layoutVideo = find(LAYOUT, "endscreen_element_layout_video")
|
||||
|
Loading…
x
Reference in New Issue
Block a user