/**
 * 检查所有核心 JS 文件状态
 */
const fs = require('fs');

const files = [
    'deobfuscated_full/extension/out/api/client.js',
    'deobfuscated_full/extension/out/extension.js',
    'deobfuscated_full/extension/out/utils/account.js',
    'deobfuscated_full/extension/out/utils/sqlite.js',
    'deobfuscated_full/extension/out/webview/provider.js'
];

console.log('='.repeat(60));
console.log('  Extension 核心文件检查');
console.log('='.repeat(60));

files.forEach(file => {
    try {
        const code = fs.readFileSync(file, 'utf8');
        const size = (code.length / 1024).toFixed(2);
        const lines = code.split('\n').length;

        // 检查混淆特征
        const oxVars = (code.match(/_0x[a-f0-9]+/gi) || []).length;
        const unicode = (code.match(/\\u[0-9a-fA-F]{4}/g) || []).length;
        const encrypted = (code.match(/_0x[a-f0-9]+\s*\(\s*['"]0x/gi) || []).length;
        const chinese = (code.match(/[\u4e00-\u9fff]/g) || []).length;

        const isClean = oxVars === 0 && encrypted === 0;
        const status = isClean ? '✅ 已清洗' : '❌ 需处理';

        const fileName = file.split('/').pop();
        console.log('\n' + '📄 ' + fileName);
        console.log('   状态: ' + status);
        console.log('   大小: ' + size + ' KB | 行数: ' + lines);
        console.log('   _0x变量: ' + oxVars + ' | Unicode: ' + unicode + ' | 加密调用: ' + encrypted + ' | 中文: ' + chinese);
    } catch (e) {
        console.log('\n📄 ' + file + ': ❌ 读取失败 - ' + e.message);
    }
});

console.log('\n' + '='.repeat(60));
