Compare commits

...

13 Commits

Author SHA1 Message Date
semantic-release-bot
c4b2e54b1e chore(release): 2.167.1 [skip ci]
## [2.167.1](https://github.com/revanced/revanced-patches/compare/v2.167.0...v2.167.1) (2023-04-13)

### Bug Fixes

* **youtube/spoof-signature-verification:** fixed subtitles in wrong location ([#1833](https://github.com/revanced/revanced-patches/issues/1833)) ([fb5380a](fb5380a03e))
* **youtube/spoof-signature-verification:** spoof videos in playlists ([8e59165](8e59165ad1))
2023-04-13 04:15:49 +00:00
LisoUseInAIKyrios
fb5380a03e fix(youtube/spoof-signature-verification): fixed subtitles in wrong location (#1833) 2023-04-13 06:11:48 +02:00
oSumAtrIX
8e59165ad1 fix(youtube/spoof-signature-verification): spoof videos in playlists 2023-04-13 06:11:46 +02:00
semantic-release-bot
b0ee6ebb99 chore(release): 2.167.0 [skip ci]
# [2.167.0](https://github.com/revanced/revanced-patches/compare/v2.166.0...v2.167.0) (2023-03-29)

### Bug Fixes

* **youtube/remember-playback-speed:**  allow to not remember playback speed ([#1762](https://github.com/revanced/revanced-patches/issues/1762)) ([708582f](708582ff03))
* **youtube/sponsorblock:** fix segments not skipping during background play ([#1765](https://github.com/revanced/revanced-patches/issues/1765)) ([45904f4](45904f4895))
* **youtube/spoof-signature-verification:** fix audio during home feed video playback ([#1754](https://github.com/revanced/revanced-patches/issues/1754)) ([c2dd63e](c2dd63e338))

### Features

* `export-all-activities` patch ([#1751](https://github.com/revanced/revanced-patches/issues/1751)) ([2e43d6f](2e43d6fcc1))
* **reddit:** bump compatibility to `2023.10.0` ([#1772](https://github.com/revanced/revanced-patches/issues/1772)) ([70d2d00](70d2d00b07))
* **twitter:** remove `monochrome-icon` patch ([#1786](https://github.com/revanced/revanced-patches/issues/1786)) ([45b2861](45b28613d3))
* **youtube/microg-support:** do not depend on `spoof-signature-verification` patch ([ce5bc27](ce5bc272bf))
* **youtube/spoof-signature-verification:** automatic signature spoofing ([025092a](025092a2ff))
2023-03-29 04:28:23 +00:00
oSumAtrIX
8950648370 chore: merge branch dev to main (#1755) 2023-03-29 06:26:07 +02:00
semantic-release-bot
e3eafd9fbb chore(release): 2.167.0-dev.6 [skip ci]
# [2.167.0-dev.6](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.5...v2.167.0-dev.6) (2023-03-22)

### Features

* **twitter:** remove `monochrome-icon` patch ([#1786](https://github.com/revanced/revanced-patches/issues/1786)) ([45b2861](45b28613d3))
2023-03-22 20:36:40 +00:00
Ax333l
45b28613d3 feat(twitter): remove monochrome-icon patch (#1786) 2023-03-22 21:33:43 +01:00
semantic-release-bot
a3b8fb5c11 chore(release): 2.167.0-dev.5 [skip ci]
# [2.167.0-dev.5](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.4...v2.167.0-dev.5) (2023-03-20)

### Features

* **reddit:** bump compatibility to `2023.10.0` ([#1772](https://github.com/revanced/revanced-patches/issues/1772)) ([70d2d00](70d2d00b07))
2023-03-20 15:41:18 +00:00
EvadeMaster
65ace4b47a refactor(ticktick): clarify unlock-themes description (#1773) 2023-03-20 16:37:41 +01:00
EvadeMaster
70d2d00b07 feat(reddit): bump compatibility to 2023.10.0 (#1772) 2023-03-20 16:36:00 +01:00
semantic-release-bot
096d0d516f chore(release): 2.167.0-dev.4 [skip ci]
# [2.167.0-dev.4](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.3...v2.167.0-dev.4) (2023-03-19)

### Bug Fixes

* **youtube/sponsorblock:** fix segments not skipping during background play ([#1765](https://github.com/revanced/revanced-patches/issues/1765)) ([45904f4](45904f4895))

### Features

* `export-all-activities` patch ([#1751](https://github.com/revanced/revanced-patches/issues/1751)) ([2e43d6f](2e43d6fcc1))
2023-03-19 22:23:15 +00:00
LisoUseInAIKyrios
45904f4895 fix(youtube/sponsorblock): fix segments not skipping during background play (#1765)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-03-20 02:21:34 +04:00
Bennett
2e43d6fcc1 feat: export-all-activities patch (#1751)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
2023-03-19 23:20:49 +01:00
16 changed files with 231 additions and 108 deletions

View File

@@ -1,3 +1,55 @@
## [2.167.1](https://github.com/revanced/revanced-patches/compare/v2.167.0...v2.167.1) (2023-04-13)
### Bug Fixes
* **youtube/spoof-signature-verification:** fixed subtitles in wrong location ([#1833](https://github.com/revanced/revanced-patches/issues/1833)) ([0dbfa62](https://github.com/revanced/revanced-patches/commit/0dbfa6247e6e7ff51e8fee86fd798f693ab05bcf))
* **youtube/spoof-signature-verification:** spoof videos in playlists ([0a858ec](https://github.com/revanced/revanced-patches/commit/0a858ecef3f152dfd97e7f2d27501201968de4e4))
# [2.167.0](https://github.com/revanced/revanced-patches/compare/v2.166.0...v2.167.0) (2023-03-29)
### Bug Fixes
* **youtube/remember-playback-speed:** allow to not remember playback speed ([#1762](https://github.com/revanced/revanced-patches/issues/1762)) ([49ec3e8](https://github.com/revanced/revanced-patches/commit/49ec3e83f18ec4eb180d220c5a7015f8e4feb3a7))
* **youtube/sponsorblock:** fix segments not skipping during background play ([#1765](https://github.com/revanced/revanced-patches/issues/1765)) ([7620ea1](https://github.com/revanced/revanced-patches/commit/7620ea1752406d703deb15aa0267d4572b1b171a))
* **youtube/spoof-signature-verification:** fix audio during home feed video playback ([#1754](https://github.com/revanced/revanced-patches/issues/1754)) ([7dd067b](https://github.com/revanced/revanced-patches/commit/7dd067b0e96679fe653c9796bef31d743287b2d0))
### Features
* `export-all-activities` patch ([#1751](https://github.com/revanced/revanced-patches/issues/1751)) ([aad6e05](https://github.com/revanced/revanced-patches/commit/aad6e055380f91462d94fc96c4ec17a27e283c64))
* **reddit:** bump compatibility to `2023.10.0` ([#1772](https://github.com/revanced/revanced-patches/issues/1772)) ([f95ab6e](https://github.com/revanced/revanced-patches/commit/f95ab6e13e70667fdffe479b7292112244e6bb9e))
* **twitter:** remove `monochrome-icon` patch ([#1786](https://github.com/revanced/revanced-patches/issues/1786)) ([b8bf804](https://github.com/revanced/revanced-patches/commit/b8bf804835e75c9f2c8453c8ce22cfd8d17318ce))
* **youtube/microg-support:** do not depend on `spoof-signature-verification` patch ([af4e765](https://github.com/revanced/revanced-patches/commit/af4e765ca87c6c979e95bc274b32c764a0a32a88))
* **youtube/spoof-signature-verification:** automatic signature spoofing ([f1395f4](https://github.com/revanced/revanced-patches/commit/f1395f49fae1c0a00de074d58fa7d81f562d3009))
# [2.167.0-dev.6](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.5...v2.167.0-dev.6) (2023-03-22)
### Features
* **twitter:** remove `monochrome-icon` patch ([#1786](https://github.com/revanced/revanced-patches/issues/1786)) ([b8bf804](https://github.com/revanced/revanced-patches/commit/b8bf804835e75c9f2c8453c8ce22cfd8d17318ce))
# [2.167.0-dev.5](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.4...v2.167.0-dev.5) (2023-03-20)
### Features
* **reddit:** bump compatibility to `2023.10.0` ([#1772](https://github.com/revanced/revanced-patches/issues/1772)) ([f95ab6e](https://github.com/revanced/revanced-patches/commit/f95ab6e13e70667fdffe479b7292112244e6bb9e))
# [2.167.0-dev.4](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.3...v2.167.0-dev.4) (2023-03-19)
### Bug Fixes
* **youtube/sponsorblock:** fix segments not skipping during background play ([#1765](https://github.com/revanced/revanced-patches/issues/1765)) ([7620ea1](https://github.com/revanced/revanced-patches/commit/7620ea1752406d703deb15aa0267d4572b1b171a))
### Features
* `export-all-activities` patch ([#1751](https://github.com/revanced/revanced-patches/issues/1751)) ([aad6e05](https://github.com/revanced/revanced-patches/commit/aad6e055380f91462d94fc96c4ec17a27e283c64))
# [2.167.0-dev.3](https://github.com/revanced/revanced-patches/compare/v2.167.0-dev.2...v2.167.0-dev.3) (2023-03-19)

View File

@@ -136,7 +136,6 @@ The official Patch bundle provided by ReVanced and the community.
| `hide-ads` | Hides ads. | all |
| `hide-recommended-users` | Hides recommended users. | all |
| `hide-views-stats` | Hides the view stats under tweets. | 9.71.0-release.0 |
| `monochrome-icon` | Adds a monochrome icon. | all |
</details>
### [📦 `com.spotify.music`](https://play.google.com/store/apps/details?id=com.spotify.music)
@@ -154,8 +153,8 @@ The official Patch bundle provided by ReVanced and the community.
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `general-reddit-ads` | Removes general ads from the Reddit frontpage and subreddits. | 2023.09.1 |
| `hide-subreddit-banner` | Hides banner ads from comments on subreddits. | 2023.09.1 |
| `general-reddit-ads` | Removes general ads from the Reddit frontpage and subreddits. | 2023.10.0 |
| `hide-subreddit-banner` | Hides banner ads from comments on subreddits. | 2023.10.0 |
| `premium-icon-reddit` | Unlocks premium Reddit app icons. | all |
</details>
@@ -290,6 +289,30 @@ The official Patch bundle provided by ReVanced and the community.
| `unlock-prime` | Unlocks Nova Prime and all functions of the app. | all |
</details>
### [📦 `ginlemon.iconpackstudio`](https://play.google.com/store/apps/details?id=ginlemon.iconpackstudio)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-pro` | Unlocks all pro features. | all |
</details>
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-pro` | Unlocks all pro features. | all |
</details>
### [📦 `com.ithebk.expensemanager`](https://play.google.com/store/apps/details?id=com.ithebk.expensemanager)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-pro` | Unlocks pro features. | all |
</details>
### [📦 `org.totschnig.myexpenses`](https://play.google.com/store/apps/details?id=org.totschnig.myexpenses)
<details>
@@ -306,36 +329,12 @@ The official Patch bundle provided by ReVanced and the community.
| `unlock-pro` | Unlocks all pro features. | all |
</details>
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-pro` | Unlocks all pro features. | all |
</details>
### [📦 `ginlemon.iconpackstudio`](https://play.google.com/store/apps/details?id=ginlemon.iconpackstudio)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-pro` | Unlocks all pro features. | all |
</details>
### [📦 `com.ithebk.expensemanager`](https://play.google.com/store/apps/details?id=com.ithebk.expensemanager)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-pro` | Unlocks pro features. | all |
</details>
### [📦 `com.ticktick.task`](https://play.google.com/store/apps/details?id=com.ticktick.task)
<details>
| 💊 Patch | 📜 Description | 🏹 Target Version |
|:--------:|:--------------:|:-----------------:|
| `unlock-themes` | Unlocks all themes. | all |
| `unlock-themes` | Unlocks all themes that are inaccessible until a certain level is reached. | all |
</details>
### [📦 `net.dinglisch.android.taskerm`](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm)

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official
version = 2.167.0-dev.3
version = 2.167.1

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,45 @@
package app.revanced.patches.all.activity.exportAll.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.Patch
@Patch(false)
@Name("export-all-activities")
@Description("Makes all app activities exportable.")
@Version("0.0.1")
class ExportAllActivitiesPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
context.xmlEditor["AndroidManifest.xml"].use { editor ->
val document = editor.file
val activities = document.getElementsByTagName("activity")
for(i in 0..activities.length) {
activities.item(i)?.apply {
val exportedAttribute = attributes.getNamedItem(EXPORTED_FLAG)
if (exportedAttribute != null) {
if (exportedAttribute.nodeValue != "true")
exportedAttribute.nodeValue = "true"
}
// Reason why the attribute is added in the case it does not exist:
// https://github.com/revanced/revanced-patches/pull/1751/files#r1141481604
else document.createAttribute(EXPORTED_FLAG)
.apply { value = "true" }
.let(attributes::setNamedItem)
}
}
}
return PatchResultSuccess()
}
private companion object {
const val EXPORTED_FLAG = "android:exported"
}
}

View File

@@ -12,7 +12,8 @@ import app.revanced.patcher.annotation.Package
"2023.07.1",
"2023.08.0",
"2023.09.0",
"2023.09.1"
"2023.09.1",
"2023.10.0"
)
)]
)

View File

@@ -14,7 +14,8 @@ import app.revanced.patcher.annotation.Package
"2023.07.1",
"2023.08.0",
"2023.09.0",
"2023.09.1"
"2023.09.1",
"2023.10.0"
)
)]
)

View File

@@ -16,7 +16,7 @@ import app.revanced.patches.ticktick.misc.themeunlock.fingerprints.SetThemeFinge
@Patch
@Name("unlock-themes")
@Description("Unlocks all themes.")
@Description("Unlocks all themes that are inaccessible until a certain level is reached.")
@UnlockThemesCompatibility
@Version("0.0.1")
class UnlockProPatch : BytecodePatch(

View File

@@ -1,8 +0,0 @@
package app.revanced.patches.twitter.misc.monochrome.annotations
import app.revanced.patcher.annotation.Compatibility
import app.revanced.patcher.annotation.Package
@Compatibility([Package("com.twitter.android")])
@Target(AnnotationTarget.CLASS)
internal annotation class MonochromeIconCompatibility

View File

@@ -1,55 +0,0 @@
package app.revanced.patches.twitter.misc.monochrome.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.twitter.misc.monochrome.annotations.MonochromeIconCompatibility
import java.io.FileWriter
import java.nio.file.Files
@Patch
@Name("monochrome-icon")
@Description("Adds a monochrome icon.")
@MonochromeIconCompatibility
@Version("0.0.1")
class MonochromeIconPatch : ResourcePatch {
override fun execute(context: ResourceContext): PatchResult {
val resDirectory = context["res"]
if (!resDirectory.isDirectory) return PatchResultError("The res folder can not be found.")
val mipmapV33Directory = resDirectory.resolve("mipmap-anydpi-v33")
if (!mipmapV33Directory.isDirectory) Files.createDirectories(mipmapV33Directory.toPath())
FileWriter(mipmapV33Directory.resolve("ic_launcher_twitter.xml")).use {
it.write(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<adaptive-icon\n" +
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
" <background android:drawable=\"@color/ic_launcher_background\" />\n" +
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
"</adaptive-icon>"
)
}
FileWriter(mipmapV33Directory.resolve("ic_launcher_twitter_round.xml")).use {
it.write(
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<adaptive-icon\n" +
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
" <background android:drawable=\"@color/ic_launcher_background\" />\n" +
" <foreground android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
" <monochrome android:drawable=\"@mipmap/ic_launcher_twitter_foreground\" />\n" +
"</adaptive-icon>"
)
}
return PatchResultSuccess()
}
}

View File

@@ -81,7 +81,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
/*
Set current video id
*/
VideoIdPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
VideoIdPatch.injectCallBackgroundPlay("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
/*
Seekbar drawing

View File

@@ -0,0 +1,11 @@
package app.revanced.patches.youtube.misc.fix.playback.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
object SubtitleWindowSettingsConstructorFingerprint : MethodFingerprint(
parameters = listOf("I", "I", "I", "Z", "Z"),
customFingerprint = { methodDef ->
methodDef.definingClass == "Lcom/google/android/libraries/youtube/player/subtitles/model/SubtitleWindowSettings;"
&& methodDef.name == "<init>"
}
)

View File

@@ -19,7 +19,9 @@ import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
import app.revanced.patches.youtube.misc.fix.playback.annotation.ProtobufSpoofCompatibility
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.OpenCronetDataSourceFingerprint
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.ProtobufParameterBuilderFingerprint
import app.revanced.patches.youtube.misc.fix.playback.fingerprints.SubtitleWindowSettingsConstructorFingerprint
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@@ -27,12 +29,13 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("spoof-signature-verification")
@Description("Spoofs the client to prevent playback issues.")
@ProtobufSpoofCompatibility
@DependsOn([IntegrationsPatch::class, SettingsPatch::class])
@DependsOn([IntegrationsPatch::class, SettingsPatch::class, PlayerTypeHookPatch::class])
@Version("0.0.1")
class SpoofSignatureVerificationPatch : BytecodePatch(
listOf(
ProtobufParameterBuilderFingerprint,
OpenCronetDataSourceFingerprint,
SubtitleWindowSettingsConstructorFingerprint,
)
) {
override fun execute(context: BytecodeContext): PatchResult {
@@ -82,6 +85,25 @@ class SpoofSignatureVerificationPatch : BytecodePatch(
} ?: return OpenCronetDataSourceFingerprint.toErrorResult()
// hook override subtitles
SubtitleWindowSettingsConstructorFingerprint.result?.let {
it.mutableMethod.apply {
addInstructions(
0,
"""
invoke-static {p1, p2, p3, p4, p5}, $INTEGRATIONS_CLASS_DESCRIPTOR->getSubtitleWindowSettingsOverride(IIIZZ)[I
move-result-object v0
const/4 v1, 0x0
aget p1, v0, v1 # ap, anchor configuration
const/4 v1, 0x1
aget p2, v0, v1 # ah, horizontal anchor
const/4 v1, 0x2
aget p3, v0, v1 # av, vertical anchor
"""
)
}
} ?: return SubtitleWindowSettingsConstructorFingerprint.toErrorResult()
return PatchResultSuccess()
}

View File

@@ -98,7 +98,9 @@ class VideoInformationPatch : BytecodePatch(
/*
Inject call for video id
*/
VideoIdPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V")
val videoIdMethodDescriptor = "$INTEGRATIONS_CLASS_DESCRIPTOR->setVideoId(Ljava/lang/String;)V"
VideoIdPatch.injectCall(videoIdMethodDescriptor)
VideoIdPatch.injectCallBackgroundPlay(videoIdMethodDescriptor)
/*
Set the video time method

View File

@@ -0,0 +1,16 @@
package app.revanced.patches.youtube.misc.video.videoid.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
object VideoIdFingerprintBackgroundPlay : MethodFingerprint(
returnType = "V",
access = AccessFlags.DECLARED_SYNCHRONIZED or AccessFlags.FINAL or AccessFlags.PUBLIC,
parameters = listOf("L"),
opcodes = listOf(Opcode.INVOKE_INTERFACE),
customFingerprint = {
it.definingClass.endsWith("PlaybackLifecycleMonitor;")
}
)

View File

@@ -15,6 +15,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.video.videoid.annotation.VideoIdCompatibility
import app.revanced.patches.youtube.misc.video.videoid.fingerprint.VideoIdFingerprint
import app.revanced.patches.youtube.misc.video.videoid.fingerprint.VideoIdFingerprintBackgroundPlay
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("video-id-hook")
@@ -23,30 +24,50 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Version("0.0.1")
@DependsOn([IntegrationsPatch::class])
class VideoIdPatch : BytecodePatch(
listOf(VideoIdFingerprint)
listOf(VideoIdFingerprint, VideoIdFingerprintBackgroundPlay)
) {
override fun execute(context: BytecodeContext): PatchResult {
VideoIdFingerprint.result?.let {
val videoIdRegisterInstructionIndex = it.scanResult.patternScanResult!!.endIndex
VideoIdFingerprint.result?.let { result ->
val videoIdRegisterInstructionIndex = result.scanResult.patternScanResult!!.endIndex
with(it.mutableMethod) {
insertMethod = this
result.mutableMethod.also {
insertMethod = it
}.apply {
videoIdRegister = (instruction(videoIdRegisterInstructionIndex) as OneRegisterInstruction).registerA
insertIndex = videoIdRegisterInstructionIndex + 1
}
} ?: return VideoIdFingerprint.toErrorResult()
VideoIdFingerprintBackgroundPlay.result?.let { result ->
val endIndex = result.scanResult.patternScanResult!!.endIndex
result.mutableMethod.also {
backgroundPlaybackMethod = it
}.apply {
backgroundPlaybackVideoIdRegister = (instruction(endIndex + 1) as OneRegisterInstruction).registerA
backgroundPlaybackInsertIndex = endIndex + 2
}
} ?: return VideoIdFingerprintBackgroundPlay.toErrorResult()
return PatchResultSuccess()
}
companion object {
private var videoIdRegister = 0
private var insertIndex = 0
private lateinit var insertMethod: MutableMethod
private var backgroundPlaybackVideoIdRegister = 0
private var backgroundPlaybackInsertIndex = 0
private lateinit var backgroundPlaybackMethod: MutableMethod
/**
* Adds an invoke-static instruction, called with the new id when the video changes.
*
* Supports all videos (regular videos, Shorts and Stories).
*
* _Does not function if playing in the background with no video visible_.
*
* Be aware, this can be called multiple times for the same video id.
*
* @param methodDescriptor which method to call. Params have to be `Ljava/lang/String;`
@@ -54,12 +75,28 @@ class VideoIdPatch : BytecodePatch(
fun injectCall(
methodDescriptor: String
) = insertMethod.addInstructions(
// Keep injection calls in the order they're added.
// Order has been proven to be important for the same reason that order of patch execution is important
// such as for the VideoInformation patch.
// Keep injection calls in the order they're added:
// Increment index. So if additional injection calls are added, those calls run after this injection call.
insertIndex++,
"invoke-static {v$videoIdRegister}, $methodDescriptor"
)
/**
* Alternate hook that supports only regular videos, but hook supports changing to new video
* during background play when no video is visible.
*
* _Does not support Shorts or Stories_.
*
* Be aware, the hook can be called multiple times for the same video id.
*
* @param methodDescriptor which method to call. Params have to be `Ljava/lang/String;`
*/
fun injectCallBackgroundPlay(
methodDescriptor: String
) = backgroundPlaybackMethod.addInstructions(
backgroundPlaybackInsertIndex++, // move-result-object offset
"invoke-static {v$backgroundPlaybackVideoIdRegister}, $methodDescriptor"
)
}
}