Skip to content

Commit

Permalink
[optimize] decoder & console
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiram committed Dec 30, 2024
1 parent 423f0a7 commit 910dcb9
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions src/renderer/src/pages/lab/components/jsEdit/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@ import emitter from '@/utils/emitter';
import { CodeEditor } from '@/components/code-editor';
import { setT3Proxy } from '@/api/proxy';
import { addSite, putSite } from '@/api/site'
import { fetchConfig } from '@/api/setting';
import { fetchJsEditPdfa, fetchJsEditPdfh, fetchJsEditMuban, fetchJsEditDebug } from '@/api/lab';
import { fetchCmsHome, fetchCmsHomeVod, fetchCmsDetail, fetchCmsCategory, fetchCmsPlay, fetchCmsSearch, fetchCmsInit, fetchCmsRunMain, putSiteDefault, fetchCmsProxy } from '@/api/site';
import { aes } from '@/utils/crypto';
import reqHtml from '../reqHtml/index.vue';
import drpySuggestions from './utils/drpy_suggestions';
import drpyObjectInner from './utils/drpy_object_inner.ts?raw';
Expand Down Expand Up @@ -451,6 +453,41 @@ const utilsBasePath = async () => {
}
};
const utilsT3decode = async (content: string) => {
const res = await fetchCmsRunMain({
func: `function main(str) { return getOriginalJs(str) }`,
arg: content,
sourceId: debugId.value
});
return res || content;
};
const utilsT4decode = async (content: string) => {
const src = 'DM8U8pJ0qw0O5YK/a9FfWRh7mj3m+j9WtKTfOMvdDFUrbU1kT+yeBvoxwGdrZ1KXVfDJ/Smh4LSq3+A07ebBNwfxy7V3aRJuEAJQ9gLETBJ1oYahMY2WOwmxl8yeqUcBzcbaI45HpFKzqYnsZrV34ddBzRIac11sammtk4UbppFzfoSSOY0HdcLahBWc7UOBV+t/CSl1y5ut5qXdbKorYOK+t789Ifb7fTrhzpmG21l4y+AqwGLKyDiHAWQA76nMVBWyJSdNRu9EQ8CtRPBnpTi03h8eQNWopr8KUs8ghbTLEndyn/q/mBkrQ5i05DilDexDN3DRq4p3UpNli00pi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bhS7sVFwyH6MnbaiIM0BJekVk0PGbcIqSbFjdLQNNcdAt6Zvh2s0mSQwIcAjZ2f3/ZA31RrNS76lGUEI0A==';
const iv = '686A64686E780A0A0A0A0A0A0A0A0A0A';
const key = '686A64686E780A0A0A0A0A0A0A0A0A0A';
const authCodes = aes.decode(src, key, 'cbc', 'pkcs7padding','base64', iv, 'hex', 'hex', 'utf8');
const authCodes2array = authCodes.split('\n');
const randomAuthIndex = Math.floor(Math.random() * authCodes2array.length);
const randomAuthCode = authCodes2array[randomAuthIndex].trim();
const res = await fetchConfig({
url: 'http://127.0.0.1:5757/decoder',
method: 'POST',
data: { code: content, auth_code: randomAuthCode },
})
return res?.data?.result || content;
};
const utilsDecode = async (content: string) => {
const type = form.value.init.mode;
if (type === 't3') {
return await utilsT3decode(content);
} else if (type === 't4') {
return await utilsT4decode(content);
}
};
const utilsReadT4File = async () =>{
try {
const basePath = await utilsT4BasePath();
Expand Down Expand Up @@ -628,12 +665,7 @@ const handleDecode = async () => {
return;
};
const res = await fetchCmsRunMain({
func: `function main(str) {return getOriginalJs(str)}`,
arg: content,
sourceId: debugId.value
});
form.value.content.js = res;
form.value.content.js = await utilsDecode(content);
MessagePlugin.success(t('pages.setting.data.success'));
} catch (err) {
console.log(`[setting][editSource][decodeEvent][err]`, err);
Expand Down Expand Up @@ -766,11 +798,15 @@ const handleDomDebug = async (type: string, rule: string) => {
try {
const res = await methodMap[type]({ html: content, rule });
_console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
_console.log(res);
console.log(res);
MessagePlugin.success(`${t('pages.setting.data.success')}`);
} catch (err: any) {
_console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
_console.error(err);
console.error(err);
MessagePlugin.error(`${t('pages.setting.data.fail')}: ${err.message}`);
}
};
Expand Down Expand Up @@ -981,11 +1017,15 @@ const handleDataDebug = async (type: string, data: { [key: string]: any } = {})
const res = await methodMap[type]({ ...data, sourceId: debugId.value });
if (type === 'proxy') form.value.proxy.upload = JSON5.stringify(res);
_console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
_console.log(res);
console.log(res);
MessagePlugin.success(`${t('pages.setting.data.success')}`);
} catch (err: any) {
_console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
console.warn(`${type}: ${moment().format('YYYY-MM-DD HH:mm:ss')}`);
_console.error(err);
console.error(err);
MessagePlugin.error(`${t('pages.setting.data.fail')}: ${err.message}`);
}
};
Expand All @@ -1002,8 +1042,9 @@ const setupConsole = () => {
};
const handleConsoleClear = () => {
if (!log.value) return;
console.clear();
if (!log.value) return;
log.value.clear();
};
Expand Down Expand Up @@ -1724,6 +1765,7 @@ const handleWebviewLoad = (url: string) => {
height: 100%;
overflow-y: auto;
background-color: var(--td-bg-content-input-2);
color: var(--td-text-color-primary);
}
}
}
Expand Down

0 comments on commit 910dcb9

Please sign in to comment.