12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import {LogColor, logColor} from "./logger";
- export let HookGameCenter = {
- printReqParam: function (HttpLoggingInterceptor) {
- HttpLoggingInterceptor.a.overload('okhttp3.Interceptor$Chain').implementation = function (chain) {
-
- var request = chain.request();
- var url = request.url();
- var result = this.a(chain);
-
- var threadLogs = HttpLoggingInterceptor.THREAD_LOGS.value;
-
- var threadLogsValue = threadLogs.get();
-
- if (threadLogsValue !== null) {
- logColor('请求url: '+url+'\n参数: ' + threadLogsValue.toString(), LogColor.GREEN_TEXT);
- } else {
- console.log('请求参数 is null or not set for the current thread');
- }
- return result;
- }
- }, startHook: function () {
-
- var HttpLoggingInterceptor = Java.use('com.framework.net.okhttp3.HttpLoggingInterceptor');
- HookGameCenter.printReqParam(HttpLoggingInterceptor);
- HookGameCenter.printResponse(HttpLoggingInterceptor);
- },
- printResponse: function (HttpLoggingInterceptor) {
- HttpLoggingInterceptor.intercept.overload('okhttp3.Interceptor$Chain').implementation = function (chain) {
- var result = this.intercept(chain);
-
-
- try {
-
- var responseBody = result.peekBody(1024 * 1024);
- var responseBodyString = responseBody.string();
- logColor("Response Body: " + responseBodyString, LogColor.BLUE_TEXT);
- } catch (e) {
- console.log("Error reading response body: " + e);
- }
- return result;
- }
- }
- }
|