feat(chrome-qwen-bridge): 🔥 init chrome qwen code bridge

This commit is contained in:
yiliang114
2025-12-20 00:58:41 +08:00
parent a92be72e88
commit a60c5c6697
57 changed files with 9489 additions and 0 deletions

View File

@@ -0,0 +1,178 @@
<!DOCTYPE html>
<html>
<head>
<title>Chrome Extension Debug Console</title>
<style>
body {
font-family: monospace;
padding: 20px;
background: #1e1e1e;
color: #d4d4d4;
}
h1 {
color: #569cd6;
}
button {
background: #569cd6;
color: white;
border: none;
padding: 8px 16px;
margin: 5px;
cursor: pointer;
border-radius: 4px;
}
button:hover {
background: #4080c0;
}
#console {
background: #2d2d30;
padding: 15px;
margin-top: 20px;
border-radius: 4px;
min-height: 300px;
max-height: 500px;
overflow-y: auto;
white-space: pre-wrap;
}
.log {
margin: 5px 0;
padding: 5px;
border-left: 3px solid #569cd6;
padding-left: 10px;
}
.error {
border-left-color: #f44747;
color: #f44747;
}
.success {
border-left-color: #4ec9b0;
color: #4ec9b0;
}
.info {
color: #9cdcfe;
}
.warning {
border-left-color: #ce9178;
color: #ce9178;
}
</style>
</head>
<body>
<h1>🔧 Chrome Extension Debug Console</h1>
<div>
<button onclick="testConnection()">Test Connection</button>
<button onclick="getStatus()">Get Status</button>
<button onclick="clearConsole()">Clear Console</button>
<button onclick="viewBackgroundLogs()">View Background Logs</button>
<button onclick="reloadExtension()">Reload Extension</button>
</div>
<div id="console"></div>
<script>
const consoleDiv = document.getElementById('console');
let extensionId = 'cimaabkejokbhjkdnajgfniiolfjgbhd';
function log(message, type = 'log') {
const logDiv = document.createElement('div');
logDiv.className = `log ${type}`;
const timestamp = new Date().toLocaleTimeString();
logDiv.textContent = `[${timestamp}] ${message}`;
consoleDiv.appendChild(logDiv);
consoleDiv.scrollTop = consoleDiv.scrollHeight;
}
function clearConsole() {
consoleDiv.innerHTML = '';
log('Console cleared', 'info');
}
async function testConnection() {
log('Testing connection to extension...', 'info');
try {
// Try to send a message to the extension
const response = await chrome.runtime.sendMessage(extensionId, {
type: 'CONNECT'
});
if (response) {
if (response.success) {
log('✅ Connected successfully!', 'success');
log(`Status: ${response.status}`, 'info');
} else {
log(`❌ Connection failed: ${response.error}`, 'error');
}
} else {
log('❌ No response from extension', 'error');
log('Possible issues:', 'warning');
log('1. Extension not loaded/enabled', 'warning');
log('2. Extension ID incorrect', 'warning');
log('3. Service worker crashed', 'warning');
}
} catch (error) {
log(`❌ Error: ${error.message}`, 'error');
if (error.message.includes('Could not establish connection')) {
log('Extension is not responding. Checking extension ID...', 'warning');
// Try to find the extension
if (chrome.management) {
chrome.management.getAll((extensions) => {
const qwenExt = extensions.find(ext =>
ext.name.includes('Qwen') || ext.name.includes('CLI Bridge')
);
if (qwenExt) {
log(`Found extension: ${qwenExt.name} (${qwenExt.id})`, 'info');
extensionId = qwenExt.id;
} else {
log('Extension not found in installed extensions', 'error');
}
});
}
}
}
}
async function getStatus() {
log('Getting extension status...', 'info');
try {
const response = await chrome.runtime.sendMessage(extensionId, {
type: 'GET_STATUS'
});
if (response) {
log(`Status received: ${JSON.stringify(response, null, 2)}`, 'success');
} else {
log('No status response', 'error');
}
} catch (error) {
log(`Error getting status: ${error.message}`, 'error');
}
}
function viewBackgroundLogs() {
log('Opening service worker console...', 'info');
window.open(`chrome://extensions/?id=${extensionId}`, '_blank');
log('Click "Inspect views: service worker" to see logs', 'info');
}
function reloadExtension() {
log('Reloading extension...', 'info');
if (chrome.runtime && chrome.runtime.reload) {
chrome.runtime.reload();
log('Extension reloaded', 'success');
} else {
log('Cannot reload from here. Please reload manually in chrome://extensions/', 'warning');
}
}
// Initial log
log('Debug console ready', 'success');
log(`Extension ID: ${extensionId}`, 'info');
log('Click "Test Connection" to start debugging', 'info');
</script>
</body>
</html>