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 player flyout menu): add
Hide 1080p Premium menu
…
…setting
- Loading branch information
Showing
4 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
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
60 changes: 60 additions & 0 deletions
60
...anced/patches/youtube/player/flyoutmenu/hide/fingerprints/VideoQualityArrayFingerprint.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,60 @@ | ||
package app.revanced.patches.youtube.player.flyoutmenu.hide.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import app.revanced.patches.youtube.player.flyoutmenu.hide.fingerprints.VideoQualityArrayFingerprint.ENDS_WITH_PARAMETER_LIST | ||
import app.revanced.patches.youtube.player.flyoutmenu.hide.fingerprints.VideoQualityArrayFingerprint.STARTS_WITH_PARAMETER_LIST | ||
import app.revanced.patches.youtube.player.flyoutmenu.hide.fingerprints.VideoQualityArrayFingerprint.indexOfQualityLabelInstruction | ||
import app.revanced.util.getReference | ||
import app.revanced.util.indexOfFirstInstruction | ||
import app.revanced.util.parametersEqual | ||
import com.android.tools.smali.dexlib2.AccessFlags | ||
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 VideoQualityArrayFingerprint : MethodFingerprint( | ||
returnType = "[Lcom/google/android/libraries/youtube/innertube/model/media/VideoQuality;", | ||
accessFlags = AccessFlags.PRIVATE or AccessFlags.FINAL, | ||
// 18.29 and earlier parameters are: | ||
// "Ljava/util/List;", | ||
// "Ljava/lang/String;" | ||
// "L" | ||
|
||
// 18.31+ parameters are: | ||
// "Ljava/util/List;", | ||
// "Ljava/util/Collection;", | ||
// "Ljava/lang/String;" | ||
// "L" | ||
customFingerprint = custom@{ methodDef, _ -> | ||
val parameterTypes = methodDef.parameterTypes | ||
val parameterSize = parameterTypes.size | ||
if (parameterSize != 3 && parameterSize != 4) { | ||
return@custom false | ||
} | ||
|
||
val startsWithMethodParameterList = parameterTypes.slice(0..0) | ||
val endsWithMethodParameterList = parameterTypes.slice(parameterSize - 2..< parameterSize) | ||
|
||
parametersEqual(STARTS_WITH_PARAMETER_LIST, startsWithMethodParameterList) && | ||
parametersEqual(ENDS_WITH_PARAMETER_LIST, endsWithMethodParameterList) && | ||
indexOfQualityLabelInstruction(methodDef) >= 0 | ||
} | ||
) { | ||
private val STARTS_WITH_PARAMETER_LIST = listOf( | ||
"Ljava/util/List;" | ||
) | ||
private val ENDS_WITH_PARAMETER_LIST = listOf( | ||
"Ljava/lang/String;", | ||
"L" | ||
) | ||
|
||
fun indexOfQualityLabelInstruction(methodDef: Method) = | ||
methodDef.indexOfFirstInstruction { | ||
val reference = getReference<MethodReference>() | ||
opcode == Opcode.INVOKE_VIRTUAL && | ||
reference?.returnType == "Ljava/lang/String;" && | ||
reference.parameterTypes.size == 0 && | ||
reference.definingClass == "Lcom/google/android/libraries/youtube/innertube/model/media/FormatStreamModel;" | ||
} | ||
} |
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