a42f1f2cce
新增 `chrome.runtime.onMessage` 监听器,用于接收来自 popup 或 sidepanel 的 `copyText` 消息,并将该消息转发至当前活动标签页的内容脚本,实现跨组件通信 与剪贴板写入功能。同时更新 manifest.json 权限声明,增加 clipboardWrite 和 clipboardRead 权限以支持 navigator.clipboard API 的调用。 此外,简化了 sidepanel 的 HTML 结构并增强时间戳工具功能,包括动态切换时间戳 单位、实时刷新与复制到剪贴板等交互逻辑。
48 lines
1.5 KiB
HTML
48 lines
1.5 KiB
HTML
<!-- sidepanel/index.html -->
|
|
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>测试工具</title>
|
|
<link rel="stylesheet" href="index.css" />
|
|
</head>
|
|
<body>
|
|
<div id="app">
|
|
<!-- 导航栏 -->
|
|
<nav class="navbar">
|
|
<button id="nav-timestamp" class="nav-button active">时间戳转换</button>
|
|
<button id="nav-other" class="nav-button">其他工具</button>
|
|
<button id="close" class="close-button">X</button>
|
|
</nav>
|
|
|
|
<!-- 页面内容容器 -->
|
|
<div class="content">
|
|
<!-- 时间戳工具页面 -->
|
|
<div id="page-timestamp" class="page active">
|
|
<h2>时间戳工具</h2>
|
|
<div>
|
|
<h2>当前时间戳</h2>
|
|
<p>
|
|
<a href="javascript:;" id="current-timestamp">1762873747965</a>
|
|
<span id="timestamp-unit">毫秒</span>
|
|
<button id="toggle-timestamp-btn">切换单位</button>
|
|
<button id="copy-timestamp-btn">复制</button>
|
|
<button id="stop-timestamp-btn">停止</button>
|
|
<button id="start-timestamp-btn" style="display: none">开始</button>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 其他工具页面 -->
|
|
<div id="page-other" class="page">
|
|
<h2>其他工具页面</h2>
|
|
<p>这里可以放置其他工具的内容。</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="index.js"></script>
|
|
</body>
|
|
</html>
|