mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 17:14:35 +02:00
chore: Lint code
This commit is contained in:
parent
dc0a5973ad
commit
a353a48aa3
@ -179,7 +179,8 @@ val sponsorBlockPatch = resourcePatch(
|
||||
val tags = document.getElementsByTagName(PREFERENCE_SCREEN_TAG_NAME)
|
||||
List(tags.length) { tags.item(it) as Element }
|
||||
.filter {
|
||||
it.getAttribute("android:key").contains("revanced_preference_screen_$category")
|
||||
it.getAttribute("android:key")
|
||||
.contains("revanced_preference_screen_$category")
|
||||
}
|
||||
.forEach {
|
||||
it.adoptChild(SWITCH_PREFERENCE_TAG_NAME) {
|
||||
@ -210,7 +211,8 @@ val sponsorBlockPatch = resourcePatch(
|
||||
val tags = document.getElementsByTagName(PREFERENCE_SCREEN_TAG_NAME)
|
||||
List(tags.length) { tags.item(it) as Element }
|
||||
.filter {
|
||||
it.getAttribute("android:key").contains("revanced_preference_screen_$category")
|
||||
it.getAttribute("android:key")
|
||||
.contains("revanced_preference_screen_$category")
|
||||
}
|
||||
.forEach {
|
||||
it.adoptChild("Preference") {
|
||||
|
@ -114,7 +114,8 @@ val adsPatch = bytecodePatch(
|
||||
// AdElementConverter is conveniently responsible for inserting all feed ads.
|
||||
// By removing the appending instruction no ad posts gets appended to the feed.
|
||||
newAdPostFingerprint.methodOrThrow().apply {
|
||||
val stringIndex = indexOfFirstStringInstructionOrThrow("android_feed_freeform_render_variant")
|
||||
val stringIndex =
|
||||
indexOfFirstStringInstructionOrThrow("android_feed_freeform_render_variant")
|
||||
val targetIndex = indexOfFirstInstructionOrThrow(stringIndex) {
|
||||
opcode == Opcode.INVOKE_VIRTUAL
|
||||
&& getReference<MethodReference>()?.toString() == "Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z"
|
||||
|
@ -24,7 +24,9 @@ val recommendedCommunitiesPatch = bytecodePatch(
|
||||
dependsOn(settingsPatch)
|
||||
|
||||
execute {
|
||||
communityRecommendationSectionFingerprint.methodOrThrow(communityRecommendationSectionParentFingerprint).apply {
|
||||
communityRecommendationSectionFingerprint.methodOrThrow(
|
||||
communityRecommendationSectionParentFingerprint
|
||||
).apply {
|
||||
addInstructionsWithLabels(
|
||||
0,
|
||||
"""
|
||||
|
@ -39,28 +39,30 @@ val navigationButtonsPatch = bytecodePatch(
|
||||
}
|
||||
|
||||
if (bottomNavScreenFingerprint.resolvable()) {
|
||||
val bottomNavScreenMutableClass = with (bottomNavScreenFingerprint.methodOrThrow()) {
|
||||
val bottomNavScreenMutableClass = with(bottomNavScreenFingerprint.methodOrThrow()) {
|
||||
val startIndex = indexOfGetDimensionPixelSizeInstruction(this)
|
||||
val targetIndex = indexOfFirstInstructionOrThrow(startIndex, Opcode.NEW_INSTANCE)
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
|
||||
val targetReference =
|
||||
getInstruction<ReferenceInstruction>(targetIndex).reference.toString()
|
||||
|
||||
classBy { it.type == targetReference }
|
||||
?.mutableClass
|
||||
?: throw ClassNotFoundException("Failed to find class $targetReference")
|
||||
}
|
||||
|
||||
bottomNavScreenOnGlobalLayoutFingerprint.second.matchOrNull(bottomNavScreenMutableClass)?.let {
|
||||
it.method.apply {
|
||||
val startIndex = it.patternMatch!!.startIndex
|
||||
val targetRegister =
|
||||
getInstruction<FiveRegisterInstruction>(startIndex).registerC
|
||||
bottomNavScreenOnGlobalLayoutFingerprint.second.matchOrNull(bottomNavScreenMutableClass)
|
||||
?.let {
|
||||
it.method.apply {
|
||||
val startIndex = it.patternMatch!!.startIndex
|
||||
val targetRegister =
|
||||
getInstruction<FiveRegisterInstruction>(startIndex).registerC
|
||||
|
||||
addInstruction(
|
||||
startIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $EXTENSION_CLASS_DESCRIPTOR->hideNavigationButtons(Landroid/view/ViewGroup;)V"
|
||||
)
|
||||
addInstruction(
|
||||
startIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $EXTENSION_CLASS_DESCRIPTOR->hideNavigationButtons(Landroid/view/ViewGroup;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Legacy method.
|
||||
bottomNavScreenHandlerFingerprint.methodOrThrow().apply {
|
||||
|
@ -31,15 +31,18 @@ val recentlyVisitedShelfPatch = bytecodePatch(
|
||||
|
||||
execute {
|
||||
|
||||
val recentlyVisitedReference = with (communityDrawerPresenterConstructorFingerprint.methodOrThrow()) {
|
||||
val recentlyVisitedFieldIndex = indexOfHeaderItemInstruction(this)
|
||||
val recentlyVisitedObjectIndex =
|
||||
indexOfFirstInstructionOrThrow(recentlyVisitedFieldIndex, Opcode.IPUT_OBJECT)
|
||||
val recentlyVisitedReference =
|
||||
with(communityDrawerPresenterConstructorFingerprint.methodOrThrow()) {
|
||||
val recentlyVisitedFieldIndex = indexOfHeaderItemInstruction(this)
|
||||
val recentlyVisitedObjectIndex =
|
||||
indexOfFirstInstructionOrThrow(recentlyVisitedFieldIndex, Opcode.IPUT_OBJECT)
|
||||
|
||||
getInstruction<ReferenceInstruction>(recentlyVisitedObjectIndex).reference.toString()
|
||||
}
|
||||
getInstruction<ReferenceInstruction>(recentlyVisitedObjectIndex).reference.toString()
|
||||
}
|
||||
|
||||
communityDrawerPresenterFingerprint.methodOrThrow(communityDrawerPresenterConstructorFingerprint).apply {
|
||||
communityDrawerPresenterFingerprint.methodOrThrow(
|
||||
communityDrawerPresenterConstructorFingerprint
|
||||
).apply {
|
||||
val recentlyVisitedObjectIndex =
|
||||
indexOfFirstInstructionOrThrow {
|
||||
(this as? ReferenceInstruction)?.reference?.toString() == recentlyVisitedReference
|
||||
|
@ -19,7 +19,8 @@ internal val customReportsFingerprint = legacyFingerprint(
|
||||
|
||||
fun indexOfScreenNavigatorInstruction(method: Method) =
|
||||
method.indexOfFirstInstruction {
|
||||
(this as? ReferenceInstruction)?.reference?.toString()?.contains("Landroid/app/Activity;Landroid/net/Uri;") == true
|
||||
(this as? ReferenceInstruction)?.reference?.toString()
|
||||
?.contains("Landroid/app/Activity;Landroid/net/Uri;") == true
|
||||
}
|
||||
|
||||
internal val screenNavigatorFingerprint = legacyFingerprint(
|
||||
|
@ -9,7 +9,6 @@ import app.revanced.patches.reddit.utils.extension.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.reddit.utils.patch.PatchList.OPEN_LINKS_EXTERNALLY
|
||||
import app.revanced.patches.reddit.utils.settings.settingsPatch
|
||||
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
|
||||
import app.revanced.util.fingerprint.methodOrThrow
|
||||
import app.revanced.util.indexOfFirstStringInstructionOrThrow
|
||||
|
||||
private const val EXTENSION_METHOD_DESCRIPTOR =
|
||||
|
@ -12,10 +12,10 @@ val screenNavigatorMethodResolverPatch = bytecodePatch(
|
||||
) {
|
||||
execute {
|
||||
screenNavigatorMethod =
|
||||
// ~ Reddit 2024.25.3
|
||||
// ~ Reddit 2024.25.3
|
||||
screenNavigatorFingerprint.second.methodOrNull
|
||||
// Reddit 2024.26.1 ~
|
||||
?: with (customReportsFingerprint.methodOrThrow()) {
|
||||
// Reddit 2024.26.1 ~
|
||||
?: with(customReportsFingerprint.methodOrThrow()) {
|
||||
getWalkerMethod(indexOfScreenNavigatorInstruction(this))
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ private val settingsBytecodePatch = bytecodePatch(
|
||||
&& (this as? BuilderInstruction21c)?.reference.toString().startsWith("202")
|
||||
}
|
||||
|
||||
val versionNumber = getInstruction<BuilderInstruction21c>(versionIndex).reference.toString().replace(".", "").toInt()
|
||||
val versionNumber =
|
||||
getInstruction<BuilderInstruction21c>(versionIndex).reference.toString()
|
||||
.replace(".", "").toInt()
|
||||
|
||||
is_2024_18_or_greater = 2024180 <= versionNumber
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ fun baseSpoofStreamingDataPatch(
|
||||
// region Replace the streaming data.
|
||||
|
||||
val approxDurationMsFieldName = formatStreamModelConstructorFingerprint.matchOrThrow().let {
|
||||
with (it.method) {
|
||||
with(it.method) {
|
||||
val approxDurationMsFieldIndex = it.patternMatch!!.startIndex
|
||||
(getInstruction<ReferenceInstruction>(approxDurationMsFieldIndex).reference as FieldReference).name
|
||||
}
|
||||
|
@ -80,8 +80,10 @@ val shortsActionButtonsPatch = resourcePatch(
|
||||
val fromPath = res.resolve(fromFile).toPath()
|
||||
val toFile = "$drawableDirectory/$toFileName.webp"
|
||||
val toPath = res.resolve(toFile).toPath()
|
||||
val inputStreamForLegacy = inputStreamFromBundledResourceOrThrow(sourceResourceDirectory, fromFile)
|
||||
val inputStreamForNew = inputStreamFromBundledResourceOrThrow(sourceResourceDirectory, fromFile)
|
||||
val inputStreamForLegacy =
|
||||
inputStreamFromBundledResourceOrThrow(sourceResourceDirectory, fromFile)
|
||||
val inputStreamForNew =
|
||||
inputStreamFromBundledResourceOrThrow(sourceResourceDirectory, fromFile)
|
||||
|
||||
Files.copy(inputStreamForLegacy, fromPath, StandardCopyOption.REPLACE_EXISTING)
|
||||
|
||||
|
@ -178,7 +178,8 @@ val customBrandingIconPatch = resourcePatch(
|
||||
}
|
||||
|
||||
document("res/values/styles.xml").use { document ->
|
||||
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||
val resourcesNode =
|
||||
document.getElementsByTagName("resources").item(0) as Element
|
||||
val childNodes = resourcesNode.childNodes
|
||||
|
||||
for (i in 0 until childNodes.length) {
|
||||
@ -205,7 +206,8 @@ val customBrandingIconPatch = resourcePatch(
|
||||
}
|
||||
|
||||
val styleMap = mutableMapOf<String, String>()
|
||||
styleMap["Base.Theme.YouTube.Launcher"] = "@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
styleMap["Base.Theme.YouTube.Launcher"] =
|
||||
"@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
|
||||
if (is_19_32_or_greater) {
|
||||
styleMap["Theme.YouTube.Home"] = "@style/Base.V27.Theme.YouTube.Home"
|
||||
@ -213,7 +215,8 @@ val customBrandingIconPatch = resourcePatch(
|
||||
|
||||
styleMap.forEach { (nodeAttributeName, nodeAttributeParent) ->
|
||||
document("res/values-v31/styles.xml").use { document ->
|
||||
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||
val resourcesNode =
|
||||
document.getElementsByTagName("resources").item(0) as Element
|
||||
|
||||
val style = document.createElement("style")
|
||||
style.setAttribute("name", nodeAttributeName)
|
||||
@ -223,7 +226,10 @@ val customBrandingIconPatch = resourcePatch(
|
||||
primaryItem.setAttribute("name", "android:windowSplashScreenAnimatedIcon")
|
||||
primaryItem.textContent = "@drawable/avd_anim"
|
||||
val secondaryItem = document.createElement("item")
|
||||
secondaryItem.setAttribute("name", "android:windowSplashScreenAnimationDuration")
|
||||
secondaryItem.setAttribute(
|
||||
"name",
|
||||
"android:windowSplashScreenAnimationDuration"
|
||||
)
|
||||
secondaryItem.textContent = if (appIcon.startsWith("revancify"))
|
||||
"1500"
|
||||
else
|
||||
|
@ -67,6 +67,7 @@ val sharedThemePatch = resourcePatch(
|
||||
1 -> when (nodeAttributeName) {
|
||||
"Base.Theme.YouTube.Launcher",
|
||||
"Base.Theme.YouTube.Launcher.Cairo" -> SPLASH_SCREEN_COLOR_ATTRIBUTE
|
||||
|
||||
else -> "null"
|
||||
}
|
||||
|
||||
@ -115,7 +116,8 @@ val sharedThemePatch = resourcePatch(
|
||||
return@editSplashScreen
|
||||
}
|
||||
document("res/$drawable/$fileName.xml").use { document ->
|
||||
val layerList = document.getElementsByTagName("layer-list").item(0) as Element
|
||||
val layerList =
|
||||
document.getElementsByTagName("layer-list").item(0) as Element
|
||||
|
||||
val childNodes = layerList.childNodes
|
||||
for (i in 0 until childNodes.length) {
|
||||
|
@ -169,7 +169,8 @@ val playerButtonsPatch = bytecodePatch(
|
||||
|
||||
if (is_19_34_or_greater) {
|
||||
layoutConstructorFingerprint.methodOrThrow().apply {
|
||||
val resourceIndex = indexOfFirstLiteralInstructionOrThrow(playerControlPreviousButtonTouchArea)
|
||||
val resourceIndex =
|
||||
indexOfFirstLiteralInstructionOrThrow(playerControlPreviousButtonTouchArea)
|
||||
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(resourceIndex) {
|
||||
opcode == Opcode.INVOKE_STATIC &&
|
||||
|
@ -16,8 +16,8 @@ import app.revanced.patches.youtube.utils.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.playservice.is_18_49_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_02_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverHook
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.rollingNumberTextViewAnimationUpdateFingerprint
|
||||
import app.revanced.patches.youtube.utils.rollingNumberTextViewFingerprint
|
||||
|
@ -37,8 +37,8 @@ import app.revanced.patches.youtube.utils.playservice.is_19_25_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_28_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_34_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverHook
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.bottomBarContainer
|
||||
import app.revanced.patches.youtube.utils.resourceid.metaPanel
|
||||
import app.revanced.patches.youtube.utils.resourceid.reelDynRemix
|
||||
|
@ -165,10 +165,22 @@ val swipeControlsPatch = bytecodePatch(
|
||||
reference.parameterTypes.size == 0
|
||||
}
|
||||
if (getInstruction(targetIndex - 1).opcode != Opcode.IGET_OBJECT) {
|
||||
throw PatchException("Previous Opcode pattern does not match: ${getInstruction(targetIndex - 1).opcode}")
|
||||
throw PatchException(
|
||||
"Previous Opcode pattern does not match: ${
|
||||
getInstruction(
|
||||
targetIndex - 1
|
||||
).opcode
|
||||
}"
|
||||
)
|
||||
}
|
||||
if (getInstruction(targetIndex + 1).opcode != Opcode.IF_EQZ) {
|
||||
throw PatchException("Next Opcode pattern does not match: ${getInstruction(targetIndex + 1).opcode}")
|
||||
throw PatchException(
|
||||
"Next Opcode pattern does not match: ${
|
||||
getInstruction(
|
||||
targetIndex + 1
|
||||
).opcode
|
||||
}"
|
||||
)
|
||||
}
|
||||
val fieldReference = getInstruction<ReferenceInstruction>(targetIndex - 1).reference
|
||||
val fieldInstruction = getInstruction<TwoRegisterInstruction>(targetIndex - 1)
|
||||
|
@ -67,7 +67,12 @@ internal val layoutConstructorFingerprint = legacyFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
strings = listOf("1.0x"),
|
||||
literals = listOf(autoNavToggle, autoNavPreviewStub, playerControlPreviousButtonTouchArea, playerControlNextButtonTouchArea),
|
||||
literals = listOf(
|
||||
autoNavToggle,
|
||||
autoNavPreviewStub,
|
||||
playerControlPreviousButtonTouchArea,
|
||||
playerControlNextButtonTouchArea
|
||||
),
|
||||
)
|
||||
|
||||
internal val playbackRateBottomSheetBuilderFingerprint = legacyFingerprint(
|
||||
|
@ -5,7 +5,6 @@ import app.revanced.patches.youtube.misc.backgroundplayback.backgroundPlaybackPa
|
||||
import app.revanced.patches.youtube.utils.playservice.is_19_04_or_greater
|
||||
import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
|
||||
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
|
||||
import app.revanced.util.fingerprint.resolvable
|
||||
|
||||
val cairoSettingsPatch = bytecodePatch(
|
||||
description = "cairoSettingsPatch"
|
||||
|
@ -45,7 +45,8 @@ val playbackSpeedWhilePlayingPatch = bytecodePatch(
|
||||
playbackSpeedInFeedsFingerprint.methodOrThrow().apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
val playbackSpeedIndex = indexOfGetPlaybackSpeedInstruction(this)
|
||||
val playbackSpeedRegister = getInstruction<TwoRegisterInstruction>(playbackSpeedIndex).registerA
|
||||
val playbackSpeedRegister =
|
||||
getInstruction<TwoRegisterInstruction>(playbackSpeedIndex).registerA
|
||||
val jumpIndex = indexOfFirstInstructionOrThrow(playbackSpeedIndex, Opcode.RETURN_VOID)
|
||||
|
||||
addInstructionsWithLabels(
|
||||
|
@ -19,8 +19,8 @@ import app.revanced.patches.youtube.utils.flyoutmenu.flyoutMenuHookPatch
|
||||
import app.revanced.patches.youtube.utils.patch.PatchList.VIDEO_PLAYBACK
|
||||
import app.revanced.patches.youtube.utils.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.qualityMenuViewInflateFingerprint
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverPatch
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverHook
|
||||
import app.revanced.patches.youtube.utils.recyclerview.recyclerViewTreeObserverPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
|
||||
import app.revanced.patches.youtube.utils.settings.settingsPatch
|
||||
|
@ -123,7 +123,8 @@ fun ResourcePatchContext.copyAdaptiveIcon(
|
||||
}
|
||||
|
||||
if (adaptiveIconMonoChromeFileName != null &&
|
||||
adaptiveIconMonoChromeFileName != getAdaptiveIconMonoChromeResourceFile()) {
|
||||
adaptiveIconMonoChromeFileName != getAdaptiveIconMonoChromeResourceFile()
|
||||
) {
|
||||
val drawableDirectory = get("res").resolve("drawable")
|
||||
Files.copy(
|
||||
drawableDirectory
|
||||
|
Loading…
x
Reference in New Issue
Block a user