diff --git a/api/index.html b/api/index.html new file mode 100644 index 0000000..3360221 --- /dev/null +++ b/api/index.html @@ -0,0 +1,1767 @@ + + +
+ +${escapeHtml(rule)}-
+ `; + grid.appendChild(newGridItem); + blockRuleElement = document.getElementById('result-block-rule'); + } + } + + // 更新屏蔽规则显示 + if (blockRuleElement) { + blockRuleElement.textContent = blockRule; + } + + // 检查是否存在屏蔽来源显示元素,如果不存在则创建 + let blockSourceElement = document.getElementById('result-block-source'); + if (!blockSourceElement) { + // 创建屏蔽来源显示区域 + const grid = resultDiv.querySelector('.grid'); + if (grid) { + const newGridItem = document.createElement('div'); + newGridItem.className = 'bg-gray-50 p-4 rounded-lg'; + newGridItem.innerHTML = ` +-
+ `; + grid.appendChild(newGridItem); + blockSourceElement = document.getElementById('result-block-source'); + } + } + + // 更新屏蔽来源显示 + if (blockSourceElement) { + blockSourceElement.textContent = blockSource; + } + + document.getElementById('result-time').textContent = timestamp; + document.getElementById('result-details').textContent = JSON.stringify(result, null, 2); +} + +// 保存查询历史 +function saveQueryHistory(domain, result) { + // 获取现有历史记录 + let history = JSON.parse(localStorage.getItem('dnsQueryHistory') || '[]'); + + // 创建历史记录项 + const historyItem = { + domain: domain, + timestamp: new Date().toISOString(), + result: { + blocked: result.blocked, + blockRuleType: result.blockRuleType, + blockRule: result.blockRule, + blocksource: result.blocksource + } + }; + + // 添加到历史记录开头 + history.unshift(historyItem); + + // 限制历史记录数量 + if (history.length > 20) { + history = history.slice(0, 20); + } + + // 保存到本地存储 + localStorage.setItem('dnsQueryHistory', JSON.stringify(history)); +} + +// 加载查询历史 +function loadQueryHistory() { + const historyDiv = document.getElementById('query-history'); + if (!historyDiv) return; + + // 获取历史记录 + const history = JSON.parse(localStorage.getItem('dnsQueryHistory') || '[]'); + + if (history.length === 0) { + historyDiv.innerHTML = '