mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
feat(YouTube): add Change start page
patch
This commit is contained in:
@ -0,0 +1,78 @@
|
||||
package app.revanced.patches.youtube.general.startpage
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.general.startpage.fingerprints.StartActivityFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch.contexts
|
||||
import app.revanced.util.copyXmlNode
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Change start page",
|
||||
description = "Changes the start page of the app.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
[
|
||||
"18.25.40",
|
||||
"18.27.36",
|
||||
"18.29.38",
|
||||
"18.30.37",
|
||||
"18.31.40",
|
||||
"18.32.39",
|
||||
"18.33.40",
|
||||
"18.34.38",
|
||||
"18.35.36",
|
||||
"18.36.39",
|
||||
"18.37.36",
|
||||
"18.38.44",
|
||||
"18.39.41",
|
||||
"18.40.34",
|
||||
"18.41.39",
|
||||
"18.42.41",
|
||||
"18.43.45",
|
||||
"18.44.41",
|
||||
"18.45.43"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object ChangeStartPagePatch : BytecodePatch(
|
||||
setOf(StartActivityFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
StartActivityFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
addInstruction(
|
||||
0,
|
||||
"invoke-static { p1 }, $GENERAL->changeStartPage(Landroid/content/Intent;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw StartActivityFingerprint.exception
|
||||
|
||||
/**
|
||||
* Copy arrays
|
||||
*/
|
||||
contexts.copyXmlNode("youtube/startpage/host", "values/arrays.xml", "resources")
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: GENERAL_SETTINGS",
|
||||
"SETTINGS: CHANGE_START_PAGE"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("Change start page")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.youtube.general.startpage.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
object StartActivityFingerprint : MethodFingerprint(
|
||||
parameters = listOf("Landroid/content/Intent;"),
|
||||
customFingerprint = { methodDef, classDef ->
|
||||
methodDef.name == "startActivity"
|
||||
&& classDef.type.endsWith("/Shell_HomeActivity;")
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user