Show notifications always on the top window

This commit is contained in:
varjolintu 2025-12-04 21:08:01 +02:00
parent fdbd077852
commit 54aa5291d4
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