fix per domain disable not working if host is in iframe

This commit is contained in:
2026-07-07 13:26:33 +02:00
parent c09cf1188d
commit e437d5436a
6 changed files with 82 additions and 40 deletions
+9 -18
View File
@@ -8,7 +8,7 @@
import CurrentSite from '@/entrypoints/popup/pages/main/CurrentSite.svelte';
import Header from '@/entrypoints/popup/pages/main/Header.svelte';
import Match from '@/entrypoints/popup/pages/main/Match.svelte';
import { listenMessages, MessageType, sendMessageToActiveTab } from '@/lib/communication';
import { listenTabMessages, sendTabMessageToActiveTab, TabMessageType } from '@/lib/communication';
import { hosts, type Host } from '@/lib/host';
import { HostSettings } from '@/lib/settings';
@@ -27,31 +27,22 @@
HostSettings.getAllHostsDisabled().then((val) => (allHostsDisabled = val));
/* lifecycle */
const cancel = listenMessages((type, data) => {
if (type !== MessageType.NotifyActiveMatch) return;
const cancel = listenTabMessages((type, data) => {
if (type !== TabMessageType.NotifyActiveMatch) return;
const match = {
host: hosts.find((host) => host.id === data.id)!,
url: data.url,
domain: data.domain
};
currentMatch = match;
currentDomain = match.domain;
});
sendMessageToActiveTab(MessageType.RequestActiveMatch, undefined);
sendTabMessageToActiveTab(TabMessageType.RequestActiveMatch, undefined);
browser.tabs
.query({ active: true, currentWindow: true })
.then((tabs) => {
if (currentDomain) return;
const url = tabs[0]?.url;
if (!url) return;
try {
currentDomain = new URL(url).hostname;
} catch {
/* ignore */
}
})
.catch(() => {});
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
const url = tabs[0]?.url;
if (!url) return;
currentDomain = new URL(url).hostname;
});
onDestroy(cancel);
</script>
@@ -3,7 +3,7 @@
import Divider from '@/entrypoints/popup/components/Divider.svelte';
import Header from '@/entrypoints/popup/pages/site-config/Header.svelte';
import PerSiteHostsList from '@/entrypoints/popup/pages/site-config/PerSiteHostsList.svelte';
import { listenMessages, MessageType, sendMessageToActiveTab } from '@/lib/communication';
import { listenTabMessages, sendTabMessageToActiveTab, TabMessageType } from '@/lib/communication';
import { hosts, type Host } from '@/lib/host';
/* types */
@@ -18,8 +18,8 @@
let currentDomain = $state<string | null>(null);
/* lifecycle */
const cancel = listenMessages((type, data) => {
if (type !== MessageType.NotifyActiveMatch) return;
const cancel = listenTabMessages((type, data) => {
if (type !== TabMessageType.NotifyActiveMatch) return;
const match = {
host: hosts.find((host) => host.id === data.id)!,
url: data.url,
@@ -28,7 +28,7 @@
currentMatch = match;
currentDomain = match.domain;
});
sendMessageToActiveTab(MessageType.RequestActiveMatch, undefined);
sendTabMessageToActiveTab(TabMessageType.RequestActiveMatch, undefined);
browser.tabs
.query({ active: true, currentWindow: true })