Telegram讨论组:Chavy Scripts Group
A SPA Appliction be used for scripts utils
安装对应模块/插件后,浏览器访问: boxjs.com
- Shadowrocket: boxjs.rewrite.surge.sgmodule
- Loon: boxjs.rewrite.loon.plugin
- Quantumult X: boxjs.rewrite.quanx.conf
- Surge: boxjs.rewrite.surge.sgmodule
- Stash: boxjs.rewrite.stash.stoverride
- Env.min.js放置于嵌入式脚本底端,然后头部调用功能
const $ = new Env("你的脚本名称");
- 支持方法: get, post, put, delete, head, options, patch
let option = { url: "http://www.example.com/", // URL,必须 headers: { // 请求头,可选 "Accept": "*/*", "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.1 Mobile/15E148 Safari/605.1.15", "Content-Type": "application/json; charset=utf-8" "" }, body: `auth_key=1234567&source_lang=EN&target_lang=ZH` // 请求体,POST等方法必须,字符串或对象 } let result = $.get(URL<String> or options<Object>, callback(error, response, data)) // 不支持异步 let result = $.post(URL<String> or options<Object>, callback(error, response, data)) // 不支持异步 …… let result = await $.http.get(URL<String> or options<Object>).then(callback(response)) let result = await $.http.post(URL<String> or options<Object>).then(response => response.body) let result = await $.http.put(URL<String> or options<Object>).then(response => { $.log(JSON.stringify(response.headers)); return response.body }) ……
```javascript
$.getdata(‘chavy’) // 读取持久化数据 (string格式)
$.setdata(string, ‘chavy’) // 写入持久化数据 (string格式)
$.getjson(‘chavy’, default_value<String, Object>) // 读取持久化数据 (object格式),当读取失败后返回默认值
$.setjson(object, ‘chavy’) // 写入持久化数据 (object格式)
```
- 用于集成:Env.min.js
- 便于阅读:Env.js
Copyright © 2019-present chavyleung. This project is GPL licensed.