refactor: Rename net.revanced to app.revanced

BREAKING CHANGE: Package name was changed from "net.revanced" to "app.revanced"
This commit is contained in:
Lucaskyy
2022-03-21 22:06:24 +01:00
parent 7068f7f2ad
commit 68ea89f15e
5 changed files with 26 additions and 26 deletions

View File

@ -0,0 +1,23 @@
package app.revanced.patches
import app.revanced.patcher.patch.Patch
import app.revanced.patches.ads.VideoAds
import app.revanced.patches.layouts.CreateButtonRemover
import app.revanced.patches.layouts.MinimizedPlayback
import kotlin.reflect.KClass
/**
* Index contains all the patches and should be imported when using this library.
*/
@Suppress("Unused")
object Index {
/**
* Array of patches.
* New patches should be added to the array.
*/
val patches: Array<KClass<out Patch>> = arrayOf(
VideoAds::class,
MinimizedPlayback::class,
CreateButtonRemover::class
)
}

View File

@ -0,0 +1,41 @@
package app.revanced.patches.ads
import app.revanced.patcher.cache.Cache
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.signature.Signature
import app.revanced.patcher.writer.ASMWriter.insertAt
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.tree.VarInsnNode
class VideoAds : Patch("VideoAds") {
override fun execute(cache: Cache): PatchResult {
val showVideoAdsMethodData = cache.methods["show-video-ads"].findParentMethod(
Signature(
"method",
Type.VOID_TYPE,
Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL,
arrayOf(Type.BOOLEAN_TYPE),
null
)
) ?: return PatchResultError("Could not find required method to patch")
showVideoAdsMethodData.method.instructions.insertAt(
0,
VarInsnNode(Opcodes.ISTORE, 1),
MethodInsnNode(
Opcodes.INVOKESTATIC,
"fi/vanced/libraries/youtube/whitelisting/Whitelist",
"shouldShowAds",
Type.getMethodDescriptor(Type.BOOLEAN_TYPE)
)
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,32 @@
package app.revanced.patches.layouts
import app.revanced.patcher.cache.Cache
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.writer.ASMWriter.insertAt
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.MethodInsnNode
import org.objectweb.asm.tree.VarInsnNode
class CreateButtonRemover : Patch("create-button-remover") {
override fun execute(cache: Cache): PatchResult {
val patchData = cache.methods["create-button-patch"]
patchData.method.instructions.insertAt(
patchData.scanData.endIndex - 1,
VarInsnNode(
Opcodes.ALOAD,
6
),
MethodInsnNode(
Opcodes.INVOKESTATIC,
"fi/razerman/youtube/XAdRemover",
"hideCreateButton",
"(Landroid/view/View;)V"
)
)
return PatchResultSuccess()
}
}

View File

@ -0,0 +1,13 @@
package app.revanced.patches.layouts
import app.revanced.patcher.cache.Cache
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
class MinimizedPlayback : Patch("minimized-playback") {
override fun execute(cache: Cache): PatchResult {
cache.methods["minimized-playback-manager"].method.instructions.clear()
return PatchResultSuccess()
}
}