-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluesky.js
67 lines (56 loc) · 2.56 KB
/
bluesky.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Bluesky Xposed Hook Script for React Native Networking
*
* This is a jshook script for the Bluesky app, built using Rhino and Xposed.
* It hooks into HTTP responses in the React Native NetworkingModule to log
* request and response data, and creates a cloned response body.
*
* GitHub: https://github.com/playdevv/bluesky-jshook
* License: MIT
* Author: playdevv
*/
XposedHelpers.findAndHookMethod(
'com.facebook.react.modules.network.NetworkingModule$2',
runtime.classLoader,
"onResponse",
"okhttp3.Call",
"okhttp3.Response",
XC_MethodReplacement({
replaceHookedMethod: function (param) {
var lines = ["\n"];
var response = param.args[1];
var body = XposedHelpers.getObjectField(response, "body");
var request = XposedHelpers.getObjectField(response, "request");
var url = request.url();
var method = request.method();
var headers = request.headers();
lines.push(`METHOD:\n - ${method}\n`);
lines.push(`URL:\n - ${url}\n`);
lines.push(`HEADERS:\n${headers}\n`);
if (method == "POST") {
var progressrequestbody = request.body();
var requestbody = XposedHelpers.getObjectField(progressrequestbody, "mRequestBody");
var this_toRequestBody = XposedHelpers.getObjectField(requestbody, "$this_toRequestBody");
var postdata;
if (`${requestbody}`.includes("toRequestBody$1")) {
postdata = this_toRequestBody.utf8();
} else {
var byteCount = XposedHelpers.getObjectField(requestbody, "$byteCount");
var offset = XposedHelpers.getObjectField(requestbody, "$offset");
postdata = new Packages.java.lang.String(this_toRequestBody, offset, byteCount, "UTF-8");
}
lines.push(`POSTDATA:\n - ${postdata}\n`);
}
var originalBody = body;
var bodyBytes = originalBody.bytes();
var bodyText = new java.lang.String(bodyBytes, "UTF-8");
lines.push(`RESPONSE:\n - ${bodyText}\n`);
var newBody = originalBody.create(bodyText, originalBody.contentType());
var newResponse = response.newBuilder().body(newBody).build();
param.args[1] = newResponse;
lines.push("====================\n");
console.log(lines.join(""));
return XposedBridge.invokeOriginalMethod(param.method, param.thisObject, param.args);
}
})
);