Open NghiaTranUIT opened 9 months ago
ScriptEntry
and ScriptService
classes to Typescriptuser-data/ScriptService-RuleTree
..//scripts/1C2FD611.js
-> 1C2FD611
is a random UUID string./// This func is called if the Request Checkbox is Enabled. You can modify the Request Data here before the request hits to the server
/// e.g. Add/Update/Remove: host, scheme, port, path, headers, queries, comment, color and body (json, form, plain-text, base64 encoded string)
///
/// Use global object `sharedState` to share data between Requests/Response from different scripts (e.g. sharedState.data = "My-Data")
///
async function onRequest(context, url, request) {
// console.log(request);
console.log(url);
// Update or Add new headers
// request.headers["X-New-Headers"] = "My-Value";
// Update or Add new queries
// request.queries["name"] = "Proxyman";
// Body
// var body = request.body;
// body["new-key"] = "new-value"
// request.body = body;
// Done
return request;
}
/// This func is called if the Response Checkbox is Enabled. You can modify the Response Data here before it goes to the client
/// e.g. Add/Update/Remove: headers, statusCode, comment, color and body (json, plain-text, base64 encoded string)
///
async function onResponse(context, url, request, response) {
// console.log(response);
// Update or Add new headers
// response.headers["Content-Type"] = "application/json";
// Update status Code
// response.statusCode = 500;
// Update Body
// var body = response.body;
// body["new-key"] = "Proxyman";
// response.body = body;
// Or map a local file as a body
// response.bodyFilePath = "~/Desktop/myfile.json"
// Done
return response;
}
[x] Introduce a new mode for Monaco Editor for the Scripting
[x] Define a list of new suggestions:
Basic suggestion: If the current curse is empty, it should suggest the basic suggestion depends on the current variables. For example: It suggests: request, response, context, url, console, console.log, delete, ... -> Everything from the Javascript mode
if it's from request
, type .
will suggest: method, scheme, host, port, path, queries, headers, body
if it's from response
, type .
will suggest: statusCode, statusPhrase, httpVersion, headers, body
if it's from context
, type .
will suggest: id, remoteDeviceIP, clientIPAddress, clientPort, serverIpAddress, serverPort
Control + B
to beautify the Scritpt Content (Javascript Mode)
Description
It's time to implement the Scripting feature. We're going to break it down into small feasible tickets.
Acceptance Criteria
1. Script List Requirement
Menu Action Requirement
ScriptFile
ScriptFile