refactor: integrations (#44)

This commit is contained in:
Joey Peter
2022-06-24 00:17:49 +02:00
committed by GitHub
parent d5597fb002
commit ccf0218b6c
12 changed files with 18 additions and 19 deletions
+1 -2
View File
@@ -1,2 +1 @@
# revanced-patches Repo for all ReVanced patches
Repo for all ReVanced patches
@@ -10,7 +10,7 @@ internal fun MutableMethodImplementation.injectHideCall(
) { ) {
this.addInstruction( this.addInstruction(
index, index,
"invoke-static { v$register }, Lfi/razerman/youtube/XAdRemover;->HideView(Landroid/view/View;)V".toInstruction() "invoke-static { v$register }, Lapp/revanced/integrations/patches/HideHomeAdsPatch;->HideHomeAds(Landroid/view/View;)V".toInstruction()
) )
} }
@@ -249,7 +249,7 @@ class GeneralBytecodeAdsPatch : BytecodePatch(
val block2 = """ val block2 = """
move-object/from16 v1, p3 move-object/from16 v1, p3
iget-object v2, v1, $templateNameParameterType->b:Ljava/nio/ByteBuffer; iget-object v2, v1, $templateNameParameterType->b:Ljava/nio/ByteBuffer;
invoke-static {v0, v2}, Lfi/razerman/youtube/litho/LithoAdRemoval;->containsAd(Ljava/lang/String;Ljava/nio/ByteBuffer;)Z invoke-static {v0, v2}, Lapp/revanced/integrations/patches/GeneralBytecodeAdsPatch;->containsAd(Ljava/lang/String;Ljava/nio/ByteBuffer;)Z
move-result v1 move-result v1
""".trimIndent().toInstructions(lithoMethod) """.trimIndent().toInstructions(lithoMethod)
val block3 = """ val block3 = """
@@ -42,7 +42,7 @@ class VideoAdsPatch : BytecodePatch(
// Override the parameter by calling shouldShowAds and setting the parameter to the result // Override the parameter by calling shouldShowAds and setting the parameter to the result
result.method.addInstructions( result.method.addInstructions(
0, """ 0, """
invoke-static { }, Lfi/vanced/libraries/youtube/whitelisting/Whitelist;->shouldShowAds()Z invoke-static { }, Lapp/revanced/integrations/patches/VideoAdsPatch;->shouldShowAds()Z
move-result v1 move-result v1
""" """
) )
@@ -86,7 +86,7 @@ class EnableSeekbarTappingPatch : BytecodePatch(
) )
result.method.addInstructions( result.method.addInstructions(
result.scanResult.endIndex + 1, """ result.scanResult.endIndex + 1, """
invoke-static { }, Lfi/razerman/youtube/preferences/BooleanPreferences;->isTapSeekingEnabled()Z invoke-static { }, Lapp/revanced/integrations/patches/SeekbarTappingPatch;->isTapSeekingEnabled()Z
move-result v0 move-result v0
""" """
) )
@@ -30,7 +30,7 @@ class HideCastButtonPatch : BytecodePatch(listOf()) {
setVisibilityMethod.addInstructions( setVisibilityMethod.addInstructions(
0, """ 0, """
invoke-static {p1}, Lfi/razerman/youtube/XGlobals;->getCastButtonOverrideV2(I)I invoke-static {p1}, Lapp/revanced/integrations/patches/HideCastButtonPatch;->getCastButtonOverrideV2(I)I
move-result p1 move-result p1
""" """
) )
@@ -54,8 +54,8 @@ class CreateButtonRemoverPatch : BytecodePatch(
// Hide the button view via proxy by passing it to the hideCreateButton method // Hide the button view via proxy by passing it to the hideCreateButton method
result.method.addInstruction( result.method.addInstruction(
moveResultIndex + 1, result.scanResult.endIndex + 1,
"invoke-static { v${moveResultInstruction.registerA} }, Lfi/razerman/youtube/XAdRemover;->hideCreateButton(Landroid/view/View;)V" "invoke-static { v$moveResultInstruction.registerA }, Lapp/revanced/integrations/patches/HideCreateButtonPatch;->hideCreateButton(Landroid/view/View;)V"
) )
return PatchResultSuccess() return PatchResultSuccess()
@@ -58,7 +58,7 @@ class OldQualityLayoutPatch : BytecodePatch(
implementation.addInstruction(5, jmpInstruction) implementation.addInstruction(5, jmpInstruction)
result.method.addInstructions( result.method.addInstructions(
0, """ 0, """
invoke-static { }, Lfi/razerman/youtube/XGlobals;->useOldStyleQualitySettings()Z invoke-static { }, Lapp/revanced/integrations/patches/OldStyleQualityPatch;->useOldStyleQualitySettings()Z
move-result v0 move-result v0
""" """
) )
@@ -28,7 +28,7 @@ class HideReelsPatch : BytecodePatch(
// so we pass the view to the HideReel method // so we pass the view to the HideReel method
result.method.addInstruction( result.method.addInstruction(
result.scanResult.endIndex, result.scanResult.endIndex,
"invoke-static { v2 }, Lfi/razerman/youtube/XAdRemover;->HideReel(Landroid/view/View;)V" "invoke-static { v2 }, Lapp/revanced/integrations/patches/HideReelsPatch;->HideReel(Landroid/view/View;)V"
) )
return PatchResultSuccess() return PatchResultSuccess()
@@ -41,16 +41,16 @@ class ShortsButtonRemoverPatch : BytecodePatch(
// Save the tab enum in XGlobals to avoid smali/register workarounds // Save the tab enum in XGlobals to avoid smali/register workarounds
result1.method.addInstruction( result1.method.addInstruction(
result1.scanResult.endIndex + 1, result1.scanResult.endIndex + 1,
"sput-object v$enumRegister, Lfi/razerman/youtube/XGlobals;->lastPivotTab:Ljava/lang/Enum;" "sput-object v$enumRegister, Lapp/revanced/integrations/patches/HideShortsButtonPatch;->lastPivotTab:Ljava/lang/Enum;"
) )
// Hide the button view via proxy by passing it to the hideShortsButton method // Hide the button view via proxy by passing it to the hideShortsButton method
// It only hides it if the last tab name is "TAB_SHORTS" // It only hides it if the last tab name is "TAB_SHORTS"
result2.method.addInstruction( result2.method.addInstruction(
result2.scanResult.endIndex + 2, result2.scanResult.endIndex + 2,
"invoke-static { v$viewRegister }, Lfi/razerman/youtube/XAdRemover;->hideShortsButton(Landroid/view/View;)V" "invoke-static { v$viewRegister }, Lapp/revanced/integrations/patches/HideShortsButtonPatch;->hideShortsButton(Landroid/view/View;)V"
) )
return PatchResultSuccess() return PatchResultSuccess()
} }
} }
@@ -42,4 +42,4 @@ object PivotBarButtonTabenumSignature : MethodSignature(
Opcode.INVOKE_STATIC, // SomeEnum.fromValue(tabOrdinal) Opcode.INVOKE_STATIC, // SomeEnum.fromValue(tabOrdinal)
Opcode.MOVE_RESULT_OBJECT Opcode.MOVE_RESULT_OBJECT
) )
) )
@@ -28,7 +28,7 @@ class IntegrationsPatch : BytecodePatch(
) )
) { ) {
override fun execute(data: BytecodeData): PatchResult { override fun execute(data: BytecodeData): PatchResult {
if (data.findClass("Lapp/revanced/integrations/Globals") == null) if (data.findClass("Lapp/revanced/integrations/utils/Globals") == null)
return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.") return PatchResultError("Integrations have not been merged yet. This patch can not succeed without the integrations.")
val result = InitSignature.result!! val result = InitSignature.result!!
@@ -38,8 +38,8 @@ class IntegrationsPatch : BytecodePatch(
result.method.addInstructions( result.method.addInstructions(
result.scanResult.endIndex + 1, """ result.scanResult.endIndex + 1, """
invoke-static {v$count}, Lpl/jakubweg/StringRef;->setContext(Landroid/content/Context;)V invoke-static {v$count}, Lapp/revanced/integrations/sponsorblock/StringRef;->setContext(Landroid/content/Context;)V
sput-object v$count, Lapp/revanced/integrations/Globals;->context:Landroid/content/Context; sput-object v$count, Lapp/revanced/integrations/utils/Globals;->context:Landroid/content/Context;
""" """
) )
@@ -55,7 +55,7 @@ class IntegrationsPatch : BytecodePatch(
null, null,
ImmutableMethodImplementation( ImmutableMethodImplementation(
1, """ 1, """
invoke-static { }, Lapp/revanced/integrations/Globals;->getAppContext()Landroid/content/Context; invoke-static { }, Lapp/revanced/integrations/utils/Globals;->getAppContext()Landroid/content/Context;
move-result-object v0 move-result-object v0
return-object v0 return-object v0
""".trimIndent().toInstructions(), null, null """.trimIndent().toInstructions(), null, null