-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Instagram): Added few patches #3604
base: dev
Are you sure you want to change the base?
Conversation
Does possible to download media like on Twitter (X) with long press media and download them? |
The added patches don't add a download patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Couple of small issues that need to be addressed before merging though. I have commented in some places but other applicable places should be considered as well.
src/main/kotlin/app/revanced/patches/instagram/developerMenu/EnableDeveloperMenuPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/misc/integrations/IntegrationsPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/developerMenu/EnableDeveloperMenuPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/developerMenu/EnableDeveloperMenuPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/developerMenu/EnableDeveloperMenuPatch.kt
Outdated
Show resolved
Hide resolved
...agram/misc/links/openInExternalBrowser/fingerprints/OpenLinksInExternalBrowserFingerprint.kt
Outdated
Show resolved
Hide resolved
.../app/revanced/patches/instagram/misc/links/sanitizeSharingLinks/SanitizeSharingLinksPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/misc/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/misc/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/misc/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
PRs are squashed to one commit. Either separate each patch to its own PR, or squash them locally into commits called "feat(Instagram): Added |
I thought max media patch is save media into high quality. |
No it just changes the media quality |
oh alright, I wasnt aware of it. Lemme correct the code base with the above mentioned corrections and create PRs individually. We can probably close this one (then). |
Working in a single pr is easier (also to review). We can decide that once all codebase issues are resolved 👍 |
Hi, Updated the codebase with the mentioned comments. Let me know if it looks good now. |
src/main/kotlin/app/revanced/patches/instagram/misc/integrations/IntegrationsPatch.kt
Outdated
Show resolved
Hide resolved
...main/kotlin/app/revanced/patches/instagram/patches/developerMenu/EnableDeveloperMenuPatch.kt
Outdated
Show resolved
Hide resolved
...main/kotlin/app/revanced/patches/instagram/patches/developerMenu/EnableDeveloperMenuPatch.kt
Outdated
Show resolved
Hide resolved
...revanced/patches/instagram/patches/links/openInExternalBrowser/OpenLinksInExternalBrowser.kt
Outdated
Show resolved
Hide resolved
...revanced/patches/instagram/patches/links/openInExternalBrowser/OpenLinksInExternalBrowser.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/patches/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/patches/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/patches/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/patches/selectableBio/SelectableBioPatch.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/app/revanced/patches/instagram/patches/selectableBio/SelectableBioPatch.kt
Outdated
Show resolved
Hide resolved
The review will be iterative, addressing big issues, once solved, smaller issues and so on, until everything looks right. Hope it doesn't cause too much trouble. |
Updated the |
@crimera was working on download patch. But he didn't complete the job yet. |
Maybe he can collaborate to piko in order to implemented it |
Better to retain it. It's good too see high quality image. |
@swakwork You can mark reviews as resolved to hide them. |
yup, done 👍 |
src/main/kotlin/app/revanced/patches/instagram/patches/maxQuality/MaxMediaQualityPatch.kt
Outdated
Show resolved
Hide resolved
Hi team, is there any other cleanups required from my end or the changes looks good ? |
) | ||
@Suppress("unused") | ||
object SelectableBioPatch : BytecodePatch( | ||
setOf(SelectableBioFingerprint), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name fingerprints to the method they match to. If this one for example matches to the constructor, call it "ConstructBioViewFingerprint"
}.name | ||
|
||
// Patch the method that opens the link in the internal browser. | ||
it.mutableClass.methods.last { it.returnType == "V" && it.parameters.size == 0 }.apply { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a safe approach. Please fingerprint the method and get it through that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically that method originally has 4 lines, 2 const/4, 1 invoke and return-void. Moreover both the "get url" method and the method where the fragment is built is present in the same call. So I thought its easier to find the class and then find the methods accordingly
|
||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
|
||
internal object OpenLinksInExternalBrowserFingerprint : MethodFingerprint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name the fingerprint like explained above.
StoryShareUrlFingerprint, | ||
LiveShareUrlFingerprint, | ||
PostShareClassFinderFingerprint, | ||
ProfileShareUrlFingerprint, | ||
HighlightsShareUrlFingerprint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fingerprints need to be named according to the method they match too
|
||
override fun execute(context: BytecodeContext) { | ||
fun sanitizeUrl(method: MutableMethod) = method.apply { | ||
val index = getInstructions().first { it.opcode == Opcode.IPUT_OBJECT }.location.index - 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment what this index does in the code
PostShareClassFinderFingerprint.resultOrThrow().mutableMethod.let { method -> | ||
val classIndex = method.getInstructions().last { it.opcode == Opcode.CONST_CLASS }.location.index | ||
val className = method.getInstruction(classIndex).getReference<TypeReference>()!!.type | ||
val parseJsonMethod = context.findClass(className)!!.mutableClass.methods.first { | ||
it.name == "parseFromJson" | ||
} | ||
|
||
sanitizeUrl(parseJsonMethod) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't you using a fingerprint for this?
val maxPostSize = "0x800" // Decimal value = 2048. Maximum post size. | ||
val maxBitRate = "0x989680" // Decimal value = 10000000. Maximum bit rate possible (found in code). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iirc you can use decimals just fine in smali, no need to convert to hex
DisplayMetricsFingerprint.resultOrThrow().let { it -> | ||
it.mutableMethod.apply { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do not use the result, simply do DisplayMetricsFingerprint.resultOrThrow().mutableMethod.
it.mutableClass.apply { | ||
val mediaSetMethod = | ||
methods.first { it.returnType == "Lcom/instagram/model/mediasize/ExtendedImageUrl;" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fingerprint this method in the first place?
// This section of code sets the bitrate of the stories to the max possible. | ||
StoryMediaBitrateFingerprint.resultOrThrow().let { it -> | ||
it.mutableMethod.apply { | ||
val ifLezIndex = getInstructions().first { it.opcode == Opcode.IF_LEZ }.location.index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use opcode patterns in fingerprint to get the index to instructions. This applies to all the other places where you manually try to find an index. Manually only makes sense if you cant fingerprint the index of a pattern properly for example due to repeating patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some refactoring. You should check if everything works on your end too. Apart from the pending reviews, looks good otherwise.
} | ||
|
||
// Improve quality of reels. | ||
// In general Instagram tend to set the minimum bitrate between max possible and compressed video's bitrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End sentences with a dot.
} | ||
|
||
// Improve quality of reels. | ||
// In general Instagram tend to set the minimum bitrate between max possible and compressed video's bitrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't short words such as "max"
feefb56
to
a371631
Compare
c0cd9d2
to
2ace07d
Compare
Hi team,
I have added the following patches to Instagram
Enable developer menu
patchMax media quality
patchSelectable bio
patchSanitize sharing links
patchOpen links in external browser
patchI have tested these with the latest alpha build(348.0.0.0.42) , at the time, and the patches work fine.
These patches go along with my integrations PR #685
This is my first PR to this project, so do let me know if any code correction is needed.
Thanks,