-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
113 lines (103 loc) · 3.86 KB
/
content.js
File metadata and controls
113 lines (103 loc) · 3.86 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// content.js
//Show the Modal on Notification arrival
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "SHOW_MODAL") {
const { task, time } = message;
// Check if a modal already exists, remove it
const existingModal = document.getElementById("notlify-modal");
if (existingModal) existingModal.remove();
// Create the modal container
const modal = document.createElement("div");
modal.id = "notlify-modal";
modal.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
`;
// Create the modal content
const modalContent = document.createElement("div");
modalContent.style.cssText = `
background-color: #1A1A1D;
color: ghostwhite;
border-radius: 8px;
width: 90%;
max-width: 400px;
padding: 20px;
text-align: center;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
font-family: Arial, sans-serif;
`;
// Add the "Notlify" heading with logo
const header = document.createElement("div");
header.style.cssText = `
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
`;
const logo = document.createElement("img");
logo.src = chrome.runtime.getURL("images/logo.png"); // images path
logo.alt = "Notlify Logo";
logo.style.cssText = `
width: 50px;
height: 50px;
margin-right: 10px;
border-radius: 50%;
`;
const title = document.createElement("h2");
title.innerText = "Notlify";
title.style.cssText = `
font-size: 30px;
font-weight: bold;
margin: 0;
color: ghostwhite;
`;
header.appendChild(logo);
header.appendChild(title);
// Add the task and time details
const taskDetails = document.createElement("div");
taskDetails.innerHTML = `
<p style="margin: 10px 0; font-size: 18px;">You have a Reminder:</p>
<p style="margin: 10px 0; font-size: 16px; color: #f0f0f0; line-height: 1.6;"><strong style = "color: #8a2be2; text-align: left">Task:</strong> ${task}</p>
<p style="margin: 5px 0; font-size: 16px; color: #f0f0f0; line-height: 1.6;"><strong style = "color: #8a2be2;">Time:</strong> ${time}</p>
`;
// Add a close button
const closeButton = document.createElement("button");
closeButton.innerText = "Close";
closeButton.style.cssText = `
margin-top: 20px;
background-color: #7A1CAC;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
`;
closeButton.addEventListener("mouseover", () => {
closeButton.style.backgroundColor = "#661891";
});
closeButton.addEventListener("mouseout", () => {
closeButton.style.backgroundColor = "#7A1CAC";
});
closeButton.addEventListener("click", () => {
modal.remove();
});
// Append elements to modal content
modalContent.appendChild(header);
modalContent.appendChild(taskDetails);
modalContent.appendChild(closeButton);
// Append modal content to modal container
modal.appendChild(modalContent);
// Append modal to body
document.body.appendChild(modal);
}
});