From 1fcddd5667f6a82a49608a2877e789e7f766f7a7 Mon Sep 17 00:00:00 2001 From: 7Sageer <125936732+7Sageer@users.noreply.github.com> Date: Sat, 7 Dec 2024 15:41:44 +0800 Subject: [PATCH] feat: add event listeners for rule checkboxes to update predefined rules selection --- README.md | 4 ++-- docs/update-log.md | 4 ++++ src/htmlBuilder.js | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eed26246..f3efd773 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ ## 📝 最近更新 -### 2024-11-30 -- 添加对 Shadowsocks 旧式 URL 的支持 +### 2024-12-07 +- 确保在手动选择规则时,预定义规则集的选择框也会自动更新为 "custom" [查看完整更新日志](/docs/update-log.md) ## 🔧 项目结构 diff --git a/docs/update-log.md b/docs/update-log.md index 1b249e2b..54ee8734 100644 --- a/docs/update-log.md +++ b/docs/update-log.md @@ -1,5 +1,9 @@ # 更新日志 +## 2024-12-07 + +- 确保在手动选择规则时,预定义规则集的选择框也会自动更新为 "custom" + ## 2024-11-30 - 添加对 Shadowsocks 旧式 URL 的支持 diff --git a/src/htmlBuilder.js b/src/htmlBuilder.js index cc3940c5..967a2fd0 100644 --- a/src/htmlBuilder.js +++ b/src/htmlBuilder.js @@ -425,6 +425,19 @@ const applyPredefinedRulesFunction = () => ` } }); } + + // Add event listeners to checkboxes + document.addEventListener('DOMContentLoaded', function() { + const checkboxes = document.querySelectorAll('.rule-checkbox'); + checkboxes.forEach(checkbox => { + checkbox.addEventListener('change', function() { + const predefinedSelect = document.getElementById('predefinedRules'); + if (predefinedSelect.value !== 'custom') { + predefinedSelect.value = 'custom'; + } + }); + }); + }); `; const tooltipFunction = () => `