From 1d6ace3b260680ba3928b3ba8fa26f48114d7aa8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:49:59 +0000 Subject: [PATCH 1/2] Initial plan From aefd8aca41d867dfdbfbf46561b133bf5f68addb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 29 Nov 2025 09:54:08 +0000 Subject: [PATCH 2/2] Fix extension working on localhost when disabled Add check for localhost URLs in isEnabled() function to respect the enableOnLocalhost setting. When on localhost (127.0.0.1, localhost, [::1], or *.localhost) and enableOnLocalhost is disabled (default), the extension will not process the page or add data-ds-ready attribute. Co-authored-by: clemenzi <77632836+clemenzi@users.noreply.github.com> --- src/lib/utils.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index e1ea43d..947e976 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,4 +1,5 @@ -import { Filter } from "@/types"; +import { defaultSettings } from "@/const"; +import { Filter, Settings } from "@/types"; import { type ClassValue, clsx } from "clsx"; import { isMatch } from "matcher"; import { twMerge } from "tailwind-merge"; @@ -21,6 +22,15 @@ export const textReplacement = ( return text; }; +export const isLocalhost = (hostname: string): boolean => { + return ( + hostname === "localhost" || + hostname === "127.0.0.1" || + hostname === "[::1]" || + hostname.endsWith(".localhost") + ); +}; + export const isEnabled = async (): Promise => { let res = true; @@ -33,6 +43,15 @@ export const isEnabled = async (): Promise => { res = false; } + // Check if localhost and if localhost is enabled + if (isLocalhost(url.hostname)) { + const settings = await storage.getItem("local:settings"); + const enableOnLocalhost = settings?.enableOnLocalhost ?? defaultSettings.enableOnLocalhost; + if (!enableOnLocalhost) { + res = false; + } + } + return res; };