Files
Dotbypasser/extension/debug-helper.js
2026-01-10 16:53:02 +08:00

151 lines
5.8 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Debug Helper Script
*
* Copy and paste this into the browser console (F12) while the popup is open
* to diagnose storage and configuration issues.
*
* Usage:
* 1. Open extension popup
* 2. Press F12 to open DevTools
* 3. Paste this entire file into the console
* 4. Call: await debugExtension()
*/
async function debugExtension() {
console.log('╔════════════════════════════════════════╗');
console.log('║ Payment Automation Suite Debugger ║');
console.log('╚════════════════════════════════════════╝\n');
// 1. Check chrome.storage.sync
console.log('📦 Checking chrome.storage.sync...');
try {
const syncData = await chrome.storage.sync.get(null);
console.log('✅ Storage sync data:', syncData);
if (syncData.modules) {
console.log('\n📋 Module States:');
for (const [name, config] of Object.entries(syncData.modules)) {
const status = config.enabled ? '🟢 ON' : '⚫ OFF';
console.log(` ${status} ${name}`);
}
}
if (syncData.globalSettings) {
console.log('\n⚙ Global Settings:');
console.log(` Master Enabled: ${syncData.globalSettings.masterEnabled ? '🟢 YES' : '⚫ NO'}`);
console.log(` Debug Mode: ${syncData.globalSettings.debugMode ? '🟢 YES' : '⚫ NO'}`);
}
} catch (error) {
console.error('❌ Error reading storage.sync:', error);
}
// 2. Check chrome.storage.local
console.log('\n📊 Checking chrome.storage.local...');
try {
const localData = await chrome.storage.local.get(null);
console.log('✅ Storage local data:', localData);
if (localData.stats) {
console.log('\n📈 Statistics:');
console.log(` Captchas Solved: ${localData.stats.captchasSolved || 0}`);
console.log(` Forms Filled: ${localData.stats.formsFilled || 0}`);
console.log(` Cards Generated: ${localData.stats.cardsGenerated || 0}`);
console.log(` Payments Captured: ${localData.stats.paymentsCaptured || 0}`);
}
} catch (error) {
console.error('❌ Error reading storage.local:', error);
}
// 3. Test message passing
console.log('\n📨 Testing message passing to background...');
try {
const response = await chrome.runtime.sendMessage({ type: 'GET_CONFIG' });
if (response && response.success) {
console.log('✅ Background communication working');
console.log('Received config:', response.config);
} else {
console.error('❌ Background communication failed:', response);
}
} catch (error) {
console.error('❌ Error communicating with background:', error);
}
// 4. Check DOM elements
console.log('\n🎨 Checking popup DOM elements...');
const masterSwitch = document.getElementById('masterSwitch');
const moduleToggles = document.querySelectorAll('.module-toggle');
if (masterSwitch) {
console.log(`✅ Master switch found: ${masterSwitch.checked ? '🟢 ON' : '⚫ OFF'}`);
} else {
console.error('❌ Master switch not found in DOM');
}
if (moduleToggles.length > 0) {
console.log(`✅ Found ${moduleToggles.length} module toggles:`);
moduleToggles.forEach(toggle => {
const name = toggle.dataset.module;
const state = toggle.checked ? '🟢 ON' : '⚫ OFF';
console.log(` ${state} ${name}`);
});
} else {
console.error('❌ No module toggles found in DOM');
}
// 5. Check storage quota
console.log('\n💾 Checking storage quota...');
try {
if (chrome.storage.sync.getBytesInUse) {
const bytesInUse = await chrome.storage.sync.getBytesInUse(null);
const quota = chrome.storage.sync.QUOTA_BYTES || 102400; // 100KB default
const percentage = ((bytesInUse / quota) * 100).toFixed(2);
console.log(`✅ Using ${bytesInUse} / ${quota} bytes (${percentage}%)`);
if (bytesInUse > quota * 0.8) {
console.warn('⚠️ Warning: Storage usage above 80%');
}
}
} catch (error) {
console.log(' Storage quota check not available');
}
console.log('\n═══════════════════════════════════════\n');
console.log('💡 Tips:');
console.log(' • If modules reset: Storage may not be saving properly');
console.log(' • Check Background logs: chrome://extensions → Details → Inspect service worker');
console.log(' • If message passing fails: Background script may have crashed');
console.log('\n═══════════════════════════════════════\n');
}
// Also provide individual helper functions
window.checkStorage = async () => {
const data = await chrome.storage.sync.get(null);
console.log('Current storage state:', data);
return data;
};
window.resetStorage = async () => {
console.warn('⚠️ Clearing all storage...');
await chrome.storage.sync.clear();
await chrome.storage.local.clear();
console.log('✅ Storage cleared. Reload the extension.');
};
window.enableAllModules = async () => {
console.log('🟢 Enabling all modules...');
const response = await chrome.runtime.sendMessage({ type: 'TOGGLE_MASTER', enabled: true });
console.log('Response:', response);
location.reload(); // Reload popup
};
window.disableAllModules = async () => {
console.log('⚫ Disabling all modules...');
const response = await chrome.runtime.sendMessage({ type: 'TOGGLE_MASTER', enabled: false });
console.log('Response:', response);
location.reload(); // Reload popup
};
console.log('✅ Debug helper loaded!');
console.log('Run: await debugExtension()');
console.log('Or use: checkStorage(), resetStorage(), enableAllModules(), disableAllModules()');