From dda1e4ae45e0715696cf314054a9cb463bd65a81 Mon Sep 17 00:00:00 2001 From: sickle <2628797272@qq.com> Date: Tue, 14 Jan 2025 17:53:04 +0800 Subject: [PATCH] v0.2.2.0 --- README.md | 1 + content/content.js | 21 ++++------------- popup/highlight.css | 25 ++++++++++++++++++++ popup/popup.js | 56 ++++++++++++--------------------------------- 4 files changed, 45 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 6a06188..4ec058c 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ - 内网 IP 匹配 - 完善了 URL 的匹配,使其能够匹配 IP 以及更多协议 - 设计了 Logo,优化文档排版样式 +- 修复配置信息不能展示的问题 --- diff --git a/content/content.js b/content/content.js index e473366..4e1c92c 100644 --- a/content/content.js +++ b/content/content.js @@ -495,23 +495,12 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { }); return true; // 保持消息通道打开 } else if (request.type === 'GET_CONFIG') { - // 返回配置信息,将正则表达式转换为字符串 - const config = { - WHITELIST: SCANNER_CONFIG.WHITELIST, - API: { - PATTERN: SCANNER_CONFIG.API.PATTERN.toString(), - STATIC_FILE_PATTERN: SCANNER_CONFIG.API.STATIC_FILE_PATTERN.toString() - }, - DOMAIN: { - BLACKLIST: SCANNER_CONFIG.DOMAIN.BLACKLIST, - SPECIAL_DOMAINS: SCANNER_CONFIG.DOMAIN.SPECIAL_DOMAINS - }, - IP: { - PRIVATE_RANGES: SCANNER_CONFIG.IP.PRIVATE_RANGES.map(pattern => pattern.toString()), - SPECIAL_RANGES: SCANNER_CONFIG.IP.SPECIAL_RANGES.map(pattern => pattern.toString()) + // 只返回白名单配置 + sendResponse({ + config: { + WHITELIST: SCANNER_CONFIG.WHITELIST } - }; - sendResponse({ config }); + }); } }); diff --git a/popup/highlight.css b/popup/highlight.css index 93e3187..2289aed 100644 --- a/popup/highlight.css +++ b/popup/highlight.css @@ -543,4 +543,29 @@ body { .fingerprint-group:hover { transform: translateX(2px); } + +/* 白名单域名展示样式 */ +.whitelist-domains { + margin-top: 10px; + background: #f8f9fa; + border-radius: 6px; + padding: 12px; +} + +.domain-item { + display: inline-block; + padding: 6px 12px; + background: #fff; + border-radius: 4px; + margin: 4px; + font-size: 13px; + color: #495057; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); +} + +.config-content { + color: #868e96; + font-size: 13px; + margin-bottom: 8px; +} \ No newline at end of file diff --git a/popup/popup.js b/popup/popup.js index 90ebd33..3ab9cd5 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -22,7 +22,7 @@ function switchPage(pageName) { // 显示配置信息 function displayConfig(config) { - const container = document.querySelector('.config-page'); + const container = document.querySelector('.config-page .container'); if (!config) { container.innerHTML = '
无法获取配置信息
'; return; @@ -31,43 +31,16 @@ function displayConfig(config) { let html = `
-

白名单域名

- -
- -
-

API 配置

-
-
API 路径匹配
- +

扫描白名单

+
+ 以下域名将不会被扫描:
-
-
静态文件匹配
- -
-
- -
-

域名配置

-
-
域名黑名单
- -
-
-
特殊域名
- -
-
- -
-

IP 配置

-
-
私有 IP 范围
- -
-
-
特殊 IP 范围
- +
+ ${config.WHITELIST ? config.WHITELIST.map(domain => ` +
+ ${domain} +
+ `).join('') : ''}
@@ -341,13 +314,12 @@ function initConfigPage() { chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { if (tabs[0]) { chrome.tabs.sendMessage(tabs[0].id, {type: 'GET_CONFIG'}, response => { - if (chrome.runtime.lastError) { - displayConfig(null); + if (chrome.runtime.lastError || !response || !response.config) { + const container = document.querySelector('.config-page .container'); + container.innerHTML = '
请刷新页面后重试
'; return; } - - const { config } = response; - displayConfig(config); + displayConfig(response.config); }); } });