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
+14 -1
View File
@@ -1,5 +1,6 @@
import { BackgroundMessageType, sendBackgroundMessage } from '@/lib/communication';
import { getHost, HostMatchType, hosts, type HostMatch } from '@/lib/host';
import { FF2MPVSettings } from '@/lib/settings';
import { FF2MPVSettings, PerDomainSettings } from '@/lib/settings';
export default defineContentScript({
matches: [
@@ -16,6 +17,18 @@ async function main() {
const host = await getHost(window.location.host);
if (!host) return;
// if current windows is an iframe, check if the parent has any disabled hosts
if (window !== window.top) {
const tabUrl = await sendBackgroundMessage(BackgroundMessageType.RequestTabUrl, undefined);
if (tabUrl) {
const domain = new URL(tabUrl).host;
const perDomainSetting = await PerDomainSettings.get(domain);
if (perDomainSetting.allDisabled) return;
else if (perDomainSetting.disabledHostIds.indexOf(host.id) !== -1) return;
}
}
let re = null;
for (const regex of host.regex) {
if ((re = document.body.innerHTML.match(regex)) !== null) {