-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube): Add
Watch history
patch
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/app/revanced/patches/youtube/misc/watchhistory/WatchHistoryPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package app.revanced.patches.youtube.misc.watchhistory | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patches.youtube.misc.watchhistory.fingerprints.TrackingUrlModelFingerprint | ||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE | ||
import app.revanced.patches.youtube.utils.integrations.Constants.MISC_PATH | ||
import app.revanced.patches.youtube.utils.settings.SettingsPatch | ||
import app.revanced.util.patch.BaseBytecodePatch | ||
import app.revanced.util.resultOrThrow | ||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction | ||
|
||
@Suppress("unused") | ||
object WatchHistoryPatch : BaseBytecodePatch( | ||
name = "Watch history", | ||
description = "Adds an option to change the domain of the watch history or check its status.", | ||
dependencies = setOf(SettingsPatch::class), | ||
compatiblePackages = COMPATIBLE_PACKAGE, | ||
fingerprints = setOf(TrackingUrlModelFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
|
||
TrackingUrlModelFingerprint.resultOrThrow().let { | ||
it.mutableMethod.apply { | ||
val targetIndex = it.scanResult.patternScanResult!!.startIndex | ||
val targetRegister = getInstruction<TwoRegisterInstruction>(targetIndex).registerA | ||
|
||
addInstructions( | ||
targetIndex + 1, """ | ||
invoke-static {v$targetRegister}, $MISC_PATH/WatchHistoryPatch;->replaceTrackingUrl(Ljava/lang/String;)Ljava/lang/String; | ||
move-result-object v$targetRegister | ||
""" | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* Add settings | ||
*/ | ||
SettingsPatch.addPreference( | ||
arrayOf( | ||
"SETTINGS: WATCH_HISTORY" | ||
) | ||
) | ||
|
||
SettingsPatch.updatePatchStatus(this) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...pp/revanced/patches/youtube/misc/watchhistory/fingerprints/TrackingUrlModelFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package app.revanced.patches.youtube.misc.watchhistory.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
internal object TrackingUrlModelFingerprint : MethodFingerprint( | ||
returnType = "Landroid/net/Uri;", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
parameters = emptyList(), | ||
opcodes = listOf( | ||
Opcode.IGET_OBJECT, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
), | ||
customFingerprint = { methodDef, _ -> | ||
methodDef.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/player/TrackingUrlModel;" | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters