commit c787a2cd3a2dc4f5d2556a52202e6490a9cea298 Author: wsb1224 Date: Thu Oct 9 15:03:39 2025 +0800 第一次提交 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..10b731c --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/.idea/AIfuzhuchajian.iml b/.idea/AIfuzhuchajian.iml new file mode 100644 index 0000000..120e4cc --- /dev/null +++ b/.idea/AIfuzhuchajian.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..9c69411 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9802404 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..16be79c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/background.js b/background.js new file mode 100644 index 0000000..ae0b2f8 --- /dev/null +++ b/background.js @@ -0,0 +1,117 @@ +// Chrome扩展后台脚本 - 移除验证功能版 +// 版本: 1.2.0 + +// 图标状态管理 +let currentIconState = 'default'; +let iconTimeout = null; + +// 扩展安装时的初始化 +chrome.runtime.onInstalled.addListener((details) => { + console.log('AI助手增强工具扩展已安装'); + + if (details.reason === 'install') { + console.log('首次安装完成'); + } else if (details.reason === 'update') { + console.log('扩展已更新到版本', chrome.runtime.getManifest().version); + } + + // 初始化默认状态 + updateExtensionIcon('default'); +}); + +// 监听来自content script的消息 +chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { + if (request.action === 'resetComplete') { + // 记录增强功能启用 + console.log(`增强功能已启用: ${request.site}`, request); + + // 更新扩展图标 + updateExtensionIcon('success'); + + // 3秒后恢复默认图标 + if (iconTimeout) clearTimeout(iconTimeout); + iconTimeout = setTimeout(() => { + updateExtensionIcon('default'); + }, 3000); + + sendResponse({ received: true }); + return true; + } +}); + +// 监听标签页更新 +chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { + // 只在页面加载完成时处理 + if (changeInfo.status === 'complete' && tab.url) { + handleTabUrlChange(tab.url); + } +}); + +// 监听标签页切换 +chrome.tabs.onActivated.addListener(async (activeInfo) => { + try { + const tab = await chrome.tabs.get(activeInfo.tabId); + if (tab.url) { + handleTabUrlChange(tab.url); + } + } catch (error) { + console.log('获取标签页信息失败:', error); + // 出错时重置为默认状态 + updateExtensionIcon('default'); + } +}); + +/** + * 处理标签页URL变化 + * @param {string} url - 标签页URL + */ +function handleTabUrlChange(url) { + try { + const urlObj = new URL(url); + const supportedSites = ['matrix.tencent.com', 'www.badstudent.ai']; + + if (supportedSites.includes(urlObj.hostname)) { + console.log(`检测到支持的网站: ${urlObj.hostname}`); + updateExtensionIcon('active'); + } else { + // 只有当前状态不是默认状态时才更新 + if (currentIconState !== 'default') { + updateExtensionIcon('default'); + } + } + } catch (error) { + console.log('解析URL失败:', error); + // URL无效时重置为默认状态 + if (currentIconState !== 'default') { + updateExtensionIcon('default'); + } + } +} + +/** + * 更新扩展标题 + * @param {string} state - 状态: 'default', 'active', 'success' + */ +function updateExtensionIcon(state) { + // 避免不必要的更新 + if (currentIconState === state) { + return; + } + + currentIconState = state; + let title; + + switch (state) { + case 'active': + title = "AI增强助手 - 可用"; + break; + case 'success': + title = "AI增强助手 - 功能已启用"; + break; + default: + title = "AI增强助手"; + } + + chrome.action.setTitle({ title: title }) + .catch(error => console.error('设置扩展标题失败:', error)); +} \ No newline at end of file diff --git a/content.js b/content.js new file mode 100644 index 0000000..f5a5c72 --- /dev/null +++ b/content.js @@ -0,0 +1,98 @@ +(function() { +'use strict'; + +// === 核心功能 === +function initEnhancements() { + try { + const hostname = window.location.hostname; + console.log(`[Enhancement] 检测到网站: ${hostname}`); + + if (hostname === 'matrix.tencent.com') { + const key = 'fp'; + const value = generateRandomHex(32); + setStorageItem(key, value, 'Zhuque'); + } else if (hostname === 'www.badstudent.ai') { + const key = 'deviceId'; + const value = generateUUID(); + setStorageItem(key, value, 'BadStudentAI'); + } else { + console.log('[Enhancement] 当前网站不在支持列表中'); + } + } catch (error) { + console.error('[Enhancement] 初始化增强功能时出错:', error); + } +} + +// 随机十六进制生成 +function generateRandomHex(length) { + try { + // 优先使用crypto API + if (window.crypto && crypto.getRandomValues) { + const array = new Uint8Array(length); + crypto.getRandomValues(array); + return Array.from(array, byte => byte.toString(16).padStart(2, '0')).join(''); + } + + // 回退到Math.random() + const hex = '0123456789abcdef'; + let result = ''; + for (let i = 0; i < length; i++) { + result += hex[Math.floor(Math.random() * 16)]; + } + return result; + } catch (error) { + console.error('[Enhancement] 生成随机十六进制时出错:', error); + return '00000000000000000000000000000000'; // 默认值 + } +} + +// UUID生成 +function generateUUID() { + try { + // 优先使用crypto API + if (window.crypto && crypto.randomUUID) { + return crypto.randomUUID(); + } + + // 回退实现 + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + const r = Math.random() * 16 | 0; + const v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + } catch (error) { + console.error('[Enhancement] 生成UUID时出错:', error); + return '00000000-0000-0000-0000-000000000000'; // 默认值 + } +} + +// 存储设置 +function setStorageItem(key, value, site) { + try { + localStorage.setItem(key, value); + console.log(`[${site} Enhancement] 已启用增强功能,${key}: ${value}`); + + // 通知background + if (chrome && chrome.runtime && chrome.runtime.sendMessage) { + chrome.runtime.sendMessage({ + action: 'resetComplete', + site: site, + key: key, + value: value + }).catch(error => { + console.error('[Enhancement] 发送消息到background失败:', error); + }); + } + } catch(error) { + console.error('[Enhancement] 设置存储项失败:', error); + } +} + +// 页面加载完成后初始化增强功能 +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initEnhancements); +} else { + initEnhancements(); +} + +})(); \ No newline at end of file diff --git a/icons/icon.svg b/icons/icon.svg new file mode 100644 index 0000000..e3de221 --- /dev/null +++ b/icons/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..dedb627 --- /dev/null +++ b/manifest.json @@ -0,0 +1,38 @@ +{ + "manifest_version": 3, + "name": "AI 增强助手", + "version": "1.2.0", + "description": "提升用户使用AI的体验体验", + + "permissions": [ + "storage", + "activeTab", + "tabs", + "alarms" + ], + + "host_permissions": [ + "https://matrix.tencent.com/*", + "https://www.badstudent.ai/*" + ], + + "content_scripts": [ + { + "matches": [ + "https://matrix.tencent.com/*", + "https://www.badstudent.ai/*" + ], + "js": ["content.js"], + "run_at": "document_start" + } + ], + + "background": { + "service_worker": "background.js" + }, + + "action": { + "default_popup": "popup.html", + "default_title": "AI 增强助手" + } +} \ No newline at end of file diff --git a/popup.css b/popup.css new file mode 100644 index 0000000..4777783 --- /dev/null +++ b/popup.css @@ -0,0 +1,499 @@ +/* Chrome扩展弹窗样式 - 重构版 */ +:root { + /* 颜色变量 */ + --primary-color: #667eea; + --secondary-color: #764ba2; + --success-color: #00c851; + --danger-color: #ff4444; + --warning-color: #ffbb33; + --info-color: #33b5e5; + --text-color: #333; + --text-light: #666; + --bg-white: #ffffff; + --bg-light: #f8f9fa; + --border-color: #e1e5e9; + --border-light: #f0f0f0; + + /* 尺寸变量 */ + --border-radius-sm: 4px; + --border-radius-md: 8px; + --border-radius-lg: 12px; + --spacing-xs: 4px; + --spacing-sm: 8px; + --spacing-md: 12px; + --spacing-lg: 16px; + --spacing-xl: 20px; + + /* 阴影变量 */ + --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1); + --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1); + --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.15); + + /* 动画变量 */ + --transition-fast: 0.2s ease; + --transition-normal: 0.3s ease; + --transition-slow: 0.5s ease; +} + +/* 暗色模式变量 */ +@media (prefers-color-scheme: dark) { + :root { + --text-color: #f0f0f0; + --text-light: #cccccc; + --bg-white: #2a2a2a; + --bg-light: #3a3a3a; + --border-color: #444444; + --border-light: #555555; + } +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + width: 380px; + min-height: 500px; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%); + color: var(--text-color); + transition: background var(--transition-normal), color var(--transition-normal); +} + +.container { + padding: var(--spacing-xl); + display: flex; + flex-direction: column; + gap: var(--spacing-lg); +} + +/* 头部样式 */ +.header { + text-align: center; + margin-bottom: 0; + color: var(--bg-white); + animation: fadeIn 0.8s ease; +} + +@keyframes fadeIn { + from { opacity: 0; transform: translateY(-10px); } + to { opacity: 1; transform: translateY(0); } +} + +.logo { + font-size: 32px; + margin-bottom: var(--spacing-sm); + transition: transform var(--transition-normal); + display: inline-block; +} + +.logo:hover { + transform: scale(1.1) rotate(5deg); +} + +.title { + font-size: 18px; + font-weight: 600; + margin-bottom: var(--spacing-xs); + text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); +} + +.version { + font-size: 12px; + opacity: 0.8; + background: rgba(255, 255, 255, 0.2); + padding: 2px 8px; + border-radius: 10px; + display: inline-block; +} + +/* 状态卡片 */ +.status-section { + margin-bottom: var(--spacing-xl); +} + +.status-card { + background: var(--bg-white); + border-radius: var(--border-radius-lg); + padding: var(--spacing-lg); + display: flex; + align-items: center; + gap: var(--spacing-md); + box-shadow: var(--shadow-md); + transition: all 0.3s ease; +} + +.status-card:hover { + transform: translateY(-2px); + box-shadow: var(--shadow-lg); +} + +.status-card.activated { + border-left: 4px solid var(--success-color); +} + +.status-card.not-activated { + border-left: 4px solid var(--danger-color); +} + +.status-icon { + font-size: 24px; + width: 40px; + height: 40px; + display: flex; + align-items: center; + justify-content: center; + border-radius: 50%; + background: var(--bg-light); + transition: transform 0.2s ease; +} + +.status-card:hover .status-icon { + transform: scale(1.1); +} + +.status-text { + flex: 1; + font-weight: 500; +} + +/* 网站列表 */ +.sites-section { + margin-bottom: var(--spacing-xl); +} + +.section-title { + color: var(--bg-white); + font-size: 14px; + font-weight: 600; + margin-bottom: var(--spacing-md); + opacity: 0.9; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.sites-list { + background: var(--bg-white); + border-radius: var(--border-radius-lg); + overflow: hidden; + box-shadow: var(--shadow-md); + transition: transform 0.3s ease; +} + +.sites-list:hover { + transform: translateY(-2px); + box-shadow: var(--shadow-lg); +} + +.site-item { + display: flex; + align-items: center; + padding: var(--spacing-md) var(--spacing-lg); + gap: var(--spacing-md); + border-bottom: 1px solid var(--border-light); + transition: background-color 0.2s ease; +} + +.site-item:hover { + background-color: rgba(102, 126, 234, 0.05); +} + +.site-item:last-child { + border-bottom: none; +} + +.site-icon { + font-size: 20px; + width: 36px; + height: 36px; + display: flex; + align-items: center; + justify-content: center; + border-radius: var(--border-radius-md); + background: var(--bg-light); + transition: transform 0.2s ease; +} + +.site-item:hover .site-icon { + transform: scale(1.1); +} + +.site-info { + flex: 1; +} + +.site-name { + font-weight: 500; + font-size: 14px; + margin-bottom: 2px; +} + +.site-url { + font-size: 11px; + color: var(--text-light); +} + +.site-status { + font-size: 11px; + padding: var(--spacing-xs) var(--spacing-sm); + border-radius: var(--border-radius-sm); + font-weight: 500; +} + +.site-status.active { + background: #d4f5d4; + color: #00875a; +} + +.site-status.inactive { + background: #ffebe6; + color: #de350b; +} + +/* 按钮样式 */ +.actions-section { + margin-bottom: var(--spacing-xl); +} + +.btn { + width: 100%; + padding: var(--spacing-md) var(--spacing-lg); + border: none; + border-radius: var(--border-radius-md); + font-size: 14px; + font-weight: 600; + cursor: pointer; + transition: all 0.3s ease; + display: flex; + align-items: center; + justify-content: center; + gap: var(--spacing-sm); + margin-bottom: var(--spacing-sm); +} + +.btn:last-child { + margin-bottom: 0; +} + +.btn-primary { + background: var(--success-color); + color: var(--bg-white); + box-shadow: 0 4px 12px rgba(0, 200, 81, 0.3); +} + +.btn-primary:hover:not(:disabled) { + background: #00a844; + transform: translateY(-2px); + box-shadow: var(--shadow-lg); +} + +.btn-primary:disabled { + background: #ccc; + cursor: not-allowed; + box-shadow: none; +} + +.btn-secondary { + background: var(--bg-white); + color: var(--primary-color); + border: 2px solid var(--primary-color); +} + +.btn-secondary:hover { + background: var(--primary-color); + color: var(--bg-white); + transform: translateY(-2px); +} + +.btn-activate { + background: var(--primary-color); + color: var(--bg-white); + width: auto; + margin: 0; + padding: 10px 20px; + flex-shrink: 0; +} + +.btn-activate:hover { + background: #5a6fd8; +} + +.btn-icon { + font-size: 16px; + transition: transform 0.2s ease; +} + +.btn:hover .btn-icon { + transform: scale(1.2); +} + +/* 激活区域 */ +.activation-section { + background: white; + border-radius: 12px; + padding: 16px; + margin-bottom: 20px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); +} + +.input-group { + display: flex; + gap: 8px; + margin-bottom: 12px; +} + +.activation-input { + flex: 1; + padding: 10px 12px; + border: 2px solid #e1e5e9; + border-radius: 6px; + font-size: 14px; + text-transform: uppercase; + outline: none; + transition: border-color 0.3s ease; +} + +.activation-input:focus { + border-color: #667eea; + box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); +} + +/* 已激活信息 */ +.activated-info { + background: white; + border-radius: 12px; + padding: 16px; + margin-bottom: 20px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); +} + +.info-item { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; +} + +.info-item:last-child { + margin-bottom: 0; +} + +.info-label { + font-size: 14px; + color: #666; +} + +.info-value { + font-size: 14px; + font-weight: 500; +} + +.info-value.success { + color: #00c851; +} + +/* 消息提示 */ +.message { + padding: 10px 12px; + border-radius: 6px; + font-size: 13px; + font-weight: 500; + text-align: center; +} + +.message.success { + background: #d4f5d4; + color: #00875a; + border: 1px solid #79e2f2; +} + +.message.error { + background: #ffe6e6; + color: #d93651; + border: 1px solid #ffc6cb; +} + +/* 帮助区域 */ +.help-section { + margin-bottom: 20px; +} + +.help-details { + background: rgba(255, 255, 255, 0.1); + border-radius: 8px; + overflow: hidden; +} + +.help-summary { + padding: 12px 16px; + cursor: pointer; + color: white; + font-weight: 500; + font-size: 14px; + list-style: none; + transition: background 0.3s ease; +} + +.help-summary:hover { + background: rgba(255, 255, 255, 0.1); +} + +.help-summary::-webkit-details-marker { + display: none; +} + +.help-summary::before { + content: '▶'; + margin-right: 8px; + transition: transform 0.3s ease; +} + +.help-details[open] .help-summary::before { + transform: rotate(90deg); +} + +.help-content { + padding: 0 16px 16px; + color: white; + font-size: 13px; + line-height: 1.5; +} + +.help-content ol { + margin-bottom: 12px; + padding-left: 20px; +} + +.help-content li { + margin-bottom: 4px; +} + +.help-note { + padding: 10px; + background: rgba(255, 255, 255, 0.1); + border-radius: 6px; + font-size: 12px; +} + +/* 底部 */ +.footer { + text-align: center; + color: white; + opacity: 0.7; +} + +.footer-text { + font-size: 12px; +} + +/* 动画 */ +@keyframes pulse { + 0%, 100% { opacity: 1; } + 50% { opacity: 0.5; } +} + +.loading { + animation: pulse 1.5s infinite; +} diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..12a1868 --- /dev/null +++ b/popup.html @@ -0,0 +1,61 @@ + + + + + + AI 增强助手 + + + +
+ +
+ +

AI 增强助手

+
v1.2.0
+
+ + +
+
+
+
加载中...
+
+
+ + + + + +
+
+ 使用说明 +
+
    +
  1. 访问支持的AI网站
  2. +
  3. 扩展会自动启用增强功能
  4. +
+
+
+
+ + +
+ +
+
+ + + + \ No newline at end of file diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..2e1285e --- /dev/null +++ b/popup.js @@ -0,0 +1,60 @@ +// 安全popup脚本 - 移除验证功能版 +(function() { +'use strict'; + +console.log('Popup模块已加载'); + +// 显示状态信息 +function showStatus(message, isSuccess = true) { + const statusDiv = document.getElementById('activation-status'); + if (!statusDiv) { + console.error('未找到状态元素'); + return; + } + + const icon = isSuccess ? '✅' : '❌'; + statusDiv.innerHTML = ` +
${icon}
+
${message}
+ `; + statusDiv.className = `status-card ${isSuccess ? 'activated' : 'not-activated'}`; +} + +// 显示已激活信息 +function showActivatedInfo() { + // 隐藏激活相关区域 + const activationSection = document.getElementById('activation-section'); + if (activationSection) activationSection.style.display = 'none'; + + // 显示已激活信息 + const activatedInfo = document.getElementById('activated-info'); + if (activatedInfo) { + activatedInfo.style.display = 'block'; + + // 更新信息显示 + const statusSpan = document.getElementById('current-status'); + const expirySpan = document.getElementById('expiry-date'); + + if (statusSpan) statusSpan.textContent = '已启用'; + if (expirySpan) expirySpan.textContent = '无限制'; + } + + // 隐藏重新激活按钮 + const reactivateBtn = document.getElementById('reactivate-btn'); + if (reactivateBtn) reactivateBtn.style.display = 'none'; +} + +document.addEventListener('DOMContentLoaded', function() { + console.log('DOMContentLoaded事件触发'); + + try { + // 直接显示已激活状态 + showStatus('功能已启用', true); + showActivatedInfo(); + } catch (error) { + console.error('Popup初始化失败:', error); + showStatus('初始化失败', false); + } +}); + +})(); \ No newline at end of file diff --git a/安装说明.txt b/安装说明.txt new file mode 100644 index 0000000..7696826 --- /dev/null +++ b/安装说明.txt @@ -0,0 +1,25 @@ +# AI 助手增强工具 + +## 安装步骤: + +1. 打开Chrome浏览器 +2. 访问 chrome://extensions/ +3. 开启"开发者模式"(右上角开关) +4. 点击"加载已解压的扩展程序" +5. 选择这个文件夹(chrome-extension) +6. 安装完成! + +## 使用方法: + +1. 访问支持的AI网站 +2. 启动后扩展会自动启用增强功能 +3. 许可证状态会自动保存 + +## 注意事项: +- 如有问题请联系技术支持 + +## 版本信息: + +- 版本:1.2.0 +- 支持:Chrome Manifest V3 +- 更新日期:2025年