32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
log_info("Script loaded successfully");
|
|
Java.perform(function () {
|
|
var OkHttpClient = Java.use('okhttp3.OkHttpClient');
|
|
var Request = Java.use('okhttp3.Request');
|
|
|
|
OkHttpClient.newCall.implementation = function (request) {
|
|
var url = request.url().toString();
|
|
var method = request.method();
|
|
var body = request.body();
|
|
var size = body != null ? body.contentLength() / 1024 : 0;
|
|
console.log("Method: " + method + "\nURL: " + url + "\nSize: " + size + " kb");
|
|
|
|
return this.newCall(request);
|
|
};
|
|
});
|
|
|
|
|
|
function log_info(messages) {
|
|
const now = new Date();
|
|
const year = now.getFullYear();
|
|
const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-based
|
|
const day = String(now.getDate()).padStart(2, '0');
|
|
const hours = String(now.getHours()).padStart(2, '0');
|
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
const milliseconds = String(now.getMilliseconds()).padStart(3, '0');
|
|
|
|
const timestamp = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}:${milliseconds}`;
|
|
|
|
console.log(`${timestamp} - ${messages}`);
|
|
send(`${timestamp} - ${messages}`);
|
|
} |