feat: sponsorblock patch (#101)

* chore(release): 2.5.1-dev.1 [skip ci]

## [2.5.1-dev.1](https://github.com/revanced/revanced-patches/compare/v2.5.0...v2.5.1-dev.1) (2022-06-30)

### Bug Fixes

* freezing panels when watching video in fullscreen ([#89](https://github.com/revanced/revanced-patches/issues/89)) ([f5d4f6c](f5d4f6c341))
* invalid version in compatibility annotation ([#90](https://github.com/revanced/revanced-patches/issues/90)) ([df43547](df435475cd))

* feat: migrate to breaking changes of patcher

* chore(release): 2.6.0-dev.1 [skip ci]

# [2.6.0-dev.1](https://github.com/revanced/revanced-patches/compare/v2.5.1-dev.1...v2.6.0-dev.1) (2022-07-02)

### Features

* migrate to breaking changes of patcher ([a116852](a11685263f))

* refactor: add package for fingerprints

* feat: partial `sponsorblock` patch

* feat: add `Name` annotation to `sponsorblock-resource-patch`

* fix: `sponsorblock-resource-patch`

* refactor: remove unused resources

* refactor: remove `locale-config-fix` dependency

* fix: broken fingerprints

* feat: general fixes on `sponsorblock` patch

* feat: more fixes on `sponsorblock` patch

* feat: update `sponsorblock` patch to 17.26.35

* style: use better wording and fix spelling mistakes

* fix: finish `sponsorblock` patch

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
This commit is contained in:
oSumAtrIX
2022-07-18 01:17:03 +02:00
committed by GitHub
parent 8f06ea9115
commit 36af4cc14f
27 changed files with 1149 additions and 7 deletions

View File

@ -5,14 +5,16 @@ import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.BytecodeData
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.Dependencies
import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.videoid.annotation.VideoIdCompatibility
import app.revanced.patches.youtube.misc.videoid.fingerprint.VideoIdFingerprint
import org.jf.dexlib2.iface.instruction.formats.Instruction11x
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("video-id-hook")
@Description("hook to detect when the video id changes")
@ -25,12 +27,21 @@ class VideoIdPatch : BytecodePatch(
)
) {
override fun execute(data: BytecodeData): PatchResult {
result = VideoIdFingerprint.result!!
insertMethod = result.mutableMethod
videoIdRegister =
(insertMethod.implementation!!.instructions[result.patternScanResult!!.endIndex + 1] as OneRegisterInstruction).registerA
injectCall("Lapp/revanced/integrations/videoplayer/VideoInformation;->setCurrentVideoId(Ljava/lang/String;)V")
return PatchResultSuccess()
}
companion object {
private lateinit var result: MethodFingerprintResult
private var videoIdRegister: Int = 0
private lateinit var insertMethod: MutableMethod
private var offset = 2
/**
@ -40,12 +51,7 @@ class VideoIdPatch : BytecodePatch(
fun injectCall(
methodDescriptor: String
) {
val result = VideoIdFingerprint.result!!
val method = result.mutableMethod
val videoIdRegister =
(method.implementation!!.instructions[result.patternScanResult!!.endIndex + 1] as Instruction11x).registerA
method.addInstructions(
insertMethod.addInstructions(
result.patternScanResult!!.endIndex + offset, // after the move-result-object
"invoke-static {v$videoIdRegister}, $methodDescriptor"
)