-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
42 lines (36 loc) · 1.38 KB
/
background.js
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
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "processData") {
console.log("Received message in background.js");
// Process the data
const processedData = {
assignmentName: processAssignmentName(request.data.assignmentName),
dueDate: processDueDate(request.data.dueDate),
courseName: processCourseName(request.data.courseName),
url: request.data.url
};
// Send processed data to the popup script and handle response asynchronously
chrome.runtime.sendMessage({action: "updatePopupForm", data: processedData}, response => {
if (chrome.runtime.lastError) {
// Handle error
console.error("Error in sending message:", chrome.runtime.lastError);
} else {
// Handle success
console.log("Message sent to frontend, response:", response);
}
});
// Indicate that you will respond asynchronously
return true;
}
});
function processAssignmentName(assignmentName) {
// Processing logic for assignment name
return assignmentName;
}
function processDueDate(dueDate) {
// Processing logic for due date
return dueDate;
}
function processCourseName(courseName) {
// Processing logic for course name
return courseName;
}