mirror of
https://github.com/pysunday/rs-reverse.git
synced 2025-04-21 14:25:17 +08:00
feat: 增加html文件与javascript代码文件的保存
This commit is contained in:
parent
53497ffaf4
commit
59b86f0ab9
@ -62,10 +62,13 @@ Examples:
|
|||||||
```bash
|
```bash
|
||||||
$ npx rs-reverse makecode -u https://wcjs.sbj.cnipa.gov.cn/sgtmi
|
$ npx rs-reverse makecode -u https://wcjs.sbj.cnipa.gov.cn/sgtmi
|
||||||
|
|
||||||
输出ts:/path/to/output/makecode_output_ts.json
|
|
||||||
输出动态代码:/path/to/output/makecode_output_code.js
|
|
||||||
url方式提取的ts:/path/to/output/makecode_input_ts.json
|
url方式提取的ts:/path/to/output/makecode_input_ts.json
|
||||||
url方式提取的静态文本:/path/to/output/makecode_input_immucfg.json
|
url方式提取的静态文本:/path/to/output/makecode_input_immucfg.json
|
||||||
|
url方式提取的javascript代码:/path/to/output/makecode_input_js.js
|
||||||
|
url方式提取的html代码:/path/to/output/makecode_input_html.html
|
||||||
|
|
||||||
|
程序生成的ts:/path/to/output/makecode_output_ts.json
|
||||||
|
程序生成的动态代码:/path/to/output/makecode_output_code.js
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
4
main.js
4
main.js
@ -43,7 +43,7 @@ const getCode = async (url) => {
|
|||||||
if (!remotes.length) throw new Error('未找到js外链,无法提取配置文本请检查!');
|
if (!remotes.length) throw new Error('未找到js外链,无法提取配置文本请检查!');
|
||||||
for(let src of remotes) {
|
for(let src of remotes) {
|
||||||
const jscode = await request(urlresolve(url, src));
|
const jscode = await request(urlresolve(url, src));
|
||||||
if (jscode.includes('r2mKa')) return { $_ts, jscode };
|
if (jscode.includes('r2mKa')) return { $_ts, jscode, html: res };
|
||||||
}
|
}
|
||||||
throw new Error('js外链中没有瑞数的代码文件');
|
throw new Error('js外链中没有瑞数的代码文件');
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ const commandHandler = (command, argv) => {
|
|||||||
logger.trace(`传入的$_ts.nsd: ${ts.nsd}`);
|
logger.trace(`传入的$_ts.nsd: ${ts.nsd}`);
|
||||||
logger.trace(`传入的$_ts.cd: ${ts.cd}`);
|
logger.trace(`传入的$_ts.cd: ${ts.cd}`);
|
||||||
if (argv.url) {
|
if (argv.url) {
|
||||||
command(ts, adapt(argv.url.jscode, argv.adapt));
|
command(ts, adapt(argv.url.jscode, argv.adapt), argv.url);
|
||||||
} else {
|
} else {
|
||||||
command(ts);
|
command(ts);
|
||||||
}
|
}
|
||||||
|
@ -57,21 +57,21 @@ module.exports = class {
|
|||||||
run() {
|
run() {
|
||||||
const { getTaskNumber: gtn } = this;
|
const { getTaskNumber: gtn } = this;
|
||||||
const cookieBaseArr = numarrJoin(
|
const cookieBaseArr = numarrJoin(
|
||||||
gv.cp2[58],
|
gv.cp2[58], // 3
|
||||||
this.getSubOne(),
|
this.getSubOne(),
|
||||||
gv.cp2[0],
|
gv.cp2[0], // 10
|
||||||
this.getSubTwo(),
|
this.getSubTwo(),
|
||||||
gv.cp2[23],
|
gv.cp2[23], // 7
|
||||||
this.getSubThree(),
|
this.getSubThree(),
|
||||||
gtn('0>one>63-287', 4),
|
gtn('0>one>63-287', 4), // 0
|
||||||
[gtn('0>one>63>one>4-290', 1)],
|
[gtn('0>one>63>one>4-290', 1)], // 0
|
||||||
gv.cp2[55],
|
gv.cp2[55], // 6
|
||||||
this.getSubFour(),
|
this.getSubFour(),
|
||||||
gv.cp2[56],
|
gv.cp2[56], // 2
|
||||||
this.getSubFive(),
|
this.getSubFive(),
|
||||||
gv.cp2[6],
|
gv.cp2[6], // 9
|
||||||
this.getSubSix(),
|
this.getSubSix(),
|
||||||
gv.cp2[39],
|
gv.cp2[39], // 13
|
||||||
[gtn('0>one>55>one>3-189', 6)],
|
[gtn('0>one>55>one>3-189', 6)],
|
||||||
)
|
)
|
||||||
return '0' + numarr2string(
|
return '0' + numarr2string(
|
||||||
|
@ -4,7 +4,7 @@ const logger = require('@utils/logger');
|
|||||||
const { extrace, bitwiseTwoNumarr, decrypt, decode } = require('./common/index');
|
const { extrace, bitwiseTwoNumarr, decrypt, decode } = require('./common/index');
|
||||||
|
|
||||||
exports.init = function() {
|
exports.init = function() {
|
||||||
const content = gv._getAttr('_ts').metaContent;
|
const content = gv._getAttr('_ts')?.metaContent;
|
||||||
if (!content) return;
|
if (!content) return;
|
||||||
const arr = extrace(bitwiseTwoNumarr(decrypt(content), gv.keys[17])).filter(it => it.length);
|
const arr = extrace(bitwiseTwoNumarr(decrypt(content), gv.keys[17])).filter(it => it.length);
|
||||||
if (!arr.length) {
|
if (!arr.length) {
|
||||||
|
@ -3,23 +3,11 @@ const paths = require('@utils/paths');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const logger = require('@utils/logger');
|
const logger = require('@utils/logger');
|
||||||
|
|
||||||
module.exports = function (ts, immucfg) {
|
module.exports = function (ts, immucfg, mate = {}) {
|
||||||
const startTime = new Date().getTime();
|
const startTime = new Date().getTime();
|
||||||
const coder = new Coder(ts, immucfg);
|
const coder = new Coder(ts, immucfg);
|
||||||
const { code, $_ts } = coder.run();
|
const { code, $_ts } = coder.run();
|
||||||
const files = [
|
const files = [
|
||||||
{
|
|
||||||
name: 'makecode_output_ts',
|
|
||||||
desc: '输出ts:',
|
|
||||||
text: JSON.stringify($_ts),
|
|
||||||
extend: 'json',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'makecode_output_code',
|
|
||||||
desc: '输出动态代码:',
|
|
||||||
text: '// 该行标记来源,非动态代码生成: ' + JSON.stringify(ts) + '\n\n' + code,
|
|
||||||
extend: 'js',
|
|
||||||
},
|
|
||||||
immucfg ? {
|
immucfg ? {
|
||||||
name: 'makecode_input_ts',
|
name: 'makecode_input_ts',
|
||||||
desc: 'url方式提取的ts:',
|
desc: 'url方式提取的ts:',
|
||||||
@ -32,12 +20,37 @@ module.exports = function (ts, immucfg) {
|
|||||||
text: JSON.stringify(immucfg),
|
text: JSON.stringify(immucfg),
|
||||||
extend: 'json',
|
extend: 'json',
|
||||||
} : null,
|
} : null,
|
||||||
|
mate.jscode ? {
|
||||||
|
name: 'makecode_input_js',
|
||||||
|
desc: 'url方式提取的javascript代码:',
|
||||||
|
text: JSON.stringify(mate.jscode),
|
||||||
|
extend: 'js',
|
||||||
|
} : null,
|
||||||
|
mate.html ? {
|
||||||
|
name: 'makecode_input_html',
|
||||||
|
desc: 'url方式提取的html代码:',
|
||||||
|
text: JSON.stringify(mate.html),
|
||||||
|
extend: 'html',
|
||||||
|
newLine: true,
|
||||||
|
} : null,
|
||||||
|
{
|
||||||
|
name: 'makecode_output_ts',
|
||||||
|
desc: '程序生成的ts:',
|
||||||
|
text: JSON.stringify($_ts),
|
||||||
|
extend: 'json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'makecode_output_code',
|
||||||
|
desc: '程序生成的动态代码:',
|
||||||
|
text: '// 该行标记来源,非动态代码生成: ' + JSON.stringify(ts) + '\n\n' + code,
|
||||||
|
extend: 'js',
|
||||||
|
},
|
||||||
].filter(Boolean).map(it => ({ ...it, filepath: `${paths.outputResolve(it.name)}.${it.extend}` }))
|
].filter(Boolean).map(it => ({ ...it, filepath: `${paths.outputResolve(it.name)}.${it.extend}` }))
|
||||||
if (!fs.existsSync(paths.outputPath)) fs.mkdirSync(paths.outputPath);
|
if (!fs.existsSync(paths.outputPath)) fs.mkdirSync(paths.outputPath);
|
||||||
files.forEach(({ filepath, text }) => fs.writeFileSync(filepath, text))
|
files.forEach(({ filepath, text }) => fs.writeFileSync(filepath, text))
|
||||||
logger.info([
|
logger.info([
|
||||||
`生成动态代码成功!用时:${new Date().getTime() - startTime}ms\n`,
|
`生成动态代码成功!用时:${new Date().getTime() - startTime}ms\n`,
|
||||||
...files.reduce((ans, it, idx) => ([...ans, `${it.desc}${it.filepath}${idx === files.length - 1 ? '\n' : ''}`]), []),
|
...files.reduce((ans, it, idx) => ([...ans, `${it.desc}${it.filepath}${idx === files.length - 1 || it.newLine ? '\n' : ''}`]), []),
|
||||||
].join('\n '));
|
].join('\n '));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user