-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
59 lines (48 loc) · 1.72 KB
/
Copy pathbackground.js
File metadata and controls
59 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
chrome.runtime.onInstalled.addListener(() => {
console.log("T&C Summarizer Extension Installed!");
});
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === "complete" && tab.url) {
chrome.storage.sync.clear(() => {
console.log("Storage cleared for new tab.");
chrome.action.setBadgeText({ text: "" });
const excludedDomains = ["google.com"];
const url = new URL(tab.url);
if (!excludedDomains.some(domain => url.hostname.includes(domain))) {
chrome.scripting.executeScript({
target: { tabId: tabId },
files: ["content.js"]
});
} else {
console.log('Script not injected for: ${url.hostname}');
}
});
}
});
// Example notification function
function notifyUser(title, message) {
chrome.notifications.create({
type: "basic",
iconUrl: "icon.png",
title: title,
message: message
});
}
// error fix
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "displaySummary") {
// Optionally log the summary in the background script
console.log("Summary received:", message.summary);
}
});
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "updateBadge") {
console.log("Adding works");
// Set the badge text and color
chrome.action.setBadgeText({ text: message.count.toString() });
chrome.action.setBadgeBackgroundColor({ color: "#FF0000" }); // Red background
} else if (message.action === "clearBadge") {
console.log("Clearing works");
chrome.action.setBadgeText({ text: "" });
}
});