feat: Initial commit

This commit is contained in:
oSumAtrIX
2022-03-21 16:19:51 +01:00
parent 89dec2fbf9
commit bee5f2faed
15 changed files with 518 additions and 0 deletions

View File

@ -0,0 +1,11 @@
package net.revanced.patches
import net.revanced.patches.ads.VideoAds
// This object contains all the patches and should be imported when using this library
object Index {
// Array of patches. New patches should be added to the array
val patches = arrayOf(
VideoAds::class
)
}

View File

@ -0,0 +1,40 @@
package net.revanced.patches.ads
import net.revanced.patcher.cache.Cache
import net.revanced.patcher.patch.Patch
import net.revanced.patcher.patch.PatchResult
import net.revanced.patcher.patch.PatchResultError
import net.revanced.patcher.patch.PatchResultSuccess
import net.revanced.patcher.signature.Signature
import net.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()
}
}