@@ -49,7 +49,10 @@ function showNotification(title, message) {
4949 message : message || "No Contest Available"
5050 } ;
5151
52- chrome . notifications . create ( "" , options ) ;
52+ // chrome.notifications.create("", options);
53+ // Generate a unique notification ID
54+ const notificationId = `cracktech_notification_${ Date . now ( ) } ` ;
55+ chrome . notifications . create ( notificationId , options ) ;
5356}
5457
5558// Helper function to convert epoch to date string
@@ -144,3 +147,22 @@ chrome.alarms.onAlarm.addListener(function (alarm) {
144147function scheduleSecondNotification ( ) {
145148 chrome . alarms . create ( "secondNotificationAlarm" , { delayInMinutes : 18 } ) ;
146149}
150+
151+ // Function to show the popup with notification ID
152+ function showPopup ( notificationId ) {
153+ const popupUrl = chrome . runtime . getURL ( `content.html?id=${ notificationId } ` ) ;
154+ chrome . windows . create ( { url : popupUrl , type : "popup" , width : 400 , height : 200 } ) ;
155+ }
156+
157+ // Event listener for notification click
158+ chrome . notifications . onClicked . addListener ( function ( notificationId ) {
159+ // Perform actions based on the clicked notification
160+ if ( notificationId . startsWith ( "cracktech_notification_" ) ) {
161+ // Extract the associated notification ID
162+ const notificationIdNumber = Number ( notificationId . split ( "_" ) [ 2 ] ) ;
163+
164+ // Perform actions based on the notification ID
165+ // For example, show a popup with the notification details
166+ showPopup ( notificationIdNumber ) ;
167+ }
168+ } ) ;
0 commit comments