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/Hide comments components): add `Hide highlighted search …
…links` setting inotia00/ReVanced_Extended#2435
- Loading branch information
Showing
7 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...ints/SpannableStringBuilderFingerprint.kt → ...ints/SpannableStringBuilderFingerprint.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
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
56 changes: 56 additions & 0 deletions
56
...kotlin/app/revanced/patches/shared/textcomponent/fingerprints/InclusiveSpanFingerprint.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,56 @@ | ||
package app.revanced.patches.shared.textcomponent.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import app.revanced.patches.shared.textcomponent.fingerprints.InclusiveSpanFingerprint.STARTS_WITH_PARAMETER_LIST | ||
import app.revanced.patches.shared.textcomponent.fingerprints.InclusiveSpanFingerprint.indexOfSetSpanInstruction | ||
import app.revanced.util.getReference | ||
import app.revanced.util.indexOfFirstInstructionReversed | ||
import app.revanced.util.parametersEqual | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.iface.Method | ||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference | ||
|
||
internal object InclusiveSpanFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
// 19.14 and earlier parameters are: | ||
// "Landroid/text/SpannableString;", | ||
// "Ljava/lang/Object;", | ||
// "I", | ||
// "I" | ||
|
||
// 19.15+ parameters are: | ||
// "Landroid/text/SpannableString;", | ||
// "Ljava/lang/Object;", | ||
// "I", | ||
// "I", | ||
// "Z" | ||
customFingerprint = custom@{ methodDef, _ -> | ||
val parameterTypes = methodDef.parameterTypes | ||
val parameterSize = parameterTypes.size | ||
if (parameterSize != 4 && parameterSize != 5) { | ||
return@custom false | ||
} | ||
val startsWithMethodParameterList = parameterTypes.slice(0..3) | ||
|
||
if (!parametersEqual(STARTS_WITH_PARAMETER_LIST, startsWithMethodParameterList)) { | ||
return@custom false | ||
} | ||
indexOfSetSpanInstruction(methodDef) >= 0 | ||
}, | ||
) { | ||
internal const val SET_SPAN_METHOD_CALL = | ||
"Landroid/text/SpannableString;->setSpan(Ljava/lang/Object;III)V" | ||
|
||
private val STARTS_WITH_PARAMETER_LIST = listOf( | ||
"Landroid/text/SpannableString;", | ||
"Ljava/lang/Object;", | ||
"I", | ||
"I" | ||
) | ||
|
||
fun indexOfSetSpanInstruction(methodDef: Method) = | ||
methodDef.indexOfFirstInstructionReversed { | ||
opcode == Opcode.INVOKE_VIRTUAL && | ||
getReference<MethodReference>().toString() == SET_SPAN_METHOD_CALL | ||
} | ||
} |
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
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