Skip to content

Commit

Permalink
Merge pull request #99 from crimera/dev
Browse files Browse the repository at this point in the history
chore: Merge branch `dev` to `main`
  • Loading branch information
crimera authored Oct 24, 2024
2 parents 6e58729 + 3a5a67d commit 3f545cc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.31.2-dev.2](https://github.com/crimera/revanced-integrations/compare/v1.31.2-dev.1...v1.31.2-dev.2) (2024-10-20)


### Refactors

* **Custom Downloader:** Improve getting of tweet method declarations ([a6ed0b2](https://github.com/crimera/revanced-integrations/commit/a6ed0b2d3db2757d83d0c0606eccf14c6ca2a02e))

## [1.31.2-dev.1](https://github.com/crimera/revanced-integrations/compare/v1.31.1...v1.31.2-dev.1) (2024-10-20)


### Bug Fixes

* **Twitter:** Add support for version 10.64.0-beta.1 ([015f492](https://github.com/crimera/revanced-integrations/commit/015f492bfaf6fece4f3cb5e46707e283405e17d6))

## [1.31.1](https://github.com/crimera/revanced-integrations/compare/v1.31.0...v1.31.1) (2024-10-15)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,40 @@ private static void alertBox(Context ctx, String filename, ArrayList<HashMap<Str
builder.show();
}

private static Class<?> tweetClass;

public static Class<?> getTweetClass() throws ClassNotFoundException {
if (tweetClass == null) tweetClass = Class.forName("tweetObjectClass");

return tweetClass;
}

public static Long getTweetId(Object tweet) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
return (Long) getTweetClass().getDeclaredMethod("idMethod").invoke(tweet);
}

public static String getTweetUsername(Object tweet) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
return (String) getTweetClass().getDeclaredMethod("getUserNamemethod").invoke(tweet);
}

public static Object getTweetMedia(Object tweet) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
return getTweetClass().getDeclaredMethod("getTweetMediaMethod").invoke(tweet);
}

// downloader(Landroid/content/Context;Ljava/lang/Object;)V
public static void downloader(Context activity, Object tweet) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
Class<?> tweetClass = tweet.getClass();
public static void downloader(Context activity, Object tweet) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException, ClassNotFoundException {
// TODO: make this into a fingerprint, match https://x.com/%1$s/status/%2$d
Class<?> tweetClass = getTweetClass();

Method getIdMethod = tweetClass.getDeclaredMethod("getId");
Long id = (Long) getIdMethod.invoke(tweet);
Long id = getTweetId(tweet);
assert id != null;

/*
Check how many versions this naive implementation lasts. checked until
versions 10.48 and the method names were the same.
*/
Method getUserNameMethod = tweetClass.getDeclaredMethod("q");
Method getMediaMethod = tweetClass.getDeclaredMethod("b");

String username = (String) getUserNameMethod.invoke(tweet);
Object obj = getMediaMethod.invoke(tweet);
String username = getTweetUsername(tweet);
if (username == null) {
Utils.toast("username is not found");
}
assert username != null;
Object obj = getTweetMedia(tweet);
ArrayList<HashMap<String, String>> media = getMediaData(obj);

assert media != null;
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
android.useAndroidX = true
version = 1.31.1
version = 1.31.2-dev.2

0 comments on commit 3f545cc

Please sign in to comment.