mirror of
https://github.com/pysunday/rs-reverse.git
synced 2025-04-12 11:56:55 +08:00
feat: 增加html文件与javascript代码文件的保存
This commit is contained in:
parent
53497ffaf4
commit
59b86f0ab9
@ -62,10 +62,13 @@ Examples:
|
||||
```bash
|
||||
$ 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方式提取的静态文本:/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外链,无法提取配置文本请检查!');
|
||||
for(let src of remotes) {
|
||||
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外链中没有瑞数的代码文件');
|
||||
}
|
||||
@ -83,7 +83,7 @@ const commandHandler = (command, argv) => {
|
||||
logger.trace(`传入的$_ts.nsd: ${ts.nsd}`);
|
||||
logger.trace(`传入的$_ts.cd: ${ts.cd}`);
|
||||
if (argv.url) {
|
||||
command(ts, adapt(argv.url.jscode, argv.adapt));
|
||||
command(ts, adapt(argv.url.jscode, argv.adapt), argv.url);
|
||||
} else {
|
||||
command(ts);
|
||||
}
|
||||
|
@ -57,21 +57,21 @@ module.exports = class {
|
||||
run() {
|
||||
const { getTaskNumber: gtn } = this;
|
||||
const cookieBaseArr = numarrJoin(
|
||||
gv.cp2[58],
|
||||
gv.cp2[58], // 3
|
||||
this.getSubOne(),
|
||||
gv.cp2[0],
|
||||
gv.cp2[0], // 10
|
||||
this.getSubTwo(),
|
||||
gv.cp2[23],
|
||||
gv.cp2[23], // 7
|
||||
this.getSubThree(),
|
||||
gtn('0>one>63-287', 4),
|
||||
[gtn('0>one>63>one>4-290', 1)],
|
||||
gv.cp2[55],
|
||||
gtn('0>one>63-287', 4), // 0
|
||||
[gtn('0>one>63>one>4-290', 1)], // 0
|
||||
gv.cp2[55], // 6
|
||||
this.getSubFour(),
|
||||
gv.cp2[56],
|
||||
gv.cp2[56], // 2
|
||||
this.getSubFive(),
|
||||
gv.cp2[6],
|
||||
gv.cp2[6], // 9
|
||||
this.getSubSix(),
|
||||
gv.cp2[39],
|
||||
gv.cp2[39], // 13
|
||||
[gtn('0>one>55>one>3-189', 6)],
|
||||
)
|
||||
return '0' + numarr2string(
|
||||
|
@ -4,7 +4,7 @@ const logger = require('@utils/logger');
|
||||
const { extrace, bitwiseTwoNumarr, decrypt, decode } = require('./common/index');
|
||||
|
||||
exports.init = function() {
|
||||
const content = gv._getAttr('_ts').metaContent;
|
||||
const content = gv._getAttr('_ts')?.metaContent;
|
||||
if (!content) return;
|
||||
const arr = extrace(bitwiseTwoNumarr(decrypt(content), gv.keys[17])).filter(it => it.length);
|
||||
if (!arr.length) {
|
||||
|
@ -3,23 +3,11 @@ const paths = require('@utils/paths');
|
||||
const fs = require('fs');
|
||||
const logger = require('@utils/logger');
|
||||
|
||||
module.exports = function (ts, immucfg) {
|
||||
module.exports = function (ts, immucfg, mate = {}) {
|
||||
const startTime = new Date().getTime();
|
||||
const coder = new Coder(ts, immucfg);
|
||||
const { code, $_ts } = coder.run();
|
||||
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 ? {
|
||||
name: 'makecode_input_ts',
|
||||
desc: 'url方式提取的ts:',
|
||||
@ -32,12 +20,37 @@ module.exports = function (ts, immucfg) {
|
||||
text: JSON.stringify(immucfg),
|
||||
extend: 'json',
|
||||
} : 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}` }))
|
||||
if (!fs.existsSync(paths.outputPath)) fs.mkdirSync(paths.outputPath);
|
||||
files.forEach(({ filepath, text }) => fs.writeFileSync(filepath, text))
|
||||
logger.info([
|
||||
`生成动态代码成功!用时:${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 '));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user