forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
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
hide-latest-videos-button
patch
- Loading branch information
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
.../patches/youtube/general/latestvideosbutton/fingerprints/LatestVideosButtonFingerprint.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,21 @@ | ||
package app.revanced.patches.youtube.general.latestvideosbutton.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.Bar | ||
import app.revanced.util.bytecode.isWideLiteralExists | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
import com.android.tools.smali.dexlib2.Opcode | ||
|
||
object LatestVideosButtonFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, | ||
parameters = listOf("L", "Z"), | ||
opcodes = listOf( | ||
Opcode.CONST, | ||
Opcode.IGET_OBJECT, | ||
Opcode.INVOKE_VIRTUAL, | ||
Opcode.MOVE_RESULT_OBJECT | ||
), | ||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(Bar) } | ||
) |
63 changes: 63 additions & 0 deletions
63
.../app/revanced/patches/youtube/general/latestvideosbutton/patch/LatestVideosButtonPatch.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,63 @@ | ||
package app.revanced.patches.youtube.general.latestvideosbutton.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.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
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.youtube.general.latestvideosbutton.fingerprints.LatestVideosButtonFingerprint | ||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility | ||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch | ||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch | ||
import app.revanced.util.integrations.Constants.GENERAL | ||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch | ||
@Name("Hide latest videos button") | ||
@Description("Hides latest videos button in home feed.") | ||
@DependsOn( | ||
[ | ||
SettingsPatch::class, | ||
SharedResourceIdPatch::class, | ||
] | ||
) | ||
@YouTubeCompatibility | ||
@Version("0.0.1") | ||
class LatestVideosButtonPatch : BytecodePatch( | ||
listOf(LatestVideosButtonFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
LatestVideosButtonFingerprint.result?.let { | ||
it.mutableMethod.apply { | ||
val targetIndex = it.scanResult.patternScanResult!!.endIndex | ||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA | ||
|
||
addInstruction( | ||
targetIndex + 1, | ||
"invoke-static {v$targetRegister}, $GENERAL->hideLatestVideosButton(Landroid/view/View;)V" | ||
) | ||
} | ||
} ?: return LatestVideosButtonFingerprint.toErrorResult() | ||
|
||
/** | ||
* Add settings | ||
*/ | ||
SettingsPatch.addPreference( | ||
arrayOf( | ||
"PREFERENCE: GENERAL_SETTINGS", | ||
"SETTINGS: HIDE_LATEST_VIDEOS_BUTTON" | ||
) | ||
) | ||
|
||
SettingsPatch.updatePatchStatus("hide-latest-videos-button") | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |
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