-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
18 lines (18 loc) · 803 Bytes
/
background.js
File metadata and controls
18 lines (18 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "modify") {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, {action: "modify"}, (response) => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
} else if (response) {
chrome.storage.local.set({ wordCount: response.wordCount || 0, charCount: response.charCount || 0 });
}
});
});
} else if (request.action === "reload") {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
chrome.tabs.reload(tabs[0].id);
});
}
sendResponse();
});