mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-20 16:15:47 +08:00
手机端脚本页面
This commit is contained in:
@@ -10,6 +10,34 @@ import 'package:path_provider/path_provider.dart';
|
||||
/// 2023/10/06
|
||||
/// js脚本
|
||||
class ScriptManager {
|
||||
static String template = """
|
||||
// 在请求到达服务器之前,调用此函数,您可以在此处修改请求数据
|
||||
// 例如Add/Update/Remove:Queries、Headers、Body
|
||||
async function onRequest(context, request) {
|
||||
console.log(request.url);
|
||||
//URL参数
|
||||
//request.queries["name"] = "value";
|
||||
// 更新或添加新标头
|
||||
//request.headers["X-New-Headers"] = "My-Value";
|
||||
|
||||
// Update Body 使用fetch API请求接口,具体文档可网上搜索fetch API
|
||||
//response.body = await fetch('https://www.baidu.com/').then(response => response.text());
|
||||
return request;
|
||||
}
|
||||
|
||||
// 在将响应数据发送到客户端之前,调用此函数,您可以在此处修改响应数据
|
||||
async function onResponse(context, request, response) {
|
||||
// 更新或添加新标头
|
||||
// response.headers["Name"] = "Value";
|
||||
// response.statusCode = 200;
|
||||
|
||||
//var body = JSON.parse(response.body);
|
||||
//body['key'] = "value";
|
||||
//response.body = JSON.stringify(body);
|
||||
return response;
|
||||
}
|
||||
""";
|
||||
|
||||
static String separator = Platform.pathSeparator;
|
||||
static ScriptManager? _instance;
|
||||
bool enabled = true;
|
||||
|
||||
Reference in New Issue
Block a user