Show notifications always on the top window (#2789)

This commit is contained in:
Sami Vänttinen 2025-12-12 16:41:48 +02:00 committed by GitHub
parent abba71e419
commit f3e0111acc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -939,9 +939,14 @@ browser.runtime.onMessage.addListener(async function(req, sender) {
kpxcFill.fillAttributeToActiveElementWith(req.args);
} else if (req.action === 'frame_message') {
if (req.args?.[0] === 'frame_request_to_frames' && window.self !== window.top) {
// Handle message from top window in iframe
kpxcCustomLoginFieldsBanner.handleParentWindowMessage(req.args);
} else if (req.args?.[0] === 'frame_request_to_parent' && window.self === window.top) {
// Handle message from iframe in top window
kpxcCustomLoginFieldsBanner.handleTopWindowMessage(req.args);
} else if (req.args?.[0] === 'notification_from_frame' && window.self === window.top) {
// Handle notification from iframe in top window
kpxcUI.createNotification(req?.args[1], req?.args[2]);
}
} else if (req.action === 'ignore_site') {
kpxc.ignoreSite(req.args);

View file

@ -330,11 +330,17 @@ kpxcUI.updateFromIntersectionObserver = function(iconClass, entries) {
* @param {string} type Notification type: (success, info, warning, error)
* @param {string} message The message shown
*/
kpxcUI.createNotification = function(type, message) {
kpxcUI.createNotification = async function(type, message) {
if (!kpxc.settings.showNotifications || !type || !message) {
return;
}
// Send the notification to top window from iframe
if (window.self !== window.top) {
await sendMessage('frame_message', [ 'notification_from_frame', type, message ]);
return;
}
// Removes notification from the body element
const removeNotification = function() {
// Catch cross-domain exception