-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
22 lines (20 loc) · 870 Bytes
/
popup.js
File metadata and controls
22 lines (20 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.getElementById('open').addEventListener('click', function() {
// 发送消息给当前页面
// console.log("Sending message to content script...");
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: "insertDiv"});
});
});
// 监听来自 content.js 的消息
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.action === "insertDivSuccess") {
// console.log("Received message from content script:", message);
// alert("成功");
}
});
document.getElementById('clearCache').addEventListener('click', function() {
// 发送消息给当前页面
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: "clearCache"});
});
});