PhishGuardian/extension/notification.js

48 lines
2.0 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
const markSafeButton = document.getElementById('mark-safe');
const moveTrashButton = document.getElementById('move-trash');
const closeButton = document.getElementById('close');
const notificationMessage = document.getElementById('notification-message');
chrome.storage.local.get(['notificationTitle', 'notificationMessage', 'emailId'], function(items) {
notificationMessage.textContent = items.notificationMessage;
if (items.emailId) {
// Show action buttons if there's a phishing email
markSafeButton.style.display = 'inline-block';
moveTrashButton.style.display = 'inline-block';
} else {
// Hide action buttons if no phishing emails
markSafeButton.style.display = 'none';
moveTrashButton.style.display = 'none';
}
markSafeButton.addEventListener('click', function() {
console.log('Mark Safe button clicked for emailId:', items.emailId);
chrome.runtime.sendMessage({
type: 'mark-safe',
emailId: items.emailId
}, function(response) {
console.log('Mark safe response:', response);
});
setTimeout(() => window.close(), 50); // Wait for 50ms before closing the window
});
moveTrashButton.addEventListener('click', function() {
console.log('Move to Trash button clicked for emailId:', items.emailId);
chrome.runtime.sendMessage({
type: 'move-trash',
emailId: items.emailId
}, function(response) {
console.log('Move to trash response:', response);
});
setTimeout(() => window.close(), 50); // Wait for 50ms before closing the window
});
closeButton.addEventListener('click', function() {
console.log('Close button clicked');
window.close();
});
});
});