diff --git a/README.md b/README.md index 4a2e4aed9..5d3da9dd2 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,113 @@ # Chavy Scripts + ![](https://img.shields.io/badge/license-GPL-blueviolet.svg) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/chavyleung/scripts?color=%23c694ff) ![](https://badgen.net/github/stars/chavyleung/scripts) ![](https://tokei.rs/b1/github/chavyleung/scripts?category=code) ![GitHub contributors](https://img.shields.io/github/contributors/chavyleung/scripts) -# BoxJs -A SPA Appliction be used for scripts utils +Telegram讨论组:[Chavy Scripts Group](https://t.me/chavyscripts) + +--- + +- [Chavy Scripts](#chavy-scripts) +- [🧰BoxJs](#boxjs) + - [简介](#简介) + - [使用方式](#使用方式) + - [安装链接](#安装链接) + - [正式版](#正式版) + - [🧪测试版](#测试版) +- [🛠️Env.js](#️envjs) + - [调用方式](#调用方式) + - [功能列表](#功能列表) + - [HttpClient](#httpclient) + - [持久化数据](#持久化数据) + - [安装链接](#安装链接-1) + - [正式版](#正式版-1) +- [📃LICENSE](#license) + +--- + +# 🧰BoxJs -[Scripts Vote](https://t.me/chavyscripts) +## 简介 +A SPA Appliction be used for scripts utils + +## 使用方式 + * 安装对应模块/插件后,浏览器访问 + * 正式版:[boxjs.com](http://boxjs.com "BoxJs") + * 测试版:[boxjs.net](http://boxjs.net "BoxJs") + +## 安装链接 +### 正式版 + * Shadowrocket: [boxjs.rewrite.surge.sgmodule](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.surge.sgmodule "BoxJs") + * Loon: [boxjs.rewrite.loon.plugin](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.loon.plugin "BoxJs") + * Quantumult X: [boxjs.rewrite.quanx.conf](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.quanx.conf "BoxJs") + * Surge: [boxjs.rewrite.surge.sgmodule](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.surge.sgmodule "BoxJs") + * Stash: [boxjs.rewrite.stash.stoverride](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.stash.stoverride "BoxJs") + +### 🧪测试版 + * Shadowrocket: [boxjs.rewrite.surge.tf.sgmodule](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.surge.tf.sgmodule "BoxJs.net") + * Loon: [boxjs.rewrite.loon.tf.plugin](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.loon.tf.plugin "BoxJs.net") + * Quantumult X: [boxjs.rewrite.quanx.tf.conf](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.quanx.tf.conf "BoxJs.net") + * Surge: [boxjs.rewrite.surge.tf.sgmodule](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.surge.tf.sgmodule "BoxJs.net") + * Stash: [boxjs.rewrite.stash.tf.stoverride](https://github.com/chavyleung/scripts/raw/master/box/rewrite/boxjs.rewrite.stash.tf.stoverride "BoxJs.net") + +--- + +# 🛠️Env.js + +## 调用方式 + * Env.min.js放置于嵌入式脚本底端,然后头部调用功能 + ``` + const $ = new Env("你的脚本名称"); + ``` + +## 功能列表 +### HttpClient + + * 支持方法: get, post, put, delete, head, options, patch + ```javascript + 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 or options, callback(error, response, data)) // 不支持异步 + let result = $.post(URL or options, callback(error, response, data)) // 不支持异步 + …… + + let result = await $.http.get(URL or options).then(callback(response)) + let result = await $.http.post(URL or options).then(response => response.body) + let result = await $.http.put(URL or options).then(response => { + $.log(JSON.stringify(response.headers)); + return response.body + }) + …… + ``` + +### 持久化数据 + ```javascript + + $.getdata(‘chavy’) // 读取持久化数据 (string格式) + $.setdata(string, ‘chavy’) // 写入持久化数据 (string格式) + $.getjson(‘chavy’, default_value) // 读取持久化数据 (object格式),当读取失败后返回默认值 + $.setjson(object, ‘chavy’) // 写入持久化数据 (object格式) + + ``` + +## 安装链接 +### 正式版 + * 用于集成:[Env.min.js](./Env.min.js?raw=true "Env.min.js") + * 便于阅读:[Env.js](./Env.js?raw=true "Env.js") + +--- -# LICENSE +# 📃LICENSE Copyright © 2019-present chavyleung. This project is [GPL](https://github.com/chavyleung/scripts/blob/master/LICENSE) licensed. diff --git a/box/rewrite/boxjs.rewrite.loon.plugin b/box/rewrite/boxjs.rewrite.loon.plugin index 75fcc98f3..3975288a6 100644 --- a/box/rewrite/boxjs.rewrite.loon.plugin +++ b/box/rewrite/boxjs.rewrite.loon.plugin @@ -1,2 +1,2 @@ [Script] -http-request ^https?://boxjs.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true, timeout=120, tag=BoxJs \ No newline at end of file +http-request ^https?:\/\/boxjs\.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true, timeout=120, tag=BoxJs diff --git a/box/rewrite/boxjs.rewrite.loon.tf.plugin b/box/rewrite/boxjs.rewrite.loon.tf.plugin index a73ffabf9..6e4c1561d 100644 --- a/box/rewrite/boxjs.rewrite.loon.tf.plugin +++ b/box/rewrite/boxjs.rewrite.loon.tf.plugin @@ -1,2 +1,2 @@ [Script] -http-request ^https?://boxjs.net script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/box/chavy.boxjs.js, requires-body=true, timeout=120, tag=BoxJs.net +http-request ^https?:\/\/boxjs\.net script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/box/chavy.boxjs.js, requires-body=true, timeout=120, tag=BoxJs.net diff --git a/box/rewrite/boxjs.rewrite.quanx.conf b/box/rewrite/boxjs.rewrite.quanx.conf index 667820165..1b1b5c4d5 100644 --- a/box/rewrite/boxjs.rewrite.quanx.conf +++ b/box/rewrite/boxjs.rewrite.quanx.conf @@ -1 +1 @@ -^https?://boxjs.com url script-analyze-echo-response https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js \ No newline at end of file +^https?:\/\/boxjs\.com url script-analyze-echo-response https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js diff --git a/box/rewrite/boxjs.rewrite.quanx.tf.conf b/box/rewrite/boxjs.rewrite.quanx.tf.conf index fdf340d88..ccdedad06 100644 --- a/box/rewrite/boxjs.rewrite.quanx.tf.conf +++ b/box/rewrite/boxjs.rewrite.quanx.tf.conf @@ -1 +1 @@ -^https?://boxjs.net url script-analyze-echo-response https://raw.githubusercontent.com/chavyleung/scripts/master/box/chavy.boxjs.js \ No newline at end of file +^https?:\/\/boxjs\.net url script-analyze-echo-response https://raw.githubusercontent.com/chavyleung/scripts/master/box/chavy.boxjs.js diff --git a/box/rewrite/boxjs.rewrite.stash.stoverride b/box/rewrite/boxjs.rewrite.stash.stoverride new file mode 100644 index 000000000..77f5606a3 --- /dev/null +++ b/box/rewrite/boxjs.rewrite.stash.stoverride @@ -0,0 +1,17 @@ +name: BoxJs +desc: http://boxjs.com + +http: + mitm: + - "boxjs.com" + script: + - match: ^https?:\/\/boxjs\.com + name: BoxJs + type: request + require-body: true + timeout: 120 + +script-providers: + BoxJs: + url: https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js + interval: 86400 diff --git a/box/rewrite/boxjs.rewrite.stash.tf.stoverride b/box/rewrite/boxjs.rewrite.stash.tf.stoverride new file mode 100644 index 000000000..a3297bb12 --- /dev/null +++ b/box/rewrite/boxjs.rewrite.stash.tf.stoverride @@ -0,0 +1,17 @@ +#!name=BoxJs.net +#!desc=http://boxjs.net + +http: + mitm: + - "boxjs.com" + script: + - match: ^https?:\/\/boxjs\.net + name: BoxJs + type: request + require-body: true + timeout: 120 + +script-providers: + BoxJs: + url: https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js + interval: 86400 diff --git a/box/rewrite/boxjs.rewrite.surge.sgmodule b/box/rewrite/boxjs.rewrite.surge.sgmodule index 110c3465b..c5d62a2d1 100644 --- a/box/rewrite/boxjs.rewrite.surge.sgmodule +++ b/box/rewrite/boxjs.rewrite.surge.sgmodule @@ -2,4 +2,4 @@ #!desc=http://boxjs.com [Script] -Rewrite: BoxJs = type=http-request,pattern=^https?://boxjs.com,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true, timeout=120 \ No newline at end of file +Rewrite: BoxJs = type=http-request,pattern=^https?:\/\/boxjs\.com,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/chavy.box.js, requires-body=true, timeout=120 diff --git a/box/rewrite/boxjs.rewrite.surge.tf.sgmodule b/box/rewrite/boxjs.rewrite.surge.tf.sgmodule index 83e7a6ca1..f9728456e 100644 --- a/box/rewrite/boxjs.rewrite.surge.tf.sgmodule +++ b/box/rewrite/boxjs.rewrite.surge.tf.sgmodule @@ -2,4 +2,4 @@ #!desc=http://boxjs.net [Script] -Rewrite: BoxJs = type=http-request,pattern=^https?://boxjs.net,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/box/chavy.boxjs.js, requires-body=true, timeout=120 +Rewrite: BoxJs = type=http-request,pattern=^https?:\/\/boxjs\.net,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/box/chavy.boxjs.js, requires-body=true, timeout=120