mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-07 18:03:55 +01:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebc4a12cd7 | ||
|
|
b3c0291e70 | ||
|
|
c43588ee40 | ||
|
|
c74b5d4e47 | ||
|
|
91ae954210 | ||
|
|
65172cad4f | ||
|
|
c2122494bc | ||
|
|
6ed94935ca | ||
|
|
a934821fa7 | ||
|
|
f3785c4e47 | ||
|
|
67e0db5ac9 | ||
|
|
aaa820430b | ||
|
|
cf5ed1baea | ||
|
|
206341cec4 | ||
|
|
e8f4890edd | ||
|
|
9463f11dbf | ||
|
|
2b3e153b60 | ||
|
|
4b6bf69366 | ||
|
|
38e8e7898b | ||
|
|
3175e864af | ||
|
|
d320dd4e58 | ||
|
|
f5ae96defb | ||
|
|
bfe3876cea | ||
|
|
3ad2c42a53 | ||
|
|
0d22fc2d2f | ||
|
|
6e6dbd0c1a | ||
|
|
4272fade4f | ||
|
|
2095e34db8 | ||
|
|
1483a9d8bb |
74
CHANGELOG.md
74
CHANGELOG.md
@@ -1,3 +1,77 @@
|
||||
# [2.116.0](https://github.com/revanced/revanced-patches/compare/v2.115.0...v2.116.0) (2022-11-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/theme:** make amoled the default color for dark theme background" ([2b68ac7](https://github.com/revanced/revanced-patches/commit/2b68ac7796e54ed07c697909a84b3847f4ed7f01))
|
||||
|
||||
# [2.115.0](https://github.com/revanced/revanced-patches/compare/v2.114.2...v2.115.0) (2022-11-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/general-ads:** normalize switch names ([7636180](https://github.com/revanced/revanced-patches/commit/763618002ab6ccd9cd23889275c0e9b23642763e))
|
||||
* **youtube/theme:** exclude the patch by default ([57358ed](https://github.com/revanced/revanced-patches/commit/57358edc4cf3ae6b05cfb51359f66fc94c71cb5c))
|
||||
* **youtube/theme:** make dark the default color for dark theme background ([db44fa6](https://github.com/revanced/revanced-patches/commit/db44fa6f5adad19384970dad58784b2bf5fe1007))
|
||||
|
||||
## [2.114.2](https://github.com/revanced/revanced-patches/compare/v2.114.1...v2.114.2) (2022-11-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/general-ads:** hide bytecode home ad view ([4976ad4](https://github.com/revanced/revanced-patches/commit/4976ad44b1867c93e976d91075b5bcead8d69c90))
|
||||
* **youtube/general-ads:** remove unused switch ([43cddcc](https://github.com/revanced/revanced-patches/commit/43cddcc85830524cd88d87ae1178f11451f158d8))
|
||||
|
||||
## [2.114.1](https://github.com/revanced/revanced-patches/compare/v2.114.0...v2.114.1) (2022-11-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **tiktok/settings:** make compatible with newer versions ([#1057](https://github.com/revanced/revanced-patches/issues/1057)) ([e1d5d64](https://github.com/revanced/revanced-patches/commit/e1d5d6492ed660f43c87c796a59e766ea6b8ead0))
|
||||
|
||||
# [2.114.0](https://github.com/revanced/revanced-patches/compare/v2.113.0...v2.114.0) (2022-11-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube:** `disable-zoom-haptics` patch ([#1079](https://github.com/revanced/revanced-patches/issues/1079)) ([a7cfba5](https://github.com/revanced/revanced-patches/commit/a7cfba54fbb3ee0ee5511a45d0b3c4620eb0c861))
|
||||
|
||||
# [2.113.0](https://github.com/revanced/revanced-patches/compare/v2.112.0...v2.113.0) (2022-11-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/general-ads:** hide ads with buttons ([97fd3fd](https://github.com/revanced/revanced-patches/commit/97fd3fda79ff4bb2fadd0e6c4aa80b96d71f46da))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **youtube/general-ads:** custom component filter ([b5e81d0](https://github.com/revanced/revanced-patches/commit/b5e81d0eaff3ab67a59ccd45eac6bf9414ed1380))
|
||||
* **youtube/general-ads:** hide gray separators ([59693f0](https://github.com/revanced/revanced-patches/commit/59693f007192c195258cea3a222d7fb94b6385c2))
|
||||
|
||||
# [2.112.0](https://github.com/revanced/revanced-patches/compare/v2.111.3...v2.112.0) (2022-11-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **anytracker:** `unlock-premium` patch ([#1076](https://github.com/revanced/revanced-patches/issues/1076)) ([52b3d90](https://github.com/revanced/revanced-patches/commit/52b3d909bbe59dafaea0cb9da1c27bdd0cda502f))
|
||||
|
||||
## [2.111.3](https://github.com/revanced/revanced-patches/compare/v2.111.2...v2.111.3) (2022-11-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/litho-filter:** use correct type for switch case ([#1068](https://github.com/revanced/revanced-patches/issues/1068)) ([ab03511](https://github.com/revanced/revanced-patches/commit/ab03511e23d07c7c40b58eae5791fb2a798289de))
|
||||
|
||||
## [2.111.2](https://github.com/revanced/revanced-patches/compare/v2.111.1...v2.111.2) (2022-11-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **youtube/general-ads:** import correct compatibility annotation ([#1065](https://github.com/revanced/revanced-patches/issues/1065)) ([db2085c](https://github.com/revanced/revanced-patches/commit/db2085c217311a8b7d45a01c03c6162bc60a9298))
|
||||
|
||||
## [2.111.1](https://github.com/revanced/revanced-patches/compare/v2.111.0...v2.111.1) (2022-11-18)
|
||||
|
||||
# [2.111.0](https://github.com/revanced/revanced-patches/compare/v2.110.0...v2.111.0) (2022-11-15)
|
||||
|
||||
|
||||
|
||||
13
README.md
13
README.md
@@ -21,7 +21,7 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `tiktok-speed` | Enables the playback speed option for all videos. | all |
|
||||
| `tiktok-download` | Removes download restrictions and changes the default path to download to. | all |
|
||||
| `tiktok-seekbar` | Show progress bar for all video. | all |
|
||||
| `tiktok-settings` | Add settings menu to TikTok. | all |
|
||||
| `settings` | Adds settings for ReVanced to TikTok. | all |
|
||||
| `tiktok-force-login` | Do not force login. | all |
|
||||
| `tiktok-feed-filter` | Filters tiktok videos: removing ads, removing livestreams. | all |
|
||||
</details>
|
||||
@@ -35,7 +35,7 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `tiktok-speed` | Enables the playback speed option for all videos. | all |
|
||||
| `tiktok-download` | Removes download restrictions and changes the default path to download to. | all |
|
||||
| `tiktok-seekbar` | Show progress bar for all video. | all |
|
||||
| `tiktok-settings` | Add settings menu to TikTok. | all |
|
||||
| `settings` | Adds settings for ReVanced to TikTok. | all |
|
||||
| `tiktok-force-login` | Do not force login. | all |
|
||||
| `tiktok-feed-filter` | Filters tiktok videos: removing ads, removing livestreams. | all |
|
||||
</details>
|
||||
@@ -115,6 +115,7 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `swipe-controls` | Adds volume and brightness swipe controls. | 17.43.36 |
|
||||
| `downloads` | Enables downloading music and videos from YouTube. | 17.43.36 |
|
||||
| `seekbar-tapping` | Enables tap-to-seek on the seekbar of the video player. | 17.43.36 |
|
||||
| `disable-zoom-haptics` | Disables haptics when zooming. | all |
|
||||
| `settings` | Adds settings for ReVanced to YouTube. | all |
|
||||
| `open-links-directly` | Bypasses redirect links and allows opening links directly. | 17.43.36 |
|
||||
| `microg-support` | Allows YouTube ReVanced to run without root and under a different package name with Vanced MicroG. | 17.43.36 |
|
||||
@@ -144,6 +145,14 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `unlock-themes` | Unlocks all themes. | all |
|
||||
</details>
|
||||
|
||||
### 📦 `com.shervinkoushan.anyTracker`
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-premium` | Unlocks all premium features. | all |
|
||||
</details>
|
||||
|
||||
### 📦 `tv.twitch.android.app`
|
||||
<details>
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("app.revanced:revanced-patcher:6.0.0")
|
||||
implementation("app.revanced:revanced-patcher:6.0.2")
|
||||
implementation("app.revanced:multidexlib2:2.5.2.r2")
|
||||
// Required for meta
|
||||
implementation("com.google.code.gson:gson:2.9.1")
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 2.111.0
|
||||
version = 2.116.0
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.misc.mapping.patch
|
||||
package app.revanced.patches.shared.mapping.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
@@ -16,7 +16,7 @@ import java.util.concurrent.TimeUnit
|
||||
@Name("resource-mapping")
|
||||
@Description("Creates a map of public resources.")
|
||||
@Version("0.0.1")
|
||||
class ResourceMappingResourcePatch : ResourcePatch {
|
||||
class ResourceMappingPatch : ResourcePatch {
|
||||
companion object {
|
||||
internal lateinit var resourceMappings: List<ResourceElement>
|
||||
private set
|
||||
@@ -14,7 +14,7 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility
|
||||
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabFingerprint
|
||||
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabParentFingerprint
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
@Description("Removes the premium tab from the navbar.")
|
||||
@PremiumNavbarTabCompatibility
|
||||
@Version("0.0.1")
|
||||
@DependsOn([ResourceMappingResourcePatch::class])
|
||||
@DependsOn([ResourceMappingPatch::class])
|
||||
class PremiumNavbarTabPatch : BytecodePatch(
|
||||
listOf(
|
||||
AddPremiumNavbarTabParentFingerprint
|
||||
@@ -40,7 +40,7 @@ class PremiumNavbarTabPatch : BytecodePatch(
|
||||
val lastInstructionIdx = methodInstructions.size - 1
|
||||
|
||||
val premiumTabId =
|
||||
ResourceMappingResourcePatch.resourceMappings.single { it.type == "id" && it.name == "premium_tab" }.id
|
||||
ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "premium_tab" }.id
|
||||
|
||||
var removeAmount = 2
|
||||
// 2nd const remove method
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.revanced.patches.tiktok.misc.settings.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility
|
||||
|
||||
@Name("about-onclick-method-fingerprint")
|
||||
@TikTokSettingsCompatibility
|
||||
@Version("0.0.1")
|
||||
object AboutOnClickMethodFingerprint : MethodFingerprint(
|
||||
strings = listOf(
|
||||
"//setting/about",
|
||||
"enter_from",
|
||||
"settings_page",
|
||||
"enter_settings_about"
|
||||
)
|
||||
)
|
||||
@@ -5,10 +5,10 @@ import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility
|
||||
|
||||
@Name("ad-personalization-activity-fingerprint")
|
||||
@Name("ad-personalization-activity-on-create-fingerprint")
|
||||
@TikTokSettingsCompatibility
|
||||
@Version("0.0.1")
|
||||
object AdPersonalizationActivityFingerprint : MethodFingerprint(
|
||||
object AdPersonalizationActivityOnCreateFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.definingClass.endsWith("/AdPersonalizationActivity;") &&
|
||||
methodDef.name == "onCreate"
|
||||
@@ -8,7 +8,7 @@ import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompa
|
||||
@Name("copyright-settings-string-fingerprint")
|
||||
@TikTokSettingsCompatibility
|
||||
@Version("0.0.1")
|
||||
object CopyRightSettingsStringFingerprint : MethodFingerprint(
|
||||
object SettingsOnViewCreatedFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.definingClass.endsWith("/SettingNewVersionFragment;") &&
|
||||
methodDef.name == "onViewCreated"
|
||||
@@ -5,6 +5,7 @@ import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.extensions.replaceInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
@@ -14,85 +15,111 @@ import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch
|
||||
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility
|
||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityFingerprint
|
||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.CopyRightSettingsStringFingerprint
|
||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.AboutOnClickMethodFingerprint
|
||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.AdPersonalizationActivityOnCreateFingerprint
|
||||
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsOnViewCreatedFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
import org.jf.dexlib2.iface.reference.TypeReference
|
||||
|
||||
@Patch
|
||||
@DependsOn([TikTokIntegrationsPatch::class])
|
||||
@Name("tiktok-settings")
|
||||
@Description("Add settings menu to TikTok.")
|
||||
@Name("settings")
|
||||
@Description("Adds settings for ReVanced to TikTok.")
|
||||
@TikTokSettingsCompatibility
|
||||
@Version("0.0.1")
|
||||
class TikTokSettingsPatch : BytecodePatch(
|
||||
listOf(
|
||||
AdPersonalizationActivityFingerprint,
|
||||
CopyRightSettingsStringFingerprint
|
||||
AdPersonalizationActivityOnCreateFingerprint,
|
||||
SettingsOnViewCreatedFingerprint,
|
||||
AboutOnClickMethodFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
//Replace string `Copyright Policy` to 'Revanced Settings` in TikTok settings.
|
||||
val method1 = CopyRightSettingsStringFingerprint.result!!.mutableMethod
|
||||
val implementation1 = method1.implementation!!
|
||||
for ((index, instruction) in implementation1.instructions.withIndex()) {
|
||||
if (instruction.opcode != Opcode.CONST_STRING) continue
|
||||
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
||||
if (string != "copyright_policy") continue
|
||||
var targetIndex = index
|
||||
while (targetIndex >= 0) {
|
||||
targetIndex--
|
||||
val invokeInstruction = implementation1.instructions[targetIndex]
|
||||
if (invokeInstruction.opcode != Opcode.INVOKE_VIRTUAL) continue
|
||||
val methodName = ((invokeInstruction as Instruction35c).reference as MethodReference).name
|
||||
if (methodName != "getString") continue
|
||||
val resultInstruction = implementation1.instructions[targetIndex + 1]
|
||||
if (resultInstruction.opcode != Opcode.MOVE_RESULT_OBJECT) continue
|
||||
val overrideRegister = (resultInstruction as OneRegisterInstruction).registerA
|
||||
method1.replaceInstruction(
|
||||
targetIndex + 1,
|
||||
// Patch Settings UI to add 'Revanced Settings'.
|
||||
val targetIndexes = findOptionsOnClickIndex()
|
||||
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) {
|
||||
for (index in targetIndexes) {
|
||||
if (
|
||||
instruction(index).opcode != Opcode.NEW_INSTANCE ||
|
||||
instruction(index - 4).opcode != Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
return PatchResultError("Hardcode offset changed.")
|
||||
patchOptionNameAndOnClickEvent(index, context)
|
||||
}
|
||||
}
|
||||
// Implement settings screen in `AdPersonalizationActivity`
|
||||
with(AdPersonalizationActivityOnCreateFingerprint.result!!.mutableMethod) {
|
||||
for ((index, instruction) in implementation!!.instructions.withIndex()) {
|
||||
if (instruction.opcode != Opcode.INVOKE_SUPER) continue
|
||||
val thisRegister = (instruction as Instruction35c).registerC
|
||||
addInstructions(
|
||||
index + 1,
|
||||
"""
|
||||
const-string v$overrideRegister, "Revanced Settings"
|
||||
invoke-static {v$thisRegister}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->initializeSettings(Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;)V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
break
|
||||
}
|
||||
//Change onClick to start settings activity.
|
||||
val clickInstruction = implementation1.instructions[index - 1]
|
||||
if (clickInstruction.opcode != Opcode.INVOKE_DIRECT)
|
||||
return PatchResultError("Can not find click listener.")
|
||||
val clickClass = ((clickInstruction as ReferenceInstruction).reference as MethodReference).definingClass
|
||||
val mutableClickClass = context.findClass(clickClass)!!.mutableClass
|
||||
val mutableOnClickMethod = mutableClickClass.methods.first {
|
||||
it.name == "onClick"
|
||||
}
|
||||
mutableOnClickMethod.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->startSettingsActivity()V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
break
|
||||
}
|
||||
//Implement revanced settings screen in `AdPersonalizationActivity`
|
||||
val method2 = AdPersonalizationActivityFingerprint.result!!.mutableMethod
|
||||
for ((index, instruction) in method2.implementation!!.instructions.withIndex()) {
|
||||
if (instruction.opcode != Opcode.INVOKE_SUPER) continue
|
||||
val thisRegister = (instruction as Instruction35c).registerC
|
||||
method2.addInstructions(
|
||||
index + 1,
|
||||
"""
|
||||
invoke-static {v$thisRegister}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->initializeSettings(Lcom/bytedance/ies/ugc/aweme/commercialize/compliance/personalization/AdPersonalizationActivity;)V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
break
|
||||
}
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private fun findOptionsOnClickIndex(): IntArray {
|
||||
val results = IntArray(2)
|
||||
var found = 0
|
||||
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) {
|
||||
for ((index, instruction) in implementation!!.instructions.withIndex()) {
|
||||
// Old UI settings option to replace to 'Revanced Settings'
|
||||
if (instruction.opcode == Opcode.CONST_STRING) {
|
||||
val string = ((instruction as ReferenceInstruction).reference as StringReference).string
|
||||
if (string == "copyright_policy") {
|
||||
results[0] = index - 2
|
||||
found++
|
||||
}
|
||||
}
|
||||
|
||||
// New UI settings option to replace to 'Revanced Settings'
|
||||
if (instruction.opcode == Opcode.NEW_INSTANCE) {
|
||||
val onClickClass = ((instruction as Instruction21c).reference as TypeReference).type
|
||||
if (onClickClass == AboutOnClickMethodFingerprint.result!!.mutableMethod.definingClass) {
|
||||
results[1] = index
|
||||
found++
|
||||
}
|
||||
}
|
||||
if (found > 1) break
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
private fun patchOptionNameAndOnClickEvent(index: Int, context: BytecodeContext) {
|
||||
with(SettingsOnViewCreatedFingerprint.result!!.mutableMethod) {
|
||||
// Patch option name
|
||||
val overrideRegister = (instruction(index - 4) as OneRegisterInstruction).registerA
|
||||
replaceInstruction(
|
||||
index - 4,
|
||||
"""
|
||||
const-string v$overrideRegister, "Revanced Settings"
|
||||
"""
|
||||
)
|
||||
|
||||
// Patch option OnClick Event
|
||||
with(((instruction(index) as ReferenceInstruction).reference as TypeReference).type) {
|
||||
context.findClass(this)!!.mutableClass.methods.first { it.name == "onClick" }
|
||||
.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static {}, Lapp/revanced/tiktok/settingsmenu/SettingsMenu;->startSettingsActivity()V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package app.revanced.patches.youtube.ad.general.bytecode.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
|
||||
import app.revanced.patcher.extensions.addInstruction
|
||||
import app.revanced.patcher.extensions.softCompareTo
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility
|
||||
import app.revanced.patches.youtube.ad.general.resource.patch.GeneralAdsResourcePatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.*
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference
|
||||
import java.util.*
|
||||
|
||||
|
||||
@Patch
|
||||
@DependsOn([GeneralAdsResourcePatch::class])
|
||||
@Name("general-ads")
|
||||
@Description("Removes general ads.")
|
||||
@GeneralAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
class GeneralAdsPatch : BytecodePatch() {
|
||||
internal companion object {
|
||||
private fun MutableClass.findMutableMethodOf(
|
||||
method: Method
|
||||
) = this.methods.first {
|
||||
it.softCompareTo(
|
||||
ImmutableMethodReference(
|
||||
method.definingClass, method.name, method.parameters, method.returnType
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
context.classes.forEach { classDef ->
|
||||
classDef.methods.forEach { method ->
|
||||
with(method.implementation) {
|
||||
this?.instructions?.forEachIndexed { index, instruction ->
|
||||
if (instruction.opcode != org.jf.dexlib2.Opcode.CONST)
|
||||
return@forEachIndexed
|
||||
// Instruction to store the id adAttribution into a register
|
||||
if ((instruction as Instruction31i).wideLiteral != GeneralAdsResourcePatch.adAttributionId)
|
||||
return@forEachIndexed
|
||||
|
||||
val insertIndex = index + 1
|
||||
|
||||
// Call to get the view with the id adAttribution
|
||||
with(instructions.elementAt(insertIndex)) {
|
||||
if (opcode != org.jf.dexlib2.Opcode.INVOKE_VIRTUAL)
|
||||
return@forEachIndexed
|
||||
|
||||
// Hide the view
|
||||
val viewRegister = (this as Instruction35c).registerC
|
||||
context.proxy(classDef).mutableClass.findMutableMethodOf(method).addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$viewRegister }, " +
|
||||
"Lapp/revanced/integrations/patches/GeneralAdsPatch;" +
|
||||
"->" +
|
||||
"hideAdAttributionView(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
package app.revanced.patches.youtube.ad.general.bytecode.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
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.extensions.softCompareTo
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patcher.util.smali.toInstruction
|
||||
import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility
|
||||
import app.revanced.patches.youtube.ad.general.resource.patch.GeneralResourceAdsPatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.MutableMethodImplementation
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction10x
|
||||
import org.jf.dexlib2.iface.Method
|
||||
import org.jf.dexlib2.iface.instruction.Instruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction21c
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
import org.jf.dexlib2.iface.reference.Reference
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference
|
||||
|
||||
@Patch
|
||||
@DependsOn([ResourceMappingResourcePatch::class, IntegrationsPatch::class, SettingsPatch::class, GeneralResourceAdsPatch::class])
|
||||
@Name("general-ads")
|
||||
@Description("Removes general ads.")
|
||||
@GeneralAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
class GeneralBytecodeAdsPatch : BytecodePatch() {
|
||||
// a constant used by litho
|
||||
private val lithoConstant = 0xaed2868
|
||||
|
||||
// list of resource names to get the id of
|
||||
private val resourceIds = arrayOf(
|
||||
"ad_attribution",
|
||||
"reel_multiple_items_shelf",
|
||||
).map { name ->
|
||||
ResourceMappingResourcePatch.resourceMappings.single { it.name == name }.id
|
||||
}
|
||||
|
||||
private val stringReferences = arrayOf(
|
||||
"Claiming to use more elements than provided",
|
||||
"LoggingProperties are not in proto format"
|
||||
)
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.ADS.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_home_ads_removal",
|
||||
StringResource("revanced_home_ads_removal_title", "Remove home ads"),
|
||||
true,
|
||||
StringResource("revanced_home_ads_removal_summary_on", "Home ads are hidden"),
|
||||
StringResource("revanced_home_ads_removal_summary_off", "Home ads are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_ad_removal",
|
||||
StringResource("revanced_adremover_ad_removal_enabled_title", "Remove general ads"),
|
||||
true,
|
||||
StringResource("revanced_adremover_ad_removal_enabled_summary_on", "General ads are hidden"),
|
||||
StringResource("revanced_adremover_ad_removal_enabled_summary_off", "General ads are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_merchandise",
|
||||
StringResource("revanced_adremover_merchandise_enabled_title", "Remove merchandise banners"),
|
||||
true,
|
||||
StringResource("revanced_adremover_merchandise_enabled_summary_on", "Merchandise banners are hidden"),
|
||||
StringResource("revanced_adremover_merchandise_enabled_summary_off", "Merchandise banners are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_community_posts_removal",
|
||||
StringResource("revanced_adremover_community_posts_enabled_title", "Remove community posts"),
|
||||
false,
|
||||
StringResource("revanced_adremover_community_posts_enabled_summary_on", "Community posts are hidden"),
|
||||
StringResource("revanced_adremover_community_posts_enabled_summary_off", "Community posts are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_compact_banner_removal",
|
||||
StringResource("revanced_adremover_compact_banner_enabled_title", "Remove compact banners"),
|
||||
true,
|
||||
StringResource("revanced_adremover_compact_banner_enabled_summary_on", "Compact banners are hidden"),
|
||||
StringResource("revanced_adremover_compact_banner_enabled_summary_off", "Compact banners are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_movie",
|
||||
StringResource("revanced_adremover_movie_enabled_title", "Remove movies section"),
|
||||
true,
|
||||
StringResource("revanced_adremover_movie_enabled_summary_on", "Movies section is hidden"),
|
||||
StringResource("revanced_adremover_movie_enabled_summary_off", "Movies section is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_feed_survey",
|
||||
StringResource("revanced_adremover_feed_survey_enabled_title", "Remove feed surveys"),
|
||||
true,
|
||||
StringResource("revanced_adremover_feed_survey_enabled_summary_on", "Feed surveys are hidden"),
|
||||
StringResource("revanced_adremover_feed_survey_enabled_summary_off", "Feed surveys are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_shorts",
|
||||
StringResource("revanced_adremover_shorts_enabled_title", "Remove shorts"),
|
||||
true,
|
||||
StringResource("revanced_adremover_shorts_enabled_summary_on", "Shorts are hidden"),
|
||||
StringResource("revanced_adremover_shorts_enabled_summary_off", "Shorts are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_community_guidelines",
|
||||
StringResource("revanced_adremover_community_guidelines_enabled_title", "Remove community guidelines"),
|
||||
true,
|
||||
StringResource("revanced_adremover_community_guidelines_enabled_summary_on", "Community guidelines are hidden"),
|
||||
StringResource("revanced_adremover_community_guidelines_enabled_summary_off", "Community guidelines are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_emergency_box_removal",
|
||||
StringResource("revanced_adremover_emergency_box_enabled_title", "Remove emergency boxes"),
|
||||
true,
|
||||
StringResource("revanced_adremover_emergency_box_enabled_summary_on", "Emergency boxes are hidden"),
|
||||
StringResource("revanced_adremover_emergency_box_enabled_summary_off", "Emergency boxes are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_info_panel",
|
||||
StringResource("revanced_adremover_info_panel_enabled_title", "Remove info panels"),
|
||||
true,
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_on", "Info panels are hidden"),
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_off", "Info panels are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_medical_panel",
|
||||
StringResource("revanced_adremover_medical_panel_enabled_title", "Remove medical panels"),
|
||||
true,
|
||||
StringResource("revanced_adremover_medical_panel_enabled_summary_on", "Medical panels are hidden"),
|
||||
StringResource("revanced_adremover_medical_panel_enabled_summary_off", "Medical panels are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_paid_content",
|
||||
StringResource("revanced_adremover_paid_content_enabled_title", "Remove paid content"),
|
||||
true,
|
||||
StringResource("revanced_adremover_paid_content_enabled_summary_on", "Paid content is hidden"),
|
||||
StringResource("revanced_adremover_paid_content_enabled_summary_off", "Paid content is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_hide_suggestions",
|
||||
StringResource("revanced_adremover_hide_suggestions_enabled_title", "Hide suggestions"),
|
||||
true,
|
||||
StringResource("revanced_adremover_hide_suggestions_enabled_summary_on", "Suggestions are hidden"),
|
||||
StringResource("revanced_adremover_hide_suggestions_enabled_summary_off", "Suggestions are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_hide_latest_posts",
|
||||
StringResource("revanced_adremover_hide_latest_posts_enabled_title", "Hide latest posts"),
|
||||
true,
|
||||
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_on", "Latest posts are hidden"),
|
||||
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_off", "Latest posts are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_hide_channel_guidelines",
|
||||
StringResource("revanced_adremover_hide_channel_guidelines_enabled_title", "Hide channel guidelines"),
|
||||
true,
|
||||
StringResource(
|
||||
"revanced_adremover_hide_channel_guidelines_enabled_summary_on",
|
||||
"Channel guidelines are hidden"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_adremover_hide_channel_guidelines_enabled_summary_off",
|
||||
"Channel guidelines are shown"
|
||||
)
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_self_sponsor",
|
||||
StringResource("revanced_adremover_self_sponsor_enabled_title", "Hide self sponsored cards"),
|
||||
true,
|
||||
StringResource("revanced_adremover_self_sponsor_enabled_summary_on", "Self sponsored cards are hidden"),
|
||||
StringResource("revanced_adremover_self_sponsor_enabled_summary_off", "Self sponsored cards are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_chapter_teaser",
|
||||
StringResource(
|
||||
"revanced_adremover_chapter_teaser_enabled_title",
|
||||
"Hide chapter teaser under videos"
|
||||
),
|
||||
true,
|
||||
StringResource(
|
||||
"revanced_adremover_chapter_teaser_enabled_summary_on",
|
||||
"Chapter teasers are hidden"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_adremover_chapter_teaser_enabled_summary_off",
|
||||
"Chapter teasers are shown"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// iterating through all classes is expensive
|
||||
for (classDef in context.classes) {
|
||||
var mutableClass: MutableClass? = null
|
||||
|
||||
method@ for (method in classDef.methods) {
|
||||
var mutableMethod: MutableMethod? = null
|
||||
|
||||
if (method.implementation == null) continue@method
|
||||
|
||||
val instructions = method.implementation!!.instructions
|
||||
instructions.forEachIndexed { index, instruction ->
|
||||
when (instruction.opcode) {
|
||||
Opcode.CONST -> {
|
||||
// TODO: find a way to de-duplicate code.
|
||||
// The issue is we need to save mutableClass and mutableMethod to the existing fields
|
||||
when ((instruction as Instruction31i).wideLiteral) {
|
||||
resourceIds[0] -> { // general ads
|
||||
// and is followed by an instruction with the mnemonic INVOKE_VIRTUAL
|
||||
val insertIndex = index + 1
|
||||
val invokeInstruction = instructions.elementAt(insertIndex)
|
||||
if (invokeInstruction.opcode != Opcode.INVOKE_VIRTUAL) return@forEachIndexed
|
||||
|
||||
// create proxied method, make sure to not re-resolve() the current class
|
||||
if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass
|
||||
if (mutableMethod == null) mutableMethod =
|
||||
mutableClass!!.findMutableMethodOf(method)
|
||||
|
||||
// insert hide call to hide the view corresponding to the resource
|
||||
val viewRegister = (invokeInstruction as Instruction35c).registerC
|
||||
mutableMethod!!.implementation!!.injectHideCall(insertIndex, viewRegister)
|
||||
}
|
||||
|
||||
resourceIds[1] -> { // reel ads
|
||||
// and is followed by an instruction at insertIndex with the mnemonic IPUT_OBJECT
|
||||
val insertIndex = index + 4
|
||||
val iPutInstruction = instructions.elementAt(insertIndex)
|
||||
if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed
|
||||
|
||||
// create proxied method, make sure to not re-resolve() the current class
|
||||
if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass
|
||||
if (mutableMethod == null) mutableMethod =
|
||||
mutableClass!!.findMutableMethodOf(method)
|
||||
|
||||
val viewRegister = (iPutInstruction as Instruction22c).registerA
|
||||
mutableMethod!!.implementation!!.injectHideCall(insertIndex, viewRegister)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Opcode.CONST_STRING -> {
|
||||
when (((instruction as Instruction21c).reference as StringReference).string) {
|
||||
stringReferences[0] -> {
|
||||
val stringInstruction = instructions.elementAt(3)
|
||||
if (stringInstruction.opcode == Opcode.CONST_STRING) return@forEachIndexed
|
||||
|
||||
// create proxied method, make sure to not re-resolve() the current class
|
||||
if (mutableClass == null) mutableClass = context.proxy(classDef).mutableClass
|
||||
if (mutableMethod == null) mutableMethod =
|
||||
mutableClass!!.findMutableMethodOf(method)
|
||||
|
||||
// return the method
|
||||
val insertIndex = 1 // after super constructor
|
||||
//ToDo: Add setting here
|
||||
mutableMethod!!.implementation!!.addInstruction(
|
||||
insertIndex, BuilderInstruction10x(Opcode.RETURN_VOID)
|
||||
)
|
||||
}
|
||||
|
||||
stringReferences[1] -> { // Litho ads
|
||||
val proxy = context.proxy(classDef)
|
||||
val proxiedClass = proxy.mutableClass
|
||||
|
||||
val lithoMethod = getLithoMethod(proxiedClass)
|
||||
?: return PatchResultError("Could not find required Litho method to patch.")
|
||||
|
||||
val instructionWithNeededDescriptor =
|
||||
lithoMethod.implementation!!.instructions.indexOfFirst {
|
||||
it.opcode == Opcode.INVOKE_STATIC_RANGE
|
||||
}
|
||||
|
||||
// get required descriptors
|
||||
val createEmptyComponentDescriptor =
|
||||
lithoMethod.instruction(instructionWithNeededDescriptor)
|
||||
.toDescriptor<MethodReference>()
|
||||
val emptyComponentFieldDescriptor =
|
||||
lithoMethod.instruction(instructionWithNeededDescriptor + 2)
|
||||
.toDescriptor<FieldReference>()
|
||||
|
||||
val pathBuilderAnchorFingerprint = object : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.CONST_16,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IPUT_OBJECT
|
||||
)
|
||||
) {}
|
||||
|
||||
val pathBuilderScanResult = pathBuilderAnchorFingerprint.also {
|
||||
it.resolve(context, lithoMethod, classDef)
|
||||
}.result!!.scanResult.patternScanResult!!
|
||||
|
||||
val clobberedRegister =
|
||||
(lithoMethod.instruction(pathBuilderScanResult.startIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
val insertIndex = pathBuilderScanResult.endIndex + 1
|
||||
lithoMethod.addInstructions(
|
||||
insertIndex, // right after setting the component.pathBuilder field,
|
||||
"""
|
||||
invoke-static {v5, v2}, Lapp/revanced/integrations/patches/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
|
||||
move-result v$clobberedRegister
|
||||
if-eqz v$clobberedRegister, :not_an_ad
|
||||
move-object/from16 v2, p1
|
||||
invoke-static {v2}, $createEmptyComponentDescriptor
|
||||
move-result-object v0
|
||||
iget-object v0, v0, $emptyComponentFieldDescriptor
|
||||
return-object v0
|
||||
""",
|
||||
listOf(ExternalLabel("not_an_ad", lithoMethod.instruction(insertIndex)))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else -> return@forEachIndexed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private fun getLithoMethod(mutableClass: MutableClass) = mutableClass.methods.firstOrNull {
|
||||
it.implementation?.instructions?.any { instruction ->
|
||||
instruction.opcode == Opcode.CONST && (instruction as Instruction31i).narrowLiteral == lithoConstant
|
||||
} ?: false
|
||||
}
|
||||
|
||||
private fun MutableClass.findMutableMethodOf(
|
||||
method: Method
|
||||
) = this.methods.first {
|
||||
it.softCompareTo(
|
||||
ImmutableMethodReference(
|
||||
method.definingClass, method.name, method.parameters, method.returnType
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private inline fun <reified T : Reference> Instruction.toDescriptor(): String {
|
||||
val reference = (this as ReferenceInstruction).reference
|
||||
return when (T::class) {
|
||||
MethodReference::class -> {
|
||||
val methodReference = reference as MethodReference
|
||||
"${methodReference.definingClass}->${methodReference.name}(${
|
||||
methodReference.parameterTypes.joinToString(
|
||||
""
|
||||
) { it }
|
||||
})${methodReference.returnType}"
|
||||
}
|
||||
|
||||
FieldReference::class -> {
|
||||
val fieldReference = reference as FieldReference
|
||||
"${fieldReference.definingClass}->${fieldReference.name}:${fieldReference.type}"
|
||||
}
|
||||
|
||||
else -> throw PatchResultError("Unsupported reference type")
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableMethodImplementation.injectHideCall(
|
||||
index: Int,
|
||||
register: Int
|
||||
) {
|
||||
this.addInstruction(
|
||||
index,
|
||||
"invoke-static { v$register }, Lapp/revanced/integrations/patches/HideHomeAdsPatch;->HideHomeAds(Landroid/view/View;)V".toInstruction()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package app.revanced.patches.youtube.ad.general.resource.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility
|
||||
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.*
|
||||
|
||||
@DependsOn(dependencies = [
|
||||
FixLocaleConfigErrorPatch::class,
|
||||
LithoFilterPatch::class,
|
||||
SettingsPatch::class,
|
||||
ResourceMappingPatch::class
|
||||
])
|
||||
@GeneralAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
class GeneralAdsResourcePatch : ResourcePatch {
|
||||
internal companion object {
|
||||
var adAttributionId: Long = -1
|
||||
}
|
||||
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
PreferenceScreen.ADS.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_adremover_ad_removal",
|
||||
StringResource("revanced_adremover_ad_removal_enabled_title", "Hide general ads"),
|
||||
true,
|
||||
StringResource("revanced_adremover_ad_removal_enabled_summary_on", "General ads are hidden"),
|
||||
StringResource("revanced_adremover_ad_removal_enabled_summary_off", "General ads are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_buttoned",
|
||||
StringResource("revanced_adremover_buttoned_enabled_title", "Hide buttoned ad"),
|
||||
true,
|
||||
StringResource("revanced_adremover_buttoned_enabled_summary_on", "Buttoned ads are hidden"),
|
||||
StringResource("revanced_adremover_buttoned_enabled_summary_off", "Buttoned ads are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_merchandise",
|
||||
StringResource("revanced_adremover_merchandise_enabled_title", "Hide merchandise banners"),
|
||||
true,
|
||||
StringResource("revanced_adremover_merchandise_enabled_summary_on", "Merchandise banners are hidden"),
|
||||
StringResource("revanced_adremover_merchandise_enabled_summary_off", "Merchandise banners are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_community_posts_removal",
|
||||
StringResource("revanced_adremover_community_posts_enabled_title", "Hide community posts"),
|
||||
false,
|
||||
StringResource("revanced_adremover_community_posts_enabled_summary_on", "Community posts are hidden"),
|
||||
StringResource("revanced_adremover_community_posts_enabled_summary_off", "Community posts are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_compact_banner_removal",
|
||||
StringResource("revanced_adremover_compact_banner_enabled_title", "Hide compact banners"),
|
||||
true,
|
||||
StringResource("revanced_adremover_compact_banner_enabled_summary_on", "Compact banners are hidden"),
|
||||
StringResource("revanced_adremover_compact_banner_enabled_summary_off", "Compact banners are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_movie",
|
||||
StringResource("revanced_adremover_movie_enabled_title", "Hide movies section"),
|
||||
true,
|
||||
StringResource("revanced_adremover_movie_enabled_summary_on", "Movies section is hidden"),
|
||||
StringResource("revanced_adremover_movie_enabled_summary_off", "Movies section is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_feed_survey",
|
||||
StringResource("revanced_adremover_feed_survey_enabled_title", "Hide feed surveys"),
|
||||
true,
|
||||
StringResource("revanced_adremover_feed_survey_enabled_summary_on", "Feed surveys are hidden"),
|
||||
StringResource("revanced_adremover_feed_survey_enabled_summary_off", "Feed surveys are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_shorts",
|
||||
StringResource("revanced_adremover_shorts_enabled_title", "Hide shorts"),
|
||||
true,
|
||||
StringResource("revanced_adremover_shorts_enabled_summary_on", "Shorts are hidden"),
|
||||
StringResource("revanced_adremover_shorts_enabled_summary_off", "Shorts are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_community_guidelines",
|
||||
StringResource("revanced_adremover_community_guidelines_enabled_title", "Hide community guidelines"),
|
||||
true,
|
||||
StringResource(
|
||||
"revanced_adremover_community_guidelines_enabled_summary_on",
|
||||
"Community guidelines are hidden"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_adremover_community_guidelines_enabled_summary_off",
|
||||
"Community guidelines are shown"
|
||||
)
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_emergency_box_removal",
|
||||
StringResource("revanced_adremover_emergency_box_enabled_title", "Hide emergency boxes"),
|
||||
true,
|
||||
StringResource("revanced_adremover_emergency_box_enabled_summary_on", "Emergency boxes are hidden"),
|
||||
StringResource("revanced_adremover_emergency_box_enabled_summary_off", "Emergency boxes are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_info_panel",
|
||||
StringResource("revanced_adremover_info_panel_enabled_title", "Hide info panels"),
|
||||
true,
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_on", "Info panels are hidden"),
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_off", "Info panels are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_medical_panel",
|
||||
StringResource("revanced_adremover_medical_panel_enabled_title", "Hide medical panels"),
|
||||
true,
|
||||
StringResource("revanced_adremover_medical_panel_enabled_summary_on", "Medical panels are hidden"),
|
||||
StringResource("revanced_adremover_medical_panel_enabled_summary_off", "Medical panels are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_paid_content",
|
||||
StringResource("revanced_adremover_paid_content_enabled_title", "Hide paid content"),
|
||||
true,
|
||||
StringResource("revanced_adremover_paid_content_enabled_summary_on", "Paid content is hidden"),
|
||||
StringResource("revanced_adremover_paid_content_enabled_summary_off", "Paid content is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_hide_suggestions",
|
||||
StringResource("revanced_adremover_hide_suggestions_enabled_title", "Hide suggestions"),
|
||||
true,
|
||||
StringResource("revanced_adremover_hide_suggestions_enabled_summary_on", "Suggestions are hidden"),
|
||||
StringResource("revanced_adremover_hide_suggestions_enabled_summary_off", "Suggestions are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_hide_latest_posts",
|
||||
StringResource("revanced_adremover_hide_latest_posts_enabled_title", "Hide latest posts"),
|
||||
true,
|
||||
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_on", "Latest posts are hidden"),
|
||||
StringResource("revanced_adremover_hide_latest_posts_enabled_summary_off", "Latest posts are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_hide_channel_guidelines",
|
||||
StringResource("revanced_adremover_hide_channel_guidelines_enabled_title", "Hide channel guidelines"),
|
||||
true,
|
||||
StringResource(
|
||||
"revanced_adremover_hide_channel_guidelines_enabled_summary_on",
|
||||
"Channel guidelines are hidden"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_adremover_hide_channel_guidelines_enabled_summary_off",
|
||||
"Channel guidelines are shown"
|
||||
)
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_self_sponsor",
|
||||
StringResource("revanced_adremover_self_sponsor_enabled_title", "Hide self sponsored cards"),
|
||||
true,
|
||||
StringResource("revanced_adremover_self_sponsor_enabled_summary_on", "Self sponsored cards are hidden"),
|
||||
StringResource("revanced_adremover_self_sponsor_enabled_summary_off", "Self sponsored cards are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_separator",
|
||||
StringResource("revanced_adremover_separator_title", "Hide gray separator"),
|
||||
true,
|
||||
StringResource("revanced_adremover_separator_summary_on", "Gray separators are hidden"),
|
||||
StringResource("revanced_adremover_separator_summary_off", "Gray separators are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_chapter_teaser",
|
||||
StringResource(
|
||||
"revanced_adremover_chapter_teaser_enabled_title",
|
||||
"Hide chapter teaser under videos"
|
||||
),
|
||||
true,
|
||||
StringResource(
|
||||
"revanced_adremover_chapter_teaser_enabled_summary_on",
|
||||
"Chapter teasers are hidden"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_adremover_chapter_teaser_enabled_summary_off",
|
||||
"Chapter teasers are shown"
|
||||
)
|
||||
),
|
||||
PreferenceScreen(
|
||||
"revanced_adremover_custom",
|
||||
StringResource("revanced_adremover_custom_title", "Custom filter"),
|
||||
listOf(
|
||||
SwitchPreference(
|
||||
"revanced_adremover_custom_enabled",
|
||||
StringResource(
|
||||
"revanced_adremover_custom_enabled_title",
|
||||
"Enable custom filter"
|
||||
),
|
||||
false,
|
||||
StringResource(
|
||||
"revanced_adremover_custom_enabled_summary_on",
|
||||
"Custom filter is enabled"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_adremover_custom_enabled_summary_off",
|
||||
"Custom filter is disabled"
|
||||
)
|
||||
),
|
||||
// TODO: This should be a ListPreference, which does not exist yet
|
||||
TextPreference(
|
||||
"revanced_adremover_custom_strings",
|
||||
StringResource("revanced_adremover_custom_strings_title", "Custom filter"),
|
||||
InputType.STRING,
|
||||
"",
|
||||
StringResource(
|
||||
"revanced_adremover_custom_strings_summary",
|
||||
"Filter components by their name separated by a comma"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
adAttributionId = ResourceMappingPatch.resourceMappings.single { it.name == "ad_attribution" }.id
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package app.revanced.patches.youtube.ad.general.resource.patch
|
||||
|
||||
import app.revanced.extensions.doRecursively
|
||||
import app.revanced.extensions.startsWithAny
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patches.youtube.ad.general.annotation.GeneralAdsCompatibility
|
||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@DependsOn(dependencies = [FixLocaleConfigErrorPatch::class])
|
||||
@Name("general-resource-ads")
|
||||
@Description("Patch to remove general ads in resources.")
|
||||
@GeneralAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
class GeneralResourceAdsPatch : ResourcePatch {
|
||||
// list of resource file names which need to be hidden
|
||||
private val resourceFileNames = arrayOf(
|
||||
"compact_promoted_",
|
||||
"promoted_video_",
|
||||
)
|
||||
|
||||
// the attributes to change the value of
|
||||
private val replacements = arrayOf(
|
||||
"height",
|
||||
"width",
|
||||
"marginTop",
|
||||
)
|
||||
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
context.forEach {
|
||||
if (!it.name.startsWithAny(*resourceFileNames)) return@forEach
|
||||
|
||||
// for each file in the "layouts" directory replace all necessary attributes content
|
||||
context.xmlEditor[it.absolutePath].use { editor ->
|
||||
editor.file.doRecursively { node ->
|
||||
replacements.forEach replacement@{ replacement ->
|
||||
if (node !is Element) return@replacement
|
||||
|
||||
node.getAttributeNode("android:layout_$replacement")?.let { attribute ->
|
||||
attribute.textContent = "1.0dip"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import app.revanced.patches.youtube.layout.autoplaybutton.annotations.AutoplayBu
|
||||
import app.revanced.patches.youtube.layout.autoplaybutton.fingerprints.AutoNavInformerFingerprint
|
||||
import app.revanced.patches.youtube.layout.autoplaybutton.fingerprints.LayoutConstructorFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
@@ -25,7 +25,7 @@ import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Name("hide-autoplay-button")
|
||||
@Description("Hides the autoplay button in the video player.")
|
||||
@AutoplayButtonCompatibility
|
||||
@@ -53,7 +53,7 @@ class HideAutoplayButtonPatch : BytecodePatch(
|
||||
val layoutGenMethodInstructions = layoutGenMethod.implementation!!.instructions
|
||||
|
||||
// resolve the offsets such as ...
|
||||
val autoNavPreviewStubId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
val autoNavPreviewStubId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.name == "autonav_preview_stub"
|
||||
}.id
|
||||
// where to insert the branch instructions and ...
|
||||
|
||||
@@ -9,16 +9,16 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.annotations.HideButtonsCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Patch
|
||||
@DependsOn([ResourceMappingResourcePatch::class, GeneralBytecodeAdsPatch::class])
|
||||
@DependsOn([ResourceMappingPatch::class, LithoFilterPatch::class])
|
||||
@Name("hide-video-buttons")
|
||||
@Description("Adds options to hide action buttons under a video.")
|
||||
@HideButtonsCompatibility
|
||||
|
||||
@@ -13,16 +13,10 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
|
||||
import app.revanced.patches.youtube.layout.comments.annotations.CommentsCompatibility
|
||||
import app.revanced.patches.youtube.layout.comments.bytecode.fingerprints.ShortsCommentsButtonFingerprint
|
||||
import app.revanced.patches.youtube.layout.comments.resource.patch.CommentsResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.comments.annotations.CommentsCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
@@ -16,7 +16,7 @@ import app.revanced.patches.youtube.misc.settings.framework.components.impl.Swit
|
||||
|
||||
@Name("comments-resource-patch")
|
||||
@CommentsCompatibility
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class CommentsResourcePatch : ResourcePatch {
|
||||
companion object {
|
||||
@@ -55,7 +55,7 @@ class CommentsResourcePatch : ResourcePatch {
|
||||
)
|
||||
)
|
||||
|
||||
shortsCommentsButtonId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
shortsCommentsButtonId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "drawable" && it.name == "ic_right_comment_32c"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.hidealbumcards.annotations.AlbumCardsCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Name("hide-album-cards-resource-patch")
|
||||
@AlbumCardsCompatibility
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class AlbumCardsResourcePatch : ResourcePatch {
|
||||
companion object {
|
||||
@@ -33,7 +33,7 @@ class AlbumCardsResourcePatch : ResourcePatch {
|
||||
)
|
||||
)
|
||||
|
||||
albumCardId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
albumCardId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "layout" && it.name == "album_card"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.annotations.HideArtistCardCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Patch
|
||||
@DependsOn([ResourceMappingResourcePatch::class, GeneralBytecodeAdsPatch::class])
|
||||
@DependsOn([ResourceMappingPatch::class, LithoFilterPatch::class])
|
||||
@Name("hide-artist-card")
|
||||
@Description("Hides the artist card below the searchbar.")
|
||||
@HideArtistCardCompatibility
|
||||
|
||||
@@ -8,14 +8,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.hidecrowdfundingbox.annotations.CrowdfundingBoxCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Name("crowdfunding-box-resource-patch")
|
||||
@CrowdfundingBoxCompatibility
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class CrowdfundingBoxResourcePatch : ResourcePatch {
|
||||
companion object {
|
||||
@@ -33,7 +33,7 @@ class CrowdfundingBoxResourcePatch : ResourcePatch {
|
||||
)
|
||||
)
|
||||
|
||||
crowdfundingBoxId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
crowdfundingBoxId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "layout" && it.name == "donation_companion"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.hideendscreencards.annotations.HideEndscreenCardsCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Name("hide-endscreen-cards-resource-patch")
|
||||
@HideEndscreenCardsCompatibility
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class HideEndscreenCardsResourcePatch : ResourcePatch {
|
||||
internal companion object {
|
||||
@@ -35,7 +35,7 @@ class HideEndscreenCardsResourcePatch : ResourcePatch {
|
||||
),
|
||||
)
|
||||
|
||||
fun findEndscreenResourceId(name: String) = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
fun findEndscreenResourceId(name: String) = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "layout" && it.name == "endscreen_element_layout_$name"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsIncognitoFingerprint
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsMethodCallFingerprint
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsIncognitoParentFingerprint
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.fingerprints.InfocardsMethodCallFingerprint
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.resource.patch.HideInfocardsResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import org.jf.dexlib2.Opcode
|
||||
@@ -39,16 +39,17 @@ class HideInfocardsPatch : BytecodePatch(
|
||||
with(InfocardsIncognitoFingerprint.also {
|
||||
it.resolve(context, InfocardsIncognitoParentFingerprint.result!!.classDef)
|
||||
}.result!!.mutableMethod) {
|
||||
val invokeInstructionIndex = implementation!!.instructions.indexOfFirst {
|
||||
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal &&
|
||||
((it as? BuilderInstruction35c)?.reference.toString() ==
|
||||
"Landroid/view/View;->setVisibility(I)V")
|
||||
}
|
||||
val invokeInstructionIndex = implementation!!.instructions.indexOfFirst {
|
||||
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal &&
|
||||
((it as? BuilderInstruction35c)?.reference.toString() ==
|
||||
"Landroid/view/View;->setVisibility(I)V")
|
||||
}
|
||||
|
||||
replaceInstruction(invokeInstructionIndex, """
|
||||
invoke-static {v${(instruction(invokeInstructionIndex) as? BuilderInstruction35c)?.registerC}}, Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsIncognito(Landroid/view/View;)V
|
||||
"""
|
||||
)
|
||||
replaceInstruction(
|
||||
invokeInstructionIndex,
|
||||
"invoke-static {v${(instruction(invokeInstructionIndex) as? BuilderInstruction35c)?.registerC}}," +
|
||||
" Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsIncognito(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
|
||||
with(InfocardsMethodCallFingerprint.result!!) {
|
||||
@@ -62,7 +63,12 @@ class HideInfocardsPatch : BytecodePatch(
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsMethodCall()Z
|
||||
move-result v$toggleRegister
|
||||
if-nez v$toggleRegister, :hide_info_cards
|
||||
""", listOf(ExternalLabel("hide_info_cards", hideInfocardsCallMethod.instruction(invokeInterfaceIndex + 1)))
|
||||
""",
|
||||
listOf(
|
||||
ExternalLabel(
|
||||
"hide_info_cards", hideInfocardsCallMethod.instruction(invokeInterfaceIndex + 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@HideInfocardsCompatibility
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class HideInfocardsResourcePatch : ResourcePatch {
|
||||
internal companion object {
|
||||
@@ -31,7 +31,7 @@ class HideInfocardsResourcePatch : ResourcePatch {
|
||||
)
|
||||
)
|
||||
|
||||
drawerResourceId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
drawerResourceId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "id" && it.name == "info_cards_drawer_header"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.personalinformation.annotations.HideEmailAddressCompatibility
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Name("hide-email-address-resource-patch")
|
||||
@HideEmailAddressCompatibility
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class HideEmailAddressResourcePatch : ResourcePatch {
|
||||
companion object {
|
||||
@@ -33,7 +33,7 @@ class HideEmailAddressResourcePatch : ResourcePatch {
|
||||
)
|
||||
)
|
||||
|
||||
accountSwitcherAccessibilityLabelId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
accountSwitcherAccessibilityLabelId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "string" && it.name == "account_switcher_accessibility_label"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarFingerp
|
||||
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.REGISTER_TEMPLATE_REPLACEMENT
|
||||
import app.revanced.patches.youtube.layout.pivotbar.utils.InjectionUtils.injectHook
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, ResourceMappingResourcePatch::class, SettingsPatch::class])
|
||||
@DependsOn([IntegrationsPatch::class, ResourceMappingPatch::class, SettingsPatch::class])
|
||||
@Name("hide-create-button")
|
||||
@Description("Hides the create button in the navigation bar.")
|
||||
@CreateButtonCompatibility
|
||||
|
||||
@@ -21,7 +21,7 @@ import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlock
|
||||
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.*
|
||||
import app.revanced.patches.youtube.layout.sponsorblock.resource.patch.SponsorBlockResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.playercontrols.bytecode.patch.PlayerControlsBytecodePatch
|
||||
import app.revanced.patches.youtube.misc.video.information.patch.VideoInformationPatch
|
||||
import app.revanced.patches.youtube.misc.video.videoid.patch.VideoIdPatch
|
||||
@@ -158,9 +158,9 @@ class SponsorBlockBytecodePatch : BytecodePatch(
|
||||
val controlsMethodResult = PlayerControlsBytecodePatch.showPlayerControlsFingerprintResult
|
||||
|
||||
val controlsLayoutStubResourceId =
|
||||
ResourceMappingResourcePatch.resourceMappings.single { it.type == "id" && it.name == "controls_layout_stub" }.id
|
||||
ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "controls_layout_stub" }.id
|
||||
val zoomOverlayResourceId =
|
||||
ResourceMappingResourcePatch.resourceMappings.single { it.type == "id" && it.name == "video_zoom_overlay_stub" }.id
|
||||
ResourceMappingPatch.resourceMappings.single { it.type == "id" && it.name == "video_zoom_overlay_stub" }.id
|
||||
|
||||
methods@ for (method in controlsMethodResult.mutableClass.methods) {
|
||||
val instructions = method.implementation?.instructions!!
|
||||
|
||||
@@ -9,7 +9,7 @@ import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlockCompatibility
|
||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.Preference
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
@@ -20,7 +20,7 @@ import app.revanced.util.resources.ResourceUtils.copyXmlNode
|
||||
|
||||
@Name("sponsorblock-resource-patch")
|
||||
@SponsorBlockCompatibility
|
||||
@DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class SponsorBlockResourcePatch : ResourcePatch {
|
||||
companion object {
|
||||
@@ -107,7 +107,7 @@ class SponsorBlockResourcePatch : ResourcePatch {
|
||||
}
|
||||
}.close() // close afterwards
|
||||
|
||||
reelButtonGroupResourceId = ResourceMappingResourcePatch.resourceMappings.single {
|
||||
reelButtonGroupResourceId = ResourceMappingPatch.resourceMappings.single {
|
||||
it.type == "id" && it.name == "reel_persistent_edu_button_group"
|
||||
}.id
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import app.revanced.util.resources.ResourceUtils
|
||||
import app.revanced.util.resources.ResourceUtils.copyResources
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@Patch
|
||||
@Patch(include = false)
|
||||
@DependsOn([LithoThemePatch::class, FixLocaleConfigErrorPatch::class])
|
||||
@Name("theme")
|
||||
@Description("Applies a custom theme.")
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter.annotation
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.google.android.youtube", arrayOf("17.36.37", "17.41.37", "17.42.35", "17.43.36")
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class LithoFilterCompatibility
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.litho.filter.annotation.LithoFilterCompatibility
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("component-context-parser-fingerprint")
|
||||
@LithoFilterCompatibility
|
||||
@Version("0.0.1")
|
||||
object ComponentContextParserFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_INTERFACE,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.GOTO,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.CONST_16,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.NEW_INSTANCE
|
||||
),
|
||||
strings = listOf("LoggingProperties are not in proto format")
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter.fingerprints
|
||||
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.misc.litho.filter.annotation.LithoFilterCompatibility
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
@Name("empty-component-builder-fingerprint")
|
||||
@LithoFilterCompatibility
|
||||
@Version("0.0.1")
|
||||
object EmptyComponentBuilderFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC_RANGE
|
||||
),
|
||||
)
|
||||
@@ -0,0 +1,78 @@
|
||||
package app.revanced.patches.youtube.misc.litho.filter.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||
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.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.annotation.LithoFilterCompatibility
|
||||
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.ComponentContextParserFingerprint
|
||||
import app.revanced.patches.youtube.misc.litho.filter.fingerprints.EmptyComponentBuilderFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.Instruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@DependsOn([IntegrationsPatch::class])
|
||||
@Description("Hooks the method which parses the bytes into a ComponentContext to filter components.")
|
||||
@LithoFilterCompatibility
|
||||
@Version("0.0.1")
|
||||
class LithoFilterPatch : BytecodePatch(
|
||||
listOf(ComponentContextParserFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
ComponentContextParserFingerprint.result?.let { result ->
|
||||
val builderMethodIndex = EmptyComponentBuilderFingerprint
|
||||
.also { it.resolve(context, result.mutableMethod, result.mutableClass) }
|
||||
.let { it.result!!.scanResult.patternScanResult!!.startIndex }
|
||||
|
||||
val emptyComponentFieldIndex = builderMethodIndex + 2
|
||||
|
||||
with(result.mutableMethod) {
|
||||
val insertHookIndex = result.scanResult.patternScanResult!!.endIndex
|
||||
val clobberedRegister = (instruction(insertHookIndex - 3) as OneRegisterInstruction).registerA
|
||||
|
||||
val builderMethodDescriptor = instruction(builderMethodIndex).toDescriptor()
|
||||
val emptyComponentFieldDescriptor = instruction(emptyComponentFieldIndex).toDescriptor()
|
||||
|
||||
addInstructions(
|
||||
insertHookIndex, // right after setting the component.pathBuilder field,
|
||||
"""
|
||||
invoke-static {v5, v2}, Lapp/revanced/integrations/patches/LithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
|
||||
move-result v$clobberedRegister
|
||||
if-eqz v$clobberedRegister, :not_an_ad
|
||||
move-object/from16 v2, p1
|
||||
invoke-static {v2}, $builderMethodDescriptor
|
||||
move-result-object v0
|
||||
iget-object v0, v0, $emptyComponentFieldDescriptor
|
||||
return-object v0
|
||||
""",
|
||||
listOf(ExternalLabel("not_an_ad", instruction(insertHookIndex)))
|
||||
)
|
||||
}
|
||||
} ?: return PatchResultError("Could not find the method to hook.")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
fun Instruction.toDescriptor() = when (val reference = (this as? ReferenceInstruction)?.reference) {
|
||||
is MethodReference -> "${reference.definingClass}->${reference.name}(${
|
||||
reference.parameterTypes.joinToString(
|
||||
""
|
||||
) { it }
|
||||
})${reference.returnType}"
|
||||
is FieldReference -> "${reference.definingClass}->${reference.name}:${reference.type}"
|
||||
else -> throw PatchResultError("Unsupported reference type")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,14 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.playercontrols.annotation.PlayerControlsCompatibility
|
||||
import app.revanced.patches.youtube.misc.playercontrols.fingerprints.BottomControlsInflateFingerprint
|
||||
import app.revanced.patches.youtube.misc.playercontrols.fingerprints.PlayerControlsVisibilityFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Name("player-controls-bytecode-patch")
|
||||
@DependsOn([ResourceMappingResourcePatch::class])
|
||||
@DependsOn([ResourceMappingPatch::class])
|
||||
@Description("Manages the code for the player controls of the YouTube player.")
|
||||
@PlayerControlsCompatibility
|
||||
@Version("0.0.1")
|
||||
@@ -28,7 +28,7 @@ class PlayerControlsBytecodePatch : BytecodePatch(
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
showPlayerControlsFingerprintResult = PlayerControlsVisibilityFingerprint.result!!
|
||||
|
||||
bottomUiContainerResourceId = ResourceMappingResourcePatch
|
||||
bottomUiContainerResourceId = ResourceMappingPatch
|
||||
.resourceMappings
|
||||
.single { it.type == "id" && it.name == "bottom_ui_container_stub" }.id
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
|
||||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
|
||||
import app.revanced.patches.shared.mapping.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.BasePreference
|
||||
@@ -21,14 +21,14 @@ import org.w3c.dom.Node
|
||||
|
||||
@Name("settings-resource-patch")
|
||||
@SettingsCompatibility
|
||||
@DependsOn([FixLocaleConfigErrorPatch::class, ResourceMappingResourcePatch::class])
|
||||
@DependsOn([FixLocaleConfigErrorPatch::class, ResourceMappingPatch::class])
|
||||
@Version("0.0.1")
|
||||
class SettingsResourcePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
/*
|
||||
* used by a fingerprint of SettingsPatch
|
||||
*/
|
||||
appearanceStringId = ResourceMappingResourcePatch.resourceMappings.find {
|
||||
appearanceStringId = ResourceMappingPatch.resourceMappings.find {
|
||||
it.type == "string" && it.name == "app_theme_appearance_dark"
|
||||
}!!.id
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.youtube.misc.zoomhaptics.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("com.google.android.youtube")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class ZoomHapticsCompatibility
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.youtube.misc.zoomhaptics.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object ZoomHapticsFingerprint : MethodFingerprint(
|
||||
strings = listOf(
|
||||
"Failed to haptics vibrate for video zoom"
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
package app.revanced.patches.youtube.misc.zoomhaptics.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
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.framework.components.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.zoomhaptics.annotations.ZoomHapticsCompatibility
|
||||
import app.revanced.patches.youtube.misc.zoomhaptics.fingerprints.ZoomHapticsFingerprint
|
||||
|
||||
@Patch
|
||||
@Name("disable-zoom-haptics")
|
||||
@Description("Disables haptics when zooming.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@ZoomHapticsCompatibility
|
||||
@Version("0.0.1")
|
||||
class ZoomHapticsPatch : BytecodePatch(
|
||||
listOf(ZoomHapticsFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_disable_zoom_haptics",
|
||||
StringResource("revanced_disable_zoom_haptics_title", "Disable zoom haptics"),
|
||||
true,
|
||||
StringResource("revanced_disable_zoom_haptics_summary_on", "Haptics are disabled"),
|
||||
StringResource("revanced_disable_zoom_haptics_summary_off", "Haptics are enabled")
|
||||
)
|
||||
)
|
||||
|
||||
val zoomHapticsFingerprintMethod = ZoomHapticsFingerprint.result!!.mutableMethod
|
||||
|
||||
zoomHapticsFingerprintMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/ZoomHapticsPatch;->shouldVibrate()Z
|
||||
move-result v0
|
||||
if-nez v0, :vibrate
|
||||
return-void
|
||||
""", listOf(ExternalLabel("vibrate", zoomHapticsFingerprintMethod.instruction(0)))
|
||||
)
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user