Compare commits

..

20 Commits

Author SHA1 Message Date
semantic-release-bot
7e5c963e36 chore(release): 2.132.0 [skip ci]
# [2.132.0](https://github.com/revanced/revanced-patches/compare/v2.131.0...v2.132.0) (2022-12-01)

### Features

* **sleepasandroid:** `unlock-premium` patch ([#1172](https://github.com/revanced/revanced-patches/issues/1172)) ([9d9d938](05ea840b8f))
* **twitch:** remove `block-embedded-ads` patch ([#1164](https://github.com/revanced/revanced-patches/issues/1164)) ([403e887](da4b80c5dd))
2022-12-01 17:20:22 +00:00
aliveoutside
05ea840b8f feat(sleepasandroid): unlock-premium patch (#1172)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-12-01 18:18:43 +01:00
Ushie
da4b80c5dd feat(twitch): remove block-embedded-ads patch (#1164) 2022-11-30 22:36:21 +01:00
semantic-release-bot
4ca19b7fd2 chore(release): 2.131.0 [skip ci]
# [2.131.0](https://github.com/revanced/revanced-patches/compare/v2.130.0...v2.131.0) (2022-11-30)

### Features

* **twitch/block-embedded-ads:** `block-embedded-ads` patch support ([#1160](https://github.com/revanced/revanced-patches/issues/1160)) ([69590fd](260b395426))
2022-11-30 14:11:58 +00:00
Tim Schneeberger
260b395426 feat(twitch/block-embedded-ads): block-embedded-ads patch support (#1160) 2022-11-30 15:10:07 +01:00
semantic-release-bot
b4d8dbcc3d chore(release): 2.130.0 [skip ci]
# [2.130.0](https://github.com/revanced/revanced-patches/compare/v2.129.0...v2.130.0) (2022-11-29)

### Features

* **youtube/enable-wide-searchbar:** bump compatibility to v17.45.36 ([5451a52](7180914df1))
2022-11-29 00:46:01 +00:00
oSumAtrIX
7180914df1 feat(youtube/enable-wide-searchbar): bump compatibility to v17.45.36 2022-11-29 01:44:18 +01:00
semantic-release-bot
748b14d547 chore(release): 2.129.0 [skip ci]
# [2.129.0](https://github.com/revanced/revanced-patches/compare/v2.128.0...v2.129.0) (2022-11-28)

### Features

* **youtube/hide-create-button:** bump compatibility to v17.45.36 ([37e9df2](d9d4d1f38c))
* **youtube/hide-shorts-button:** bump compatibility to v17.45.36 ([e5e33f2](0f73a9dd5e))
2022-11-28 23:57:26 +00:00
oSumAtrIX
d9d4d1f38c feat(youtube/hide-create-button): bump compatibility to v17.45.36 2022-11-29 00:55:34 +01:00
oSumAtrIX
0f73a9dd5e feat(youtube/hide-shorts-button): bump compatibility to v17.45.36 2022-11-29 00:55:31 +01:00
semantic-release-bot
fafcd751b2 chore(release): 2.128.0 [skip ci]
# [2.128.0](https://github.com/revanced/revanced-patches/compare/v2.127.0...v2.128.0) (2022-11-28)

### Features

* **twitch:** settings for patches ([#1142](https://github.com/revanced/revanced-patches/issues/1142)) ([02bb641](ea7b3f5529))
2022-11-28 23:22:34 +00:00
Tim Schneeberger
ea7b3f5529 feat(twitch): settings for patches (#1142) 2022-11-29 00:20:58 +01:00
semantic-release-bot
4935c00aa5 chore(release): 2.127.0 [skip ci]
# [2.127.0](https://github.com/revanced/revanced-patches/compare/v2.126.1...v2.127.0) (2022-11-28)

### Features

* **twitch:** `settings` patch ([#1075](https://github.com/revanced/revanced-patches/issues/1075)) ([632a083](06098713bb))
2022-11-28 22:52:01 +00:00
Tim Schneeberger
06098713bb feat(twitch): settings patch (#1075)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-11-28 23:50:04 +01:00
Tim Schneeberger
eb505d802a refactor: abstract settings patch (#1109)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-11-28 20:13:34 +01:00
semantic-release-bot
e8b7cdfa35 chore(release): 2.126.1 [skip ci]
## [2.126.1](https://github.com/revanced/revanced-patches/compare/v2.126.0...v2.126.1) (2022-11-28)

### Bug Fixes

* **youtube/custom-video-speed:** fuzzy scan on fingerprint  ([#1135](https://github.com/revanced/revanced-patches/issues/1135)) ([920e72a](986951dc8a))
2022-11-28 10:58:11 +00:00
FineFindus
986951dc8a fix(youtube/custom-video-speed): fuzzy scan on fingerprint (#1135) 2022-11-28 11:56:12 +01:00
d4rkk3y
b88fda959c refactor(tiktok): simplify names (#1085) 2022-11-28 03:11:32 +01:00
semantic-release-bot
96c36dca74 chore(release): 2.126.0 [skip ci]
# [2.126.0](https://github.com/revanced/revanced-patches/compare/v2.125.0...v2.126.0) (2022-11-28)

### Features

* **backdrops:** `pro-unlock` patch ([#1121](https://github.com/revanced/revanced-patches/issues/1121)) ([285169e](4ce3fd4ff7))
2022-11-28 01:38:21 +00:00
josesilveiraa
4ce3fd4ff7 feat(backdrops): pro-unlock patch (#1121) 2022-11-28 02:36:39 +01:00
124 changed files with 1432 additions and 603 deletions

View File

@@ -1,3 +1,61 @@
# [2.132.0](https://github.com/revanced/revanced-patches/compare/v2.131.0...v2.132.0) (2022-12-01)
### Features
* **sleepasandroid:** `unlock-premium` patch ([#1172](https://github.com/revanced/revanced-patches/issues/1172)) ([580ddcd](https://github.com/revanced/revanced-patches/commit/580ddcdf1f8ef4a525f772630b3c085b706e4dc7))
* **twitch:** remove `block-embedded-ads` patch ([#1164](https://github.com/revanced/revanced-patches/issues/1164)) ([ecc1eae](https://github.com/revanced/revanced-patches/commit/ecc1eaef4daa7dfecb7913c378188b2b4685e610))
# [2.131.0](https://github.com/revanced/revanced-patches/compare/v2.130.0...v2.131.0) (2022-11-30)
### Features
* **twitch/block-embedded-ads:** `block-embedded-ads` patch support ([#1160](https://github.com/revanced/revanced-patches/issues/1160)) ([641d33f](https://github.com/revanced/revanced-patches/commit/641d33fc7e213031124491bb468fb382267769aa))
# [2.130.0](https://github.com/revanced/revanced-patches/compare/v2.129.0...v2.130.0) (2022-11-29)
### Features
* **youtube/enable-wide-searchbar:** bump compatibility to v17.45.36 ([66ce54c](https://github.com/revanced/revanced-patches/commit/66ce54c9921e6fbf5bbe52d73b0182352181f2b8))
# [2.129.0](https://github.com/revanced/revanced-patches/compare/v2.128.0...v2.129.0) (2022-11-28)
### Features
* **youtube/hide-create-button:** bump compatibility to v17.45.36 ([751f604](https://github.com/revanced/revanced-patches/commit/751f6047ba1589593d881ad523727d00dfb2609b))
* **youtube/hide-shorts-button:** bump compatibility to v17.45.36 ([51bfa7a](https://github.com/revanced/revanced-patches/commit/51bfa7afd1720d958847a44ae636de722311a199))
# [2.128.0](https://github.com/revanced/revanced-patches/compare/v2.127.0...v2.128.0) (2022-11-28)
### Features
* **twitch:** settings for patches ([#1142](https://github.com/revanced/revanced-patches/issues/1142)) ([ed56f94](https://github.com/revanced/revanced-patches/commit/ed56f94f12c3bee46ab370b2e3b7890d1181d53d))
# [2.127.0](https://github.com/revanced/revanced-patches/compare/v2.126.1...v2.127.0) (2022-11-28)
### Features
* **twitch:** `settings` patch ([#1075](https://github.com/revanced/revanced-patches/issues/1075)) ([6e95b86](https://github.com/revanced/revanced-patches/commit/6e95b86e50cb09b60d82b456d4650218436ed154))
## [2.126.1](https://github.com/revanced/revanced-patches/compare/v2.126.0...v2.126.1) (2022-11-28)
### Bug Fixes
* **youtube/custom-video-speed:** fuzzy scan on fingerprint ([#1135](https://github.com/revanced/revanced-patches/issues/1135)) ([7b2cf56](https://github.com/revanced/revanced-patches/commit/7b2cf5698b85f7e2a901f6085c53d042660dc5c7))
# [2.126.0](https://github.com/revanced/revanced-patches/compare/v2.125.0...v2.126.0) (2022-11-28)
### Features
* **backdrops:** `pro-unlock` patch ([#1121](https://github.com/revanced/revanced-patches/issues/1121)) ([76b5449](https://github.com/revanced/revanced-patches/commit/76b5449c61c97e8ad9f87fb7173c9819815744ba))
# [2.125.0](https://github.com/revanced/revanced-patches/compare/v2.124.0...v2.125.0) (2022-11-26)

View File

@@ -25,15 +25,15 @@ The official Patch bundle provided by ReVanced and the community.
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `tiktok-ads` | Removes ads from TikTok. | all |
| `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` | Adds settings for ReVanced to TikTok. | all |
| `tiktok-force-login` | Do not force login. | all |
| `tiktok-web-login` | Allows logging in with a Google account. | all |
| `hide-ads` | Removes ads from TikTok. | all |
| `playback-speed` | Enables the playback speed option for all videos. | all |
| `downloads` | Removes download restrictions and changes the default path to download to. | all |
| `show-seekbar` | Shows progress bar for all video. | all |
| `settings` | Adds settings for ReVanced to TikTok. | all |
| `fix-google-login` | Allows logging in with a Google account. | all |
| `disable-login-requirement` | Do not force login. | all |
| `sim-spoof` | Spoofs the information which is retrieved from the sim-card. | all |
| `tiktok-feed-filter` | Filters tiktok videos: removing ads, removing livestreams. | all |
| `feed-filter` | Filters tiktok videos: removing ads, removing livestreams. | all |
</details>
### 📦 `com.zhiliaoapp.musically`
@@ -41,15 +41,15 @@ The official Patch bundle provided by ReVanced and the community.
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `tiktok-ads` | Removes ads from TikTok. | all |
| `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` | Adds settings for ReVanced to TikTok. | all |
| `tiktok-force-login` | Do not force login. | all |
| `tiktok-web-login` | Allows logging in with a Google account. | all |
| `hide-ads` | Removes ads from TikTok. | all |
| `playback-speed` | Enables the playback speed option for all videos. | all |
| `downloads` | Removes download restrictions and changes the default path to download to. | all |
| `show-seekbar` | Shows progress bar for all video. | all |
| `settings` | Adds settings for ReVanced to TikTok. | all |
| `fix-google-login` | Allows logging in with a Google account. | all |
| `disable-login-requirement` | Do not force login. | all |
| `sim-spoof` | Spoofs the information which is retrieved from the sim-card. | all |
| `tiktok-feed-filter` | Filters tiktok videos: removing ads, removing livestreams. | all |
| `feed-filter` | Filters tiktok videos: removing ads, removing livestreams. | all |
</details>
### 📦 `com.twitter.android`
@@ -96,10 +96,10 @@ The official Patch bundle provided by ReVanced and the community.
| `hide-crowdfunding-box` | Hides the crowdfunding box between the player and video description. | 17.45.36 |
| `hide-time-and-seekbar` | Hides progress bar and time counter on videos. | 17.45.36 |
| `hide-video-buttons` | Adds options to hide action buttons under a video. | 17.45.36 |
| `enable-wide-searchbar` | Replaces the search icon with a wide search bar. This will hide the YouTube logo when active. | 17.43.36 |
| `enable-wide-searchbar` | Replaces the search icon with a wide search bar. This will hide the YouTube logo when active. | 17.45.36 |
| `hide-captions-button` | Hides the captions button on video player. | 17.45.36 |
| `hide-shorts-button` | Hides the shorts button on the navigation bar. | 17.43.36 |
| `hide-create-button` | Hides the create button in the navigation bar. | 17.43.36 |
| `hide-shorts-button` | Hides the shorts button on the navigation bar. | 17.45.36 |
| `hide-create-button` | Hides the create button in the navigation bar. | 17.45.36 |
| `disable-startup-shorts-player` | Disables playing YouTube Shorts when launching YouTube. | 17.45.36 |
| `remove-player-button-background` | Removes the background from the video player buttons. | 17.45.36 |
| `hide-endscreen-cards` | Hides the suggested video cards at the end of a video in fullscreen. | 17.45.36 |
@@ -150,6 +150,14 @@ The official Patch bundle provided by ReVanced and the community.
| `client-spoof` | Spoofs the YouTube or Vanced client to prevent playback issues. | all |
</details>
### 📦 `com.urbandroid.sleep`
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-premium` | Unlocks all premium features. | all |
</details>
### 📦 `com.ticktick.task`
<details>
@@ -182,6 +190,7 @@ The official Patch bundle provided by ReVanced and the community.
| `debug-mode` | Enables Twitch's internal debugging mode. | all |
| `block-audio-ads` | Blocks audio ads in streams and VODs. | all |
| `block-video-ads` | Blocks video ads in streams and VODs. | all |
| `settings` | Adds settings menu to Twitch. | all |
| `show-deleted-messages` | Shows deleted chat messages behind a clickable spoiler. | all |
</details>
@@ -235,6 +244,14 @@ The official Patch bundle provided by ReVanced and the community.
| `unlock-pro` | Unlocks all pro features. | all |
</details>
### 📦 `com.backdrops.wallpapers`
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `pro-unlock` | Unlocks pro-only functions. | all |
</details>
## 📝 JSON Format

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 2.125.0
version = 2.132.0

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,23 @@
package app.revanced.extensions
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.MethodFingerprintExtensions.name
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.util.MethodUtil
import org.w3c.dom.Node
// TODO: populate this to all patches
/**
* Convert a [MethodFingerprint] to a [PatchResultError].
*
* @return A [PatchResultError] for the [MethodFingerprint].
*/
fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name")
/**
* Find the [MutableMethod] from a given [Method] in a [MutableClass].
*

View File

@@ -0,0 +1,7 @@
package app.revanced.patches.backdrops.misc.pro.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.backdrops.wallpapers")])
internal annotation class ProUnlockCompatibility

View File

@@ -0,0 +1,15 @@
package app.revanced.patches.backdrops.misc.pro.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object ProUnlockFingerprint : MethodFingerprint(
opcodes = listOf(
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT,
Opcode.IF_EQZ
),
customFingerprint = { it.definingClass == "Lcom/backdrops/wallpapers/data/local/DatabaseHandlerIAB;" && it.name == "lambda\$existPurchase\$0" }
)

View File

@@ -0,0 +1,42 @@
package app.revanced.patches.backdrops.misc.pro.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.MethodFingerprintExtensions.name
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.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.backdrops.misc.pro.annotations.ProUnlockCompatibility
import app.revanced.patches.backdrops.misc.pro.fingerprints.ProUnlockFingerprint
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("pro-unlock")
@Description("Unlocks pro-only functions.")
@ProUnlockCompatibility
@Version("0.0.1")
class ProUnlockPatch : BytecodePatch(
listOf(ProUnlockFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = ProUnlockFingerprint.result ?: return PatchResultError("${ProUnlockFingerprint.name} not found")
val moveRegisterInstruction = result.mutableMethod.instruction(result.scanResult.patternScanResult!!.endIndex - 1)
val register = (moveRegisterInstruction as OneRegisterInstruction).registerA
result.mutableMethod.addInstructions(
result.scanResult.patternScanResult!!.endIndex,
"""
const/4 v$register, 0x1
"""
)
return PatchResultSuccess()
}
}

View File

@@ -1,6 +1,6 @@
package app.revanced.patches.shared.settings
package app.revanced.patches.shared.settings.preference
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.StringResource
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.shared.settings
package app.revanced.patches.shared.settings.preference
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -1,6 +1,6 @@
package app.revanced.patches.shared.settings
package app.revanced.patches.shared.settings.preference
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.StringResource
import org.w3c.dom.Element
import org.w3c.dom.Node

View File

@@ -1,6 +1,6 @@
package app.revanced.patches.shared.settings
package app.revanced.patches.shared.settings.preference
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.StringResource
/**
* Preference

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.shared.settings
package app.revanced.patches.shared.settings.preference
/**
* Resource

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.shared.settings
package app.revanced.patches.shared.settings.preference
enum class SummaryType(val type: String) {
DEFAULT("summary"), ON("summaryOn"), OFF("summaryOff")

View File

@@ -1,7 +1,7 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BaseResource
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.preference.BaseResource
import app.revanced.patches.shared.settings.preference.IResource
import org.w3c.dom.Document
import org.w3c.dom.Element
@@ -19,8 +19,10 @@ internal data class ArrayResource(
override fun serialize(ownerDocument: Document, resourceCallback: ((IResource) -> Unit)?): Element {
return super.serialize(ownerDocument, resourceCallback).apply {
setAttribute("name", name)
items.forEach { item ->
setAttribute("name", item.also { resourceCallback?.invoke(it) }.name)
resourceCallback?.invoke(item)
this.appendChild(ownerDocument.createElement("item").also { itemNode ->
itemNode.textContent = item.value

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
enum class InputType(val type: String) {
STRING("text"),

View File

@@ -1,9 +1,9 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BasePreference
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.addDefault
import app.revanced.patches.shared.settings.addSummary
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addDefault
import app.revanced.patches.shared.settings.preference.addSummary
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -1,8 +1,8 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BasePreference
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.addSummary
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addSummary
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -1,7 +1,7 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BasePreference
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import org.w3c.dom.Document
import org.w3c.dom.Element
@@ -15,7 +15,7 @@ import org.w3c.dom.Element
internal open class PreferenceCategory(
key: String,
title: StringResource,
val preferences: List<BasePreference>
var preferences: List<BasePreference>
) : BasePreference(key, title) {
override val tag: String = "PreferenceCategory"

View File

@@ -1,8 +1,8 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BasePreference
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.addSummary
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addSummary
import org.w3c.dom.Document
import org.w3c.dom.Element
@@ -17,7 +17,7 @@ import org.w3c.dom.Element
internal open class PreferenceScreen(
key: String,
title: StringResource,
val preferences: List<BasePreference>,
var preferences: List<BasePreference>,
val summary: StringResource? = null
) : BasePreference(key, title) {
override val tag: String = "PreferenceScreen"

View File

@@ -1,7 +1,7 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BaseResource
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.preference.BaseResource
import app.revanced.patches.shared.settings.preference.IResource
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -1,10 +1,10 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.*
import app.revanced.patches.shared.settings.BasePreference
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.addDefault
import app.revanced.patches.shared.settings.addSummary
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addDefault
import app.revanced.patches.shared.settings.preference.addSummary
import app.revanced.patches.shared.settings.preference.SummaryType
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -1,9 +1,9 @@
package app.revanced.patches.shared.settings.impl
package app.revanced.patches.shared.settings.preference.impl
import app.revanced.patches.shared.settings.BasePreference
import app.revanced.patches.shared.settings.IResource
import app.revanced.patches.shared.settings.addDefault
import app.revanced.patches.shared.settings.addSummary
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addDefault
import app.revanced.patches.shared.settings.preference.addSummary
import org.w3c.dom.Document
import org.w3c.dom.Element

View File

@@ -0,0 +1,135 @@
package app.revanced.patches.shared.settings.resource.patch
import app.revanced.patcher.data.DomFileEditor
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.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.IResource
import app.revanced.patches.shared.settings.preference.addPreference
import app.revanced.patches.shared.settings.preference.addResource
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.copyResources
import org.w3c.dom.Node
/**
* Abstract settings resource patch
*
* @param preferenceFileName Name of the settings preference xml file
* @param sourceDirectory Source directory to copy the preference template from
*/
abstract class AbstractSettingsResourcePatch(
private val preferenceFileName: String,
private val sourceDirectory: String,
) : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
/*
* used for self-restart
*/
context.xmlEditor["AndroidManifest.xml"].use { editor ->
editor.file.getElementsByTagName("manifest").item(0).also {
it.appendChild(it.ownerDocument.createElement("uses-permission").also { element ->
element.setAttribute("android:name", "android.permission.SCHEDULE_EXACT_ALARM")
})
}
}
/* copy preference template from source dir */
context.copyResources(
sourceDirectory,
ResourceUtils.ResourceGroup(
"xml", "$preferenceFileName.xml"
)
)
/* prepare xml editors */
stringsEditor = context.xmlEditor["res/values/strings.xml"]
arraysEditor = context.xmlEditor["res/values/arrays.xml"]
revancedPreferencesEditor = context.xmlEditor["res/xml/$preferenceFileName.xml"]
return PatchResultSuccess()
}
internal companion object {
private var revancedPreferenceNode: Node? = null
private var stringsNode: Node? = null
private var arraysNode: Node? = null
private var strings = mutableListOf<StringResource>()
private var revancedPreferencesEditor: DomFileEditor? = null
set(value) {
field = value
revancedPreferenceNode = value.getNode("PreferenceScreen")
}
private var stringsEditor: DomFileEditor? = null
set(value) {
field = value
stringsNode = value.getNode("resources")
}
private var arraysEditor: DomFileEditor? = null
set(value) {
field = value
arraysNode = value.getNode("resources")
}
/**
* Add a new string to the resources.
*
* @param identifier The key of the string.
* @param value The value of the string.
* @throws IllegalArgumentException if the string already exists.
*/
fun addString(identifier: String, value: String, formatted: Boolean) =
StringResource(identifier, value, formatted).include()
/**
* Add an array to the resources.
*
* @param arrayResource The array resource to add.
*/
fun addArray(arrayResource: ArrayResource) =
arraysNode!!.addResource(arrayResource)
/**
* Add a preference to the settings.
*
* @param preference The preference to add.
*/
fun addPreference(preference: BasePreference) =
revancedPreferenceNode!!.addPreference(preference) { it.include() }
/**
* Add a new resource to the resources.
*
* @throws IllegalArgumentException if the resource already exists.
*/
internal fun IResource.include() {
when (this) {
is StringResource -> {
if (strings.any { it.name == name }) return
strings.add(this)
}
is ArrayResource -> addArray(this)
else -> throw NotImplementedError("Unsupported resource type")
}
}
internal fun DomFileEditor?.getNode(tagName: String) = this!!.file.getElementsByTagName(tagName).item(0)
}
override fun close() {
// merge all strings, skip duplicates
strings.forEach {
stringsNode!!.addResource(it)
}
revancedPreferencesEditor?.close()
stringsEditor?.close()
arraysEditor?.close()
}
}

View File

@@ -0,0 +1,89 @@
package app.revanced.patches.shared.settings.util
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import java.io.Closeable
internal abstract class AbstractPreferenceScreen(
private val root: MutableList<Screen> = mutableListOf()
) : Closeable {
override fun close() {
if (root.isEmpty())
return
for (preference in root.sortedBy { it.title }) {
commit(preference.transform())
}
}
/**
* Finalize and insert root preference into resource patch
*/
abstract fun commit(screen: PreferenceScreen)
open inner class Screen(
key: String,
title: String,
val summary: String? = null,
preferences: MutableList<BasePreference> = mutableListOf(),
val categories: MutableList<Category> = mutableListOf()
) : BasePreferenceCollection(key, title, preferences) {
override fun transform(): PreferenceScreen {
return PreferenceScreen(
key,
StringResource("${key}_title", title),
preferences.sortedBy { it.title.value } +
categories.sortedBy { it.title }.map { it.transform() },
summary?.let { summary ->
StringResource("${key}_summary", summary)
}
)
}
private fun ensureScreenInserted() {
// Add to screens if not yet done
if(!this@AbstractPreferenceScreen.root.contains(this))
this@AbstractPreferenceScreen.root.add(this)
}
fun addPreferences(vararg preferences: BasePreference) {
ensureScreenInserted()
this.preferences.addAll(preferences)
}
open inner class Category(
key: String,
title: String,
preferences: MutableList<BasePreference> = mutableListOf()
): BasePreferenceCollection(key, title, preferences) {
override fun transform(): PreferenceCategory {
return PreferenceCategory(
key,
StringResource("${key}_title", title),
preferences.sortedBy { it.title.value }
)
}
fun addPreferences(vararg preferences: BasePreference) {
ensureScreenInserted()
// Add to categories if not yet done
if(!this@Screen.categories.contains(this))
this@Screen.categories.add(this)
this.preferences.addAll(preferences)
}
}
}
abstract class BasePreferenceCollection(
val key: String,
val title: String,
val preferences: MutableList<BasePreference> = mutableListOf()
) {
abstract fun transform(): BasePreference
}
}

View File

@@ -0,0 +1,9 @@
package app.revanced.patches.sleepasandroid.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.urbandroid.sleep")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class UnlockPremiumCompatibility

View File

@@ -0,0 +1,8 @@
package app.revanced.patches.sleepasandroid.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object IsTrialFingerprint : MethodFingerprint(
"Z",
customFingerprint = { it.name == "isTrial" }
)

View File

@@ -0,0 +1,36 @@
package app.revanced.patches.sleepasandroid.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.sleepasandroid.annotations.UnlockPremiumCompatibility
import app.revanced.patches.sleepasandroid.fingerprints.IsTrialFingerprint
@Patch
@Name("unlock-premium")
@Description("Unlocks all premium features.")
@UnlockPremiumCompatibility
class UnlockPremiumPatch : BytecodePatch(
listOf(
IsTrialFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
val method = IsTrialFingerprint.result!!.mutableMethod
method.addInstructions(
0,
"""
const/4 v0, 0x0
return v0
"""
)
return PatchResultSuccess()
}
}

View File

@@ -11,4 +11,4 @@ import app.revanced.patcher.annotation.Package
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class TiktokAdsCompatibility
internal annotation class HideAdsCompatibility

View File

@@ -10,7 +10,7 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.ad.annotations.TiktokAdsCompatibility
import app.revanced.patches.tiktok.ad.annotations.HideAdsCompatibility
import app.revanced.patches.tiktok.ad.fingerprints.ConvertHelpFeedItemListFingerprint
import app.revanced.patches.tiktok.ad.fingerprints.FeedItemListCloneFingerprint
import org.jf.dexlib2.Opcode
@@ -19,11 +19,11 @@ import org.jf.dexlib2.iface.instruction.TwoRegisterInstruction
import org.jf.dexlib2.iface.reference.FieldReference
@Patch
@Name("tiktok-ads")
@Name("hide-ads")
@Description("Removes ads from TikTok.")
@TiktokAdsCompatibility
@HideAdsCompatibility
@Version("0.0.1")
class TiktokAdsPatch : BytecodePatch(
class HideAdsPatch : BytecodePatch(
listOf(
FeedItemListCloneFingerprint,
ConvertHelpFeedItemListFingerprint

View File

@@ -12,19 +12,19 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.feedfilter.annotations.FeedFilterCompatibility
import app.revanced.patches.tiktok.feedfilter.fingerprints.FeedApiServiceLIZFingerprint
import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import app.revanced.patches.tiktok.misc.settings.patch.TikTokSettingsPatch
import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@DependsOn([TikTokIntegrationsPatch::class, TikTokSettingsPatch::class])
@Name("tiktok-feed-filter")
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("feed-filter")
@Description("Filters tiktok videos: removing ads, removing livestreams.")
@FeedFilterCompatibility
@Version("0.0.1")
class TiktokFeedFilter : BytecodePatch(
class FeedFilterPatch : BytecodePatch(
listOf(
FeedApiServiceLIZFingerprint,
SettingsStatusLoadFingerprint

View File

@@ -21,17 +21,17 @@ import app.revanced.patches.tiktok.interaction.downloads.fingerprints.ACLCommonS
import app.revanced.patches.tiktok.interaction.downloads.fingerprints.ACLCommonShareFingerprint2
import app.revanced.patches.tiktok.interaction.downloads.fingerprints.ACLCommonShareFingerprint3
import app.revanced.patches.tiktok.interaction.downloads.fingerprints.DownloadPathParentFingerprint
import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import app.revanced.patches.tiktok.misc.settings.patch.TikTokSettingsPatch
import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.StringReference
@Patch
@DependsOn([TikTokIntegrationsPatch::class, TikTokSettingsPatch::class])
@Name("tiktok-download")
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("downloads")
@Description("Removes download restrictions and changes the default path to download to.")
@DownloadsCompatibility
@Version("0.0.1")

View File

@@ -11,4 +11,4 @@ import app.revanced.patcher.annotation.Package
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class SeekbarCompatibility
internal annotation class ShowSeekbarCompatibility

View File

@@ -10,18 +10,18 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.interaction.seekbar.annotations.SeekbarCompatibility
import app.revanced.patches.tiktok.interaction.seekbar.annotations.ShowSeekbarCompatibility
import app.revanced.patches.tiktok.interaction.seekbar.fingerprints.AwemeGetVideoControlFingerprint
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction11n
import org.jf.dexlib2.builder.instruction.BuilderInstruction22c
@Patch
@Name("tiktok-seekbar")
@Description("Show progress bar for all video.")
@SeekbarCompatibility
@Name("show-seekbar")
@Description("Shows progress bar for all video.")
@ShowSeekbarCompatibility
@Version("0.0.1")
class TiktokSeekbarPatch : BytecodePatch(
class ShowSeekbarPatch : BytecodePatch(
listOf(
AwemeGetVideoControlFingerprint
)

View File

@@ -11,4 +11,4 @@ import app.revanced.patcher.annotation.Package
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class SpeedCompatibility
internal annotation class PlaybackSpeedCompatibility

View File

@@ -11,16 +11,16 @@ import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.tiktok.interaction.speed.annotations.SpeedCompatibility
import app.revanced.patches.tiktok.interaction.speed.annotations.PlaybackSpeedCompatibility
import app.revanced.patches.tiktok.interaction.speed.fingerprints.SpeedControlParentFingerprint
import org.jf.dexlib2.Opcode
@Patch
@Name("tiktok-speed")
@Name("playback-speed")
@Description("Enables the playback speed option for all videos.")
@SpeedCompatibility
@PlaybackSpeedCompatibility
@Version("0.0.1")
class SpeedPatch : BytecodePatch(
class PlaybackSpeedPatch : BytecodePatch(
listOf(
SpeedControlParentFingerprint
)

View File

@@ -11,4 +11,4 @@ import app.revanced.patcher.annotation.Package
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class TikTokIntegrationsCompatibility
internal annotation class IntegrationsCompatibility

View File

@@ -1,13 +1,13 @@
package app.revanced.patches.tiktok.misc.integrations.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patches.tiktok.misc.integrations.annotations.TikTokIntegrationsCompatibility
import app.revanced.patches.tiktok.misc.integrations.annotations.IntegrationsCompatibility
import app.revanced.patches.tiktok.misc.integrations.fingerprints.InitFingerprint
import app.revanced.patches.shared.integrations.patch.AbstractIntegrationsPatch
@Name("tiktok-integrations")
@TikTokIntegrationsCompatibility
class TikTokIntegrationsPatch : AbstractIntegrationsPatch(
@Name("integrations")
@IntegrationsCompatibility
class IntegrationsPatch : AbstractIntegrationsPatch(
"Lapp/revanced/tiktok/utils/ReVancedUtils;",
listOf(InitFingerprint)
)

View File

@@ -0,0 +1,14 @@
package app.revanced.patches.tiktok.misc.login.disablerequirement.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[
Package("com.ss.android.ugc.trill"),
Package("com.zhiliaoapp.musically")
]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class DisableLoginRequirementCompatibility

View File

@@ -1,7 +1,6 @@
package app.revanced.patches.tiktok.misc.forcelogin.fingerprints
package app.revanced.patches.tiktok.misc.login.disablerequirement.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object MandatoryLoginServiceFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/MandatoryLoginService;") &&

View File

@@ -1,12 +1,12 @@
package app.revanced.patches.tiktok.misc.forcelogin.fingerprints
package app.revanced.patches.tiktok.misc.login.disablerequirement.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.forcelogin.annotations.DisableForceLoginCompatibility
import app.revanced.patches.tiktok.misc.login.disablerequirement.annotations.DisableLoginRequirementCompatibility
@Name("mandatory-login-service-fingerprint2")
@DisableForceLoginCompatibility
@DisableLoginRequirementCompatibility
@Version("0.0.1")
object MandatoryLoginServiceFingerprint2 : MethodFingerprint(
customFingerprint = { methodDef ->

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.misc.forcelogin.patch
package app.revanced.patches.tiktok.misc.login.disablerequirement.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
@@ -9,16 +9,16 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.misc.forcelogin.annotations.DisableForceLoginCompatibility
import app.revanced.patches.tiktok.misc.forcelogin.fingerprints.MandatoryLoginServiceFingerprint
import app.revanced.patches.tiktok.misc.forcelogin.fingerprints.MandatoryLoginServiceFingerprint2
import app.revanced.patches.tiktok.misc.login.disablerequirement.annotations.DisableLoginRequirementCompatibility
import app.revanced.patches.tiktok.misc.login.disablerequirement.fingerprints.MandatoryLoginServiceFingerprint
import app.revanced.patches.tiktok.misc.login.disablerequirement.fingerprints.MandatoryLoginServiceFingerprint2
@Patch
@Name("tiktok-force-login")
@Name("disable-login-requirement")
@Description("Do not force login.")
@DisableForceLoginCompatibility
@DisableLoginRequirementCompatibility
@Version("0.0.1")
class DisableForceLoginPatch : BytecodePatch(
class DisableLoginRequirementPatch : BytecodePatch(
listOf(
MandatoryLoginServiceFingerprint,
MandatoryLoginServiceFingerprint2

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.misc.forcelogin.annotations
package app.revanced.patches.tiktok.misc.login.fixgoogle.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@@ -11,4 +11,4 @@ import app.revanced.patcher.annotation.Package
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class DisableForceLoginCompatibility
internal annotation class FixGoogleLoginCompatibility

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.misc.loginfallback.fingerprints
package app.revanced.patches.tiktok.misc.login.fixgoogle.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.misc.loginfallback.fingerprints
package app.revanced.patches.tiktok.misc.login.fixgoogle.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint

View File

@@ -1,4 +1,4 @@
package app.revanced.patches.tiktok.misc.loginfallback.patch
package app.revanced.patches.tiktok.misc.login.fixgoogle.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
@@ -9,16 +9,16 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility
import app.revanced.patches.tiktok.misc.loginfallback.fingerprints.GoogleAuthAvailableFingerprint
import app.revanced.patches.tiktok.misc.loginfallback.fingerprints.GoogleOneTapAuthAvailableFingerprint
import app.revanced.patches.tiktok.misc.login.fixgoogle.annotations.FixGoogleLoginCompatibility
import app.revanced.patches.tiktok.misc.login.fixgoogle.fingerprints.GoogleAuthAvailableFingerprint
import app.revanced.patches.tiktok.misc.login.fixgoogle.fingerprints.GoogleOneTapAuthAvailableFingerprint
@Patch
@Name("tiktok-web-login")
@Name("fix-google-login")
@Description("Allows logging in with a Google account.")
@TikTokWebLoginCompatibility
@FixGoogleLoginCompatibility
@Version("0.0.1")
class TikTokLoginFallbackPatch : BytecodePatch(
class FixGoogleLoginPatch : BytecodePatch(
listOf(
GoogleOneTapAuthAvailableFingerprint,
GoogleAuthAvailableFingerprint

View File

@@ -1,14 +0,0 @@
package app.revanced.patches.tiktok.misc.loginfallback.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility(
[
Package("com.ss.android.ugc.trill"),
Package("com.zhiliaoapp.musically")
]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class TikTokWebLoginCompatibility

View File

@@ -11,4 +11,4 @@ import app.revanced.patcher.annotation.Package
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class TikTokSettingsCompatibility
internal annotation class SettingsCompatibility

View File

@@ -13,8 +13,8 @@ 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.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.annotations.TikTokSettingsCompatibility
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.annotations.SettingsCompatibility
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
@@ -27,12 +27,12 @@ import org.jf.dexlib2.iface.reference.StringReference
import org.jf.dexlib2.iface.reference.TypeReference
@Patch
@DependsOn([TikTokIntegrationsPatch::class])
@Name("tiktok-settings")
@DependsOn([IntegrationsPatch::class])
@Name("settings")
@Description("Adds settings for ReVanced to TikTok.")
@TikTokSettingsCompatibility
@SettingsCompatibility
@Version("0.0.1")
class TikTokSettingsPatch : BytecodePatch(
class SettingsPatch : BytecodePatch(
listOf(
AdPersonalizationActivityOnCreateFingerprint,
SettingsOnViewCreatedFingerprint,

View File

@@ -14,9 +14,9 @@ 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.MutableMethod
import app.revanced.patches.tiktok.misc.integrations.patch.TikTokIntegrationsPatch
import app.revanced.patches.tiktok.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.tiktok.misc.settings.fingerprints.SettingsStatusLoadFingerprint
import app.revanced.patches.tiktok.misc.settings.patch.TikTokSettingsPatch
import app.revanced.patches.tiktok.misc.settings.patch.SettingsPatch
import app.revanced.patches.tiktok.misc.spoof.sim.annotations.SpoofSimCompatibility
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@@ -24,7 +24,7 @@ import org.jf.dexlib2.iface.instruction.formats.Instruction35c
import org.jf.dexlib2.iface.reference.MethodReference
@Patch(false)
@DependsOn([TikTokIntegrationsPatch::class, TikTokSettingsPatch::class])
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("sim-spoof")
@Description("Spoofs the information which is retrieved from the sim-card.")
@SpoofSimCompatibility

View File

@@ -4,15 +4,23 @@ 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.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.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.twitch.ad.audio.annotations.AudioAdsCompatibility
import app.revanced.patches.twitch.ad.audio.fingerprints.AudioAdsPresenterPlayFingerprint
import app.revanced.patches.twitch.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("block-audio-ads")
@Description("Blocks audio ads in streams and VODs.")
@AudioAdsCompatibility
@@ -23,9 +31,37 @@ class AudioAdsPatch : BytecodePatch(
override fun execute(context: BytecodeContext): PatchResult {
// Block playAds call
with(AudioAdsPresenterPlayFingerprint.result!!) {
mutableMethod.addInstruction(0, "return-void")
mutableMethod.addInstructions(
0,
"""
invoke-static { }, Lapp/revanced/twitch/patches/AudioAdsPatch;->shouldBlockAudioAds()Z
move-result v0
if-eqz v0, :show_audio_ads
return-void
""",
listOf(ExternalLabel("show_audio_ads", mutableMethod.instruction(0)))
)
}
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
SwitchPreference(
"revanced_block_audio_ads",
StringResource(
"revanced_block_audio_ads",
"Block audio ads"
),
true,
StringResource(
"revanced_block_audio_ads_on",
"Audio ads are blocked"
),
StringResource(
"revanced_block_audio_ads_off",
"Audio ads are unblocked"
),
)
)
return PatchResultSuccess()
}
}

View File

@@ -4,18 +4,25 @@ 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.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.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.twitch.ad.video.annotations.VideoAdsCompatibility
import app.revanced.patches.twitch.ad.video.fingerprints.AdsManagerFingerprint
import app.revanced.patches.twitch.ad.video.fingerprints.CheckAdEligibilityLambdaFingerprint
import app.revanced.patches.twitch.ad.video.fingerprints.ContentConfigShowAdsFingerprint
import app.revanced.patches.twitch.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("block-video-ads")
@Description("Blocks video ads in streams and VODs.")
@VideoAdsCompatibility
@@ -27,24 +34,34 @@ class VideoAdsPatch : BytecodePatch(
CheckAdEligibilityLambdaFingerprint
)
) {
private fun createConditionInstructions(register: String = "v0") = """
invoke-static { }, Lapp/revanced/twitch/patches/VideoAdsPatch;->shouldBlockVideoAds()Z
move-result $register
if-eqz $register, :show_video_ads
"""
override fun execute(context: BytecodeContext): PatchResult {
// Pretend our player is ineligible for all ads
with(CheckAdEligibilityLambdaFingerprint.result!!) {
mutableMethod.addInstructions(
0,
"""
const/4 v0, 0
${createConditionInstructions()}
const/4 v0, 0
invoke-static {v0}, Lio/reactivex/Single;->just(Ljava/lang/Object;)Lio/reactivex/Single;
move-result-object p0
return-object p0
"""
""",
listOf(ExternalLabel("show_video_ads", mutableMethod.instruction(0)))
)
}
// Spoof showAds JSON field
with(ContentConfigShowAdsFingerprint.result!!) {
mutableMethod.addInstructions(0, """
${createConditionInstructions()}
const/4 v0, 0
:show_video_ads
return v0
"""
)
@@ -52,9 +69,35 @@ class VideoAdsPatch : BytecodePatch(
// Block playAds call
with(AdsManagerFingerprint.result!!) {
mutableMethod.addInstruction(0, "return-void")
mutableMethod.addInstructions(
0,
"""
${createConditionInstructions()}
return-void
""",
listOf(ExternalLabel("show_video_ads", mutableMethod.instruction(0)))
)
}
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
SwitchPreference(
"revanced_block_video_ads",
StringResource(
"revanced_block_video_ads",
"Block video ads"
),
true,
StringResource(
"revanced_block_video_ads_on",
"Video ads are blocked"
),
StringResource(
"revanced_block_video_ads_off",
"Video ads are unblocked"
),
)
)
return PatchResultSuccess()
}
}

View File

@@ -0,0 +1,9 @@
package app.revanced.patches.twitch.chat.antidelete.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object ChatUtilCreateDeletedSpanFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/ChatUtil\$Companion;") && methodDef.name == "createDeletedSpanFromChatMessageSpan"
}
)

View File

@@ -6,13 +6,19 @@ import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.*
import app.revanced.patcher.patch.*
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.shared.settings.preference.impl.ArrayResource
import app.revanced.patches.shared.settings.preference.impl.ListPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.twitch.chat.antidelete.annotations.ShowDeletedMessagesCompatibility
import app.revanced.patches.twitch.chat.antidelete.fingerprints.*
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction10x
import app.revanced.patches.twitch.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("show-deleted-messages")
@Description("Shows deleted chat messages behind a clickable spoiler.")
@ShowDeletedMessagesCompatibility
@@ -21,25 +27,77 @@ class ShowDeletedMessagesPatch : BytecodePatch(
listOf(
SetHasModAccessFingerprint,
DeletedMessageClickableSpanCtorFingerprint,
ChatUtilCreateDeletedSpanFingerprint
)
) {
private fun createSpoilerConditionInstructions(register: String = "v0") = """
invoke-static {}, Lapp/revanced/twitch/patches/ShowDeletedMessagesPatch;->shouldUseSpoiler()Z
move-result $register
if-eqz $register, :no_spoiler
"""
override fun execute(context: BytecodeContext): PatchResult {
// Force set hasModAccess member to true in constructor
// Spoiler mode: Force set hasModAccess member to true in constructor
with(DeletedMessageClickableSpanCtorFingerprint.result!!.mutableMethod) {
addInstructions(
implementation!!.instructions.lastIndex, /* place in front of return-void */
"""
${createSpoilerConditionInstructions()}
const/4 v0, 1
iput-boolean v0, p0, $definingClass->hasModAccess:Z
"""
""",
listOf(ExternalLabel("no_spoiler", instruction(implementation!!.instructions.lastIndex)))
)
}
// Disable setHasModAccess setter
with(SetHasModAccessFingerprint.result!!.mutableMethod.implementation!!) {
addInstruction(0, BuilderInstruction10x(Opcode.RETURN_VOID))
// Spoiler mode: Disable setHasModAccess setter
with(SetHasModAccessFingerprint.result!!) {
mutableMethod.addInstruction(0, "return-void")
}
// Cross-out mode: Reformat span of deleted message
with(ChatUtilCreateDeletedSpanFingerprint.result!!) {
mutableMethod.addInstructions(
0,
"""
invoke-static {p2}, Lapp/revanced/twitch/patches/ShowDeletedMessagesPatch;->reformatDeletedMessage(Landroid/text/Spanned;)Landroid/text/Spanned;
move-result-object v0
if-eqz v0, :no_reformat
return-object v0
""",
listOf(ExternalLabel("no_reformat", mutableMethod.instruction(0)))
)
}
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
ListPreference(
"revanced_show_deleted_messages",
StringResource(
"revanced_show_deleted_messages_title",
"Show deleted messages"
),
ArrayResource(
"revanced_deleted_messages",
listOf(
StringResource("revanced_deleted_messages_hide", "Do not show deleted messages"),
StringResource("revanced_deleted_messages_spoiler", "Hide deleted messages behind a spoiler"),
StringResource("revanced_deleted_messages_cross_out", "Show deleted messages as crossed-out text")
)
),
ArrayResource(
"revanced_deleted_messages_values",
listOf(
StringResource("key_revanced_deleted_messages_hide", "hide"),
StringResource("key_revanced_deleted_messages_spoiler", "spoiler"),
StringResource("key_revanced_deleted_messages_cross_out", "cross-out")
)
),
"cross-out"
)
)
SettingsPatch.addString("revanced_deleted_msg", "message deleted")
return PatchResultSuccess()
}
}

View File

@@ -8,13 +8,19 @@ import app.revanced.patcher.extensions.addInstructions
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.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.twitch.debug.annotations.DebugModeCompatibility
import app.revanced.patches.twitch.debug.fingerprints.IsDebugConfigEnabledFingerprint
import app.revanced.patches.twitch.debug.fingerprints.IsOmVerificationEnabledFingerprint
import app.revanced.patches.twitch.debug.fingerprints.ShouldShowDebugOptionsFingerprint
import app.revanced.patches.twitch.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.twitch.misc.settings.bytecode.patch.SettingsPatch
@Patch(false)
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@Name("debug-mode")
@Description("Enables Twitch's internal debugging mode.")
@DebugModeCompatibility
@@ -37,13 +43,34 @@ class DebugModePatch : BytecodePatch(
addInstructions(
0,
"""
const/4 v0, 0x1
invoke-static {}, Lapp/revanced/twitch/patches/DebugModePatch;->isDebugModeEnabled()Z
move-result v0
return v0
"""
)
}
}
}
SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences(
SwitchPreference(
"revanced_debug_mode",
StringResource(
"revanced_debug_mode_enable",
"Enable debug mode"
),
false,
StringResource(
"revanced_debug_mode_on",
"Debug mode is enabled (not recommended)"
),
StringResource(
"revanced_debug_mode_off",
"Debug mode is disabled"
),
)
)
return PatchResultSuccess()
}
}

View File

@@ -0,0 +1,9 @@
package app.revanced.patches.twitch.misc.settings.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("tv.twitch.android.app")])
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class SettingsCompatibility

View File

@@ -0,0 +1,195 @@
package app.revanced.patches.twitch.misc.settings.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.*
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
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.MutableField.Companion.toMutable
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen
import app.revanced.patches.twitch.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.twitch.misc.settings.annotations.SettingsCompatibility
import app.revanced.patches.twitch.misc.settings.components.CustomPreferenceCategory
import app.revanced.patches.twitch.misc.settings.fingerprints.*
import app.revanced.patches.twitch.misc.settings.resource.patch.SettingsResourcePatch
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.immutable.ImmutableField
@Patch
@DependsOn([IntegrationsPatch::class, SettingsResourcePatch::class])
@Name("settings")
@Description("Adds settings menu to Twitch.")
@SettingsCompatibility
@Version("0.0.1")
class SettingsPatch : BytecodePatch(
listOf(
SettingsActivityOnCreateFingerprint,
SettingsMenuItemEnumFingerprint,
MenuGroupsUpdatedFingerprint,
MenuGroupsOnClickFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
// Hook onCreate to handle fragment creation
with(SettingsActivityOnCreateFingerprint.result!!) {
val insertIndex = mutableMethod.implementation!!.instructions.size - 2
mutableMethod.addInstructions(
insertIndex,
"""
invoke-static {p0}, $SETTINGS_HOOKS_CLASS->handleSettingsCreation(Landroidx/appcompat/app/AppCompatActivity;)Z
move-result v0
if-eqz v0, :no_rv_settings_init
return-void
""",
listOf(ExternalLabel("no_rv_settings_init", mutableMethod.instruction(insertIndex)))
)
}
// Create new menu item for settings menu
with(SettingsMenuItemEnumFingerprint.result!!) {
injectMenuItem(
REVANCED_SETTINGS_MENU_ITEM_NAME,
REVANCED_SETTINGS_MENU_ITEM_ID,
REVANCED_SETTINGS_MENU_ITEM_TITLE_RES,
REVANCED_SETTINGS_MENU_ITEM_ICON_RES
)
}
// Intercept settings menu creation and add new menu item
with(MenuGroupsUpdatedFingerprint.result!!) {
mutableMethod.addInstructions(
0,
"""
sget-object v0, $MENU_ITEM_ENUM_CLASS->$REVANCED_SETTINGS_MENU_ITEM_NAME:$MENU_ITEM_ENUM_CLASS
invoke-static {p1, v0}, $SETTINGS_HOOKS_CLASS->handleSettingMenuCreation(Ljava/util/List;Ljava/lang/Object;)Ljava/util/List;
move-result-object p1
"""
)
}
// Intercept onclick events for the settings menu
with(MenuGroupsOnClickFingerprint.result!!) {
val insertIndex = 0
mutableMethod.addInstructions(
insertIndex,
"""
invoke-static {p1}, $SETTINGS_HOOKS_CLASS->handleSettingMenuOnClick(Ljava/lang/Enum;)Z
move-result p2
if-eqz p2, :no_rv_settings_onclick
sget-object p1, $MENU_DISMISS_EVENT_CLASS->INSTANCE:$MENU_DISMISS_EVENT_CLASS
invoke-virtual {p0, p1}, Ltv/twitch/android/core/mvp/viewdelegate/RxViewDelegate;->pushEvent(Ltv/twitch/android/core/mvp/viewdelegate/ViewDelegateEvent;)V
return-void
""",
listOf(ExternalLabel("no_rv_settings_onclick", mutableMethod.instruction(insertIndex)))
)
}
addString("revanced_settings", "ReVanced Settings", false)
addString("revanced_reboot_message", "Twitch needs to restart to apply your changes. Restart now?", false)
addString("revanced_reboot", "Restart", false)
addString("revanced_cancel", "Cancel", false)
return PatchResultSuccess()
}
internal companion object {
fun addString(identifier: String, value: String, formatted: Boolean = true) =
SettingsResourcePatch.addString(identifier, value, formatted)
fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) =
SettingsResourcePatch.addPreferenceScreen(preferenceScreen)
/* Private members */
private const val REVANCED_SETTINGS_MENU_ITEM_NAME = "RevancedSettings"
private const val REVANCED_SETTINGS_MENU_ITEM_ID = 0x7
private const val REVANCED_SETTINGS_MENU_ITEM_TITLE_RES = "revanced_settings"
private const val REVANCED_SETTINGS_MENU_ITEM_ICON_RES = "ic_settings"
private const val MENU_ITEM_ENUM_CLASS = "Ltv/twitch/android/feature/settings/menu/SettingsMenuItem;"
private const val MENU_DISMISS_EVENT_CLASS = "Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;"
private const val INTEGRATIONS_PACKAGE = "app/revanced/twitch"
private const val SETTINGS_HOOKS_CLASS = "L$INTEGRATIONS_PACKAGE/settingsmenu/SettingsHooks;"
private const val REVANCED_UTILS_CLASS = "L$INTEGRATIONS_PACKAGE/utils/ReVancedUtils;"
private fun MethodFingerprintResult.injectMenuItem(
name: String,
value: Int,
titleResourceName: String,
iconResourceName: String
) {
// Add new static enum member field
mutableClass.staticFields.add(
ImmutableField(
mutableMethod.definingClass,
name,
MENU_ITEM_ENUM_CLASS,
AccessFlags.PUBLIC or AccessFlags.FINAL or AccessFlags.ENUM or AccessFlags.STATIC,
null,
null,
null
).toMutable()
)
// Add initializer for the new enum member
mutableMethod.addInstructions(
mutableMethod.implementation!!.instructions.size - 4,
"""
new-instance v0, $MENU_ITEM_ENUM_CLASS
const-string v1, "$titleResourceName"
invoke-static {v1}, $REVANCED_UTILS_CLASS->getStringId(Ljava/lang/String;)I
move-result v1
const-string v3, "$iconResourceName"
invoke-static {v3}, $REVANCED_UTILS_CLASS->getDrawableId(Ljava/lang/String;)I
move-result v3
const-string v4, "$name"
const/4 v5, $value
invoke-direct {v0, v4, v5, v1, v3}, $MENU_ITEM_ENUM_CLASS-><init>(Ljava/lang/String;III)V
sput-object v0, $MENU_ITEM_ENUM_CLASS->$name:$MENU_ITEM_ENUM_CLASS
"""
)
}
}
/**
* Preference screens patches should add their settings to.
*/
internal object PreferenceScreen : AbstractPreferenceScreen() {
val ADS = CustomScreen("ads", "Ads", "Ad blocking settings")
val CHAT = CustomScreen("chat", "Chat", "Chat settings")
val MISC = CustomScreen("misc", "Misc", "Miscellaneous patches")
internal class CustomScreen(key: String, title: String, summary: String) : Screen(key, title, summary) {
/* Categories */
val GENERAL = CustomCategory("general", "General settings")
val OTHER = CustomCategory("other", "Other settings")
val CLIENT_SIDE = CustomCategory("client_ads", "Client-side ads")
internal inner class CustomCategory(key: String, title: String) : Screen.Category(key, title) {
/* For Twitch, we need to load our CustomPreferenceCategory class instead of the default one. */
override fun transform(): PreferenceCategory {
return CustomPreferenceCategory(
key,
StringResource("${key}_title", title),
preferences.sortedBy { it.title.value }
)
}
}
}
override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) {
addPreferenceScreen(screen)
}
}
override fun close() = PreferenceScreen.close()
}

View File

@@ -0,0 +1,20 @@
package app.revanced.patches.twitch.misc.settings.components
import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory
import app.revanced.patches.shared.settings.preference.impl.StringResource
/**
* Customized preference category for Twitch.
*
* @param key The key of the preference.
* @param title The title of the preference.
* @param preferences Child preferences of this category.
*/
internal open class CustomPreferenceCategory(
key: String,
title: StringResource,
preferences: List<BasePreference>
) : PreferenceCategory(key, title, preferences) {
override val tag: String = "app.revanced.twitch.settingsmenu.preference.CustomPreferenceCategory"
}

View File

@@ -0,0 +1,15 @@
package app.revanced.patches.twitch.misc.settings.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object MenuGroupsOnClickFingerprint : MethodFingerprint(
"V",
AccessFlags.PRIVATE or AccessFlags.STATIC or AccessFlags.FINAL,
listOf("L", "L", "L"),
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/SettingsMenuViewDelegate;")
&& methodDef.name.contains("render")
}
)

View File

@@ -0,0 +1,10 @@
package app.revanced.patches.twitch.misc.settings.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object MenuGroupsUpdatedFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/SettingsMenuPresenter\$Event\$MenuGroupsUpdated;")
&& methodDef.name == "<init>"
}
)

View File

@@ -0,0 +1,10 @@
package app.revanced.patches.twitch.misc.settings.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SettingsActivityOnCreateFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/SettingsActivity;") &&
methodDef.name == "onCreate"
}
)

View File

@@ -0,0 +1,9 @@
package app.revanced.patches.twitch.misc.settings.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SettingsMenuItemEnumFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.definingClass.endsWith("/SettingsMenuItem;") && methodDef.name == "<clinit>"
}
)

View File

@@ -0,0 +1,44 @@
package app.revanced.patches.twitch.misc.settings.resource.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.resource.patch.AbstractSettingsResourcePatch
import app.revanced.patches.twitch.misc.settings.annotations.SettingsCompatibility
@Name("settings-resource-patch")
@SettingsCompatibility
@Version("0.0.1")
class SettingsResourcePatch : AbstractSettingsResourcePatch(
"revanced_prefs",
"twitch/settings"
) {
internal companion object {
/* Companion delegates */
/**
* Add a new string to the resources.
*
* @param identifier The key of the string.
* @param value The value of the string.
* @throws IllegalArgumentException if the string already exists.
*/
fun addString(identifier: String, value: String, formatted: Boolean) =
AbstractSettingsResourcePatch.addString(identifier, value, formatted)
/**
* Add an array to the resources.
*
* @param arrayResource The array resource to add.
*/
fun addArray(arrayResource: ArrayResource) = AbstractSettingsResourcePatch.addArray(arrayResource)
/**
* Add a preference to the settings.
*
* @param preferenceScreen The name of the preference screen.
*/
fun addPreferenceScreen(preferenceScreen: PreferenceScreen) = AbstractSettingsResourcePatch.addPreference(preferenceScreen)
}
}

View File

@@ -7,10 +7,10 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.impl.InputType
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.impl.TextPreference
import app.revanced.patches.shared.settings.preference.impl.InputType
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.TextPreference
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
@@ -187,7 +187,7 @@ class GeneralAdsResourcePatch : ResourcePatch {
"Chapter teasers are shown"
)
),
app.revanced.patches.shared.settings.impl.PreferenceScreen(
app.revanced.patches.shared.settings.preference.impl.PreferenceScreen(
"revanced_adremover_custom",
StringResource("revanced_adremover_custom_title", "Custom filter"),
listOf(

View File

@@ -17,8 +17,8 @@ import app.revanced.patches.youtube.ad.video.fingerprints.LoadVideoAdsFingerprin
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playback.fix.patch.FixPlaybackPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, FixPlaybackPatch::class])

View File

@@ -8,10 +8,11 @@ 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.shared.settings.impl.*
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.impl.TextPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.TextPreference
import app.revanced.patches.shared.settings.preference.impl.InputType
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.youtube.interaction.downloads.annotation.DownloadsCompatibility
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.playercontrols.resource.patch.BottomControlsResourcePatch

View File

@@ -16,8 +16,8 @@ import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTapp
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingParentFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21t
import org.jf.dexlib2.iface.Method

View File

@@ -7,11 +7,11 @@ 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.shared.settings.impl.*
import app.revanced.patches.shared.settings.impl.PreferenceScreen
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.impl.TextPreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.TextPreference
import app.revanced.patches.shared.settings.preference.impl.InputType
import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.util.resources.ResourceUtils

View File

@@ -16,8 +16,8 @@ import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleBut
import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleTrackFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

View File

@@ -17,8 +17,8 @@ import app.revanced.patches.youtube.layout.autoplaybutton.fingerprints.LayoutCon
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction

View File

@@ -13,9 +13,9 @@ import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
import app.revanced.patches.youtube.layout.buttons.annotations.HideButtonsCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.PreferenceScreen
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([ResourceMappingPatch::class, LithoFilterPatch::class])

View File

@@ -14,8 +14,8 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.layout.castbutton.annotations.CastButtonCompatibility
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

View File

@@ -10,9 +10,9 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.comments.annotations.CommentsCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.PreferenceScreen
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Name("comments-resource-patch")
@CommentsCompatibility

View File

@@ -18,8 +18,8 @@ import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.Fullscr
import app.revanced.patches.youtube.layout.fullscreenpanels.fingerprints.FullscreenViewAdderParentFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@Name("disable-fullscreen-panels")

View File

@@ -10,8 +10,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.hidealbumcards.annotations.AlbumCardsCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Name("hide-album-cards-resource-patch")
@AlbumCardsCompatibility

View File

@@ -13,8 +13,8 @@ import app.revanced.patches.youtube.misc.litho.filter.patch.LithoFilterPatch
import app.revanced.patches.youtube.layout.buttons.annotations.HideArtistCardCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([ResourceMappingPatch::class, LithoFilterPatch::class])

View File

@@ -14,8 +14,8 @@ import app.revanced.patches.youtube.layout.autocaptions.annotations.AutoCaptions
import app.revanced.patches.youtube.layout.autocaptions.fingerprints.SubtitleButtonControllerFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import org.jf.dexlib2.Opcode
@Patch

View File

@@ -10,8 +10,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.hidecrowdfundingbox.annotations.CrowdfundingBoxCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Name("crowdfunding-box-resource-patch")
@CrowdfundingBoxCompatibility

View File

@@ -10,8 +10,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.hideendscreencards.annotations.HideEndscreenCardsCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Name("hide-endscreen-cards-resource-patch")
@HideEndscreenCardsCompatibility

View File

@@ -9,8 +9,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.hideinfocards.annotations.HideInfocardsCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@HideInfocardsCompatibility
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])

View File

@@ -17,8 +17,8 @@ import app.revanced.patches.youtube.layout.hidemixplaylists.fingerprints.CreateM
import app.revanced.patches.youtube.layout.hidemixplaylists.fingerprints.SecondCreateMixPlaylistFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch

View File

@@ -15,8 +15,8 @@ import app.revanced.patches.youtube.layout.hidetimeandseekbar.fingerprints.TimeC
import app.revanced.patches.youtube.layout.sponsorblock.bytecode.fingerprints.CreateVideoPlayerSeekbarFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

View File

@@ -14,8 +14,8 @@ import app.revanced.patches.youtube.layout.oldqualitylayout.annotations.OldQuali
import app.revanced.patches.youtube.layout.oldqualitylayout.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
@Patch

View File

@@ -10,8 +10,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.personalinformation.annotations.HideEmailAddressCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Name("hide-email-address-resource-patch")
@HideEmailAddressCompatibility

View File

@@ -1,13 +1,13 @@
package app.revanced.patches.youtube.layout.pivotbar.createbutton.annotations
package app.revanced.patches.youtube.layout.pivotbar.annotations
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")
"com.google.android.youtube", arrayOf("17.36.37", "17.41.37", "17.42.35", "17.43.36", "17.45.36")
)]
)
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
internal annotation class CreateButtonCompatibility
internal annotation class PivotBarCompatibility

View File

@@ -1,39 +1,39 @@
package app.revanced.patches.youtube.layout.pivotbar.createbutton.patch
import app.revanced.extensions.toErrorResult
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.MethodFingerprintExtensions.name
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.patches.youtube.layout.pivotbar.createbutton.annotations.CreateButtonCompatibility
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.layout.pivotbar.annotations.PivotBarCompatibility
import app.revanced.patches.youtube.layout.pivotbar.createbutton.fingerprints.PivotBarCreateButtonViewFingerprint
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarFingerprint
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.InitializeButtonsFingerprint
import app.revanced.patches.youtube.layout.pivotbar.resource.patch.ResolvePivotBarFingerprintsPatch
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.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, ResourceMappingPatch::class, SettingsPatch::class])
@DependsOn([IntegrationsPatch::class, ResourceMappingPatch::class, SettingsPatch::class, ResolvePivotBarFingerprintsPatch::class])
@Name("hide-create-button")
@Description("Hides the create button in the navigation bar.")
@CreateButtonCompatibility
@PivotBarCompatibility
@Version("0.0.1")
class CreateButtonRemoverPatch : BytecodePatch(
listOf(
PivotBarFingerprint
)
) {
class CreateButtonRemoverPatch : BytecodePatch() {
private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/HideCreateButtonPatch;"
}
override fun execute(context: BytecodeContext): PatchResult {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
@@ -49,10 +49,10 @@ class CreateButtonRemoverPatch : BytecodePatch(
* Resolve fingerprints
*/
val pivotBarResult = PivotBarFingerprint.result ?: return PatchResultError("PivotBarFingerprint failed")
if (!PivotBarCreateButtonViewFingerprint.resolve(context, pivotBarResult.mutableMethod, pivotBarResult.mutableClass))
return PatchResultError("${PivotBarCreateButtonViewFingerprint.name} failed")
InitializeButtonsFingerprint.result!!.let {
if (!PivotBarCreateButtonViewFingerprint.resolve(context, it.mutableMethod, it.mutableClass))
return PivotBarCreateButtonViewFingerprint.toErrorResult()
}
val createButtonResult = PivotBarCreateButtonViewFingerprint.result!!
val insertIndex = createButtonResult.scanResult.patternScanResult!!.endIndex
@@ -61,9 +61,8 @@ class CreateButtonRemoverPatch : BytecodePatch(
* Inject hooks
*/
val integrationsClass = "Lapp/revanced/integrations/patches/HideCreateButtonPatch;"
val hook =
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $integrationsClass->hideCreateButton(Landroid/view/View;)V"
val hook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideCreateButton(Landroid/view/View;)V"
createButtonResult.mutableMethod.injectHook(hook, insertIndex)

View File

@@ -0,0 +1,15 @@
package app.revanced.patches.youtube.layout.pivotbar.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.layout.pivotbar.resource.patch.ResolvePivotBarFingerprintsPatch
import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
object InitializeButtonsFingerprint : MethodFingerprint(
customFingerprint = { methodDef ->
methodDef.implementation?.instructions?.any {
it.opcode == Opcode.CONST && (it as WideLiteralInstruction).wideLiteral ==
ResolvePivotBarFingerprintsPatch.imageOnlyTabResourceId
} == true
}
)

View File

@@ -0,0 +1,10 @@
package app.revanced.patches.youtube.layout.pivotbar.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
object PivotBarConstructorFingerprint : MethodFingerprint(
access = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
strings = listOf("com.google.android.apps.youtube.app.endpoint.flags")
)

View File

@@ -1,44 +0,0 @@
package app.revanced.patches.youtube.layout.pivotbar.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@FuzzyPatternScanMethod(2)
object PivotBarFingerprint : MethodFingerprint(
"V",
AccessFlags.PUBLIC or AccessFlags.FINAL,
listOf("Z"),
listOf(
Opcode.IGET,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_NEZ,
Opcode.SGET_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT,
Opcode.IGET_OBJECT,
Opcode.IF_NEZ,
Opcode.SGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IF_NEZ,
Opcode.SGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.NEW_INSTANCE,
Opcode.NEW_INSTANCE,
Opcode.INVOKE_DIRECT,
Opcode.CONST,
Opcode.INVOKE_STATIC,
Opcode.MOVE_RESULT_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.MOVE_OBJECT,
Opcode.INVOKE_DIRECT_RANGE,
)
)

View File

@@ -0,0 +1,45 @@
package app.revanced.patches.youtube.layout.pivotbar.resource.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
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.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.layout.pivotbar.annotations.PivotBarCompatibility
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.InitializeButtonsFingerprint
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.PivotBarConstructorFingerprint
@DependsOn([ResourceMappingPatch::class])
@PivotBarCompatibility
@Description("Resolves necessary fingerprints.")
@Version("0.0.1")
class ResolvePivotBarFingerprintsPatch : BytecodePatch(
listOf(PivotBarConstructorFingerprint)
) {
internal companion object {
var imageOnlyTabResourceId: Long = -1
}
override fun execute(context: BytecodeContext): PatchResult {
// imageOnlyTabResourceId is used in InitializeButtonsFingerprint fingerprint
ResourceMappingPatch.resourceMappings.find { it.type == "layout" && it.name == "image_only_tab" }
?.let { imageOnlyTabResourceId = it.id } ?: return PatchResultError("Failed to find resource")
PivotBarConstructorFingerprint.result?.let {
// Resolve InitializeButtonsFingerprint on the class of the method
// which PivotBarConstructorFingerprint resolved to
if (!InitializeButtonsFingerprint.resolve(
context,
it.classDef
)
) return InitializeButtonsFingerprint.toErrorResult()
} ?: return PivotBarConstructorFingerprint.toErrorResult()
return PatchResultSuccess()
}
}

View File

@@ -1,13 +0,0 @@
package app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations
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 ShortsButtonCompatibility

View File

@@ -1,37 +1,39 @@
package app.revanced.patches.youtube.layout.pivotbar.shortsbutton.patch
import app.revanced.extensions.toErrorResult
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.MethodFingerprintExtensions.name
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.patches.youtube.layout.pivotbar.fingerprints.PivotBarFingerprint
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.annotations.ShortsButtonCompatibility
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.layout.pivotbar.annotations.PivotBarCompatibility
import app.revanced.patches.youtube.layout.pivotbar.fingerprints.InitializeButtonsFingerprint
import app.revanced.patches.youtube.layout.pivotbar.resource.patch.ResolvePivotBarFingerprintsPatch
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarEnumFingerprint
import app.revanced.patches.youtube.layout.pivotbar.shortsbutton.fingerprints.PivotBarShortsButtonViewFingerprint
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.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, ResolvePivotBarFingerprintsPatch::class])
@Name("hide-shorts-button")
@Description("Hides the shorts button on the navigation bar.")
@ShortsButtonCompatibility
@PivotBarCompatibility
@Version("0.0.1")
class ShortsButtonRemoverPatch : BytecodePatch(
listOf(PivotBarFingerprint)
) {
class ShortsButtonRemoverPatch : BytecodePatch() {
private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/patches/HideShortsButtonPatch;"
}
override fun execute(context: BytecodeContext): PatchResult {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
@@ -47,18 +49,21 @@ class ShortsButtonRemoverPatch : BytecodePatch(
* Resolve fingerprints
*/
val pivotBarResult = PivotBarFingerprint.result ?: return PatchResultError("PivotBarFingerprint failed")
val fingerprintResults = arrayOf(PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint)
.onEach {
val resolutionSucceeded = it.resolve(
context,
pivotBarResult.mutableMethod,
pivotBarResult.mutableClass
)
val initializeButtonsResult = InitializeButtonsFingerprint.result!!
val fingerprintResults =
arrayOf(PivotBarEnumFingerprint, PivotBarShortsButtonViewFingerprint)
.onEach {
if (!it.resolve(
context,
initializeButtonsResult.mutableMethod,
initializeButtonsResult.mutableClass
)
)
return it.toErrorResult()
}
.map { it.result!!.scanResult.patternScanResult!! }
if (!resolutionSucceeded) return PatchResultError("${it.name} failed")
}
.map { it.result!!.scanResult.patternScanResult!! }
val enumScanResult = fingerprintResults[0]
val buttonViewResult = fingerprintResults[1]
@@ -70,19 +75,17 @@ class ShortsButtonRemoverPatch : BytecodePatch(
* Inject hooks
*/
val integrationsClass = "Lapp/revanced/integrations/patches/HideShortsButtonPatch;"
val enumHook =
"sput-object v$REGISTER_TEMPLATE_REPLACEMENT, $integrationsClass->lastPivotTab:Ljava/lang/Enum;"
val buttonHook =
"invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, $integrationsClass->hideShortsButton(Landroid/view/View;)V"
val enumHook = "sput-object v$REGISTER_TEMPLATE_REPLACEMENT, " +
"$INTEGRATIONS_CLASS_DESCRIPTOR->lastPivotTab:Ljava/lang/Enum;"
val buttonHook = "invoke-static { v$REGISTER_TEMPLATE_REPLACEMENT }, " +
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideShortsButton(Landroid/view/View;)V"
// Inject bottom to top to not mess up the indices
mapOf(
buttonHook to buttonHookInsertIndex,
enumHook to enumHookInsertIndex
).forEach { (hook, insertIndex) ->
pivotBarResult.mutableMethod.injectHook(hook, insertIndex)
initializeButtonsResult.mutableMethod.injectHook(hook, insertIndex)
}
return PatchResultSuccess()

View File

@@ -14,8 +14,8 @@ import app.revanced.patches.youtube.layout.playerpopuppanels.annotations.PlayerP
import app.revanced.patches.youtube.layout.playerpopuppanels.fingerprints.EngagementPanelControllerFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

View File

@@ -12,8 +12,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.reels.annotations.HideReelsCompatibility
import app.revanced.patches.youtube.layout.reels.fingerprints.HideReelsFingerprint
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
//@Patch TODO: this is currently in the general-bytecode-ads patch due to the integrations having a preference for including reels or not. Move it here.
@Name("hide-reels")

View File

@@ -11,8 +11,8 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.Preference
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.Preference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings
@DependsOn([FixLocaleConfigErrorPatch::class, SettingsPatch::class])

View File

@@ -11,8 +11,8 @@ import app.revanced.patches.youtube.layout.sponsorblock.annotations.SponsorBlock
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.Preference
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.Preference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings
import app.revanced.util.resources.ResourceUtils.copyResources

View File

@@ -14,8 +14,8 @@ import app.revanced.patches.youtube.layout.startupshortsreset.annotations.Startu
import app.revanced.patches.youtube.layout.startupshortsreset.fingerprints.UserWasInShortsFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

View File

@@ -20,8 +20,8 @@ import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPla
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerResponseModelSizeCheckFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch

View File

@@ -14,8 +14,8 @@ import app.revanced.patches.youtube.layout.watchinvr.annotations.WatchinVRCompat
import app.revanced.patches.youtube.layout.watchinvr.fingerprints.WatchinVRFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

View File

@@ -18,8 +18,8 @@ import app.revanced.patches.youtube.layout.watermark.fingerprints.HideWatermarkF
import app.revanced.patches.youtube.layout.watermark.fingerprints.HideWatermarkParentFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import app.revanced.patches.shared.settings.impl.StringResource
import app.revanced.patches.shared.settings.impl.SwitchPreference
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
@Patch
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])

Some files were not shown because too many files have changed in this diff Show More