From e2a168b18893007d071bcfc5085c36724da13fd4 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Mon, 28 Jul 2025 02:16:48 +0400 Subject: [PATCH] refactor: use shared camoufox config form --- src/components/camoufox-config-dialog.tsx | 407 +--------------------- 1 file changed, 17 insertions(+), 390 deletions(-) diff --git a/src/components/camoufox-config-dialog.tsx b/src/components/camoufox-config-dialog.tsx index 78d99b5..e4b9d24 100644 --- a/src/components/camoufox-config-dialog.tsx +++ b/src/components/camoufox-config-dialog.tsx @@ -1,8 +1,8 @@ "use client"; import { useEffect, useState } from "react"; +import { SharedCamoufoxConfigForm } from "@/components/shared-camoufox-config-form"; import { Button } from "@/components/ui/button"; -import { Checkbox } from "@/components/ui/checkbox"; import { Dialog, DialogContent, @@ -10,16 +10,8 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; import { ScrollArea } from "@/components/ui/scroll-area"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; +import { getCurrentOS } from "@/lib/browser-utils"; import type { BrowserProfile, CamoufoxConfig } from "@/types"; interface CamoufoxConfigDialogProps { @@ -29,43 +21,6 @@ interface CamoufoxConfigDialogProps { onSave: (profile: BrowserProfile, config: CamoufoxConfig) => Promise; } -const osOptions = [ - { value: "windows", label: "Windows" }, - { value: "macos", label: "macOS" }, - { value: "linux", label: "Linux" }, -]; - -const timezoneOptions = [ - { value: "America/New_York", label: "America/New_York" }, - { value: "America/Los_Angeles", label: "America/Los_Angeles" }, - { value: "Europe/London", label: "Europe/London" }, - { value: "Europe/Paris", label: "Europe/Paris" }, - { value: "Asia/Tokyo", label: "Asia/Tokyo" }, - { value: "Asia/Shanghai", label: "Asia/Shanghai" }, - { value: "Australia/Sydney", label: "Australia/Sydney" }, -]; - -const localeOptions = [ - { value: "en-US", label: "English (US)" }, - { value: "en-GB", label: "English (UK)" }, - { value: "fr-FR", label: "French" }, - { value: "de-DE", label: "German" }, - { value: "es-ES", label: "Spanish" }, - { value: "it-IT", label: "Italian" }, - { value: "ja-JP", label: "Japanese" }, - { value: "zh-CN", label: "Chinese (Simplified)" }, -]; - -const getCurrentOS = () => { - if (typeof window !== "undefined") { - const userAgent = window.navigator.userAgent; - if (userAgent.includes("Win")) return "windows"; - if (userAgent.includes("Mac")) return "macos"; - if (userAgent.includes("Linux")) return "linux"; - } - return "unknown"; -}; - export function CamoufoxConfigDialog({ isOpen, onClose, @@ -141,350 +96,22 @@ export function CamoufoxConfigDialog({ -
- {/* Operating System */} -
- - - {showOSWarning && ( -
-

- ⚠️ Warning: Spoofing OS features is detectable by advanced - anti-bot systems. Some platform-specific APIs and behaviors - cannot be fully replicated. -

-
- )} -
+
+ {/* OS Warning */} + {showOSWarning && ( +
+

+ ⚠️ Warning: Spoofing OS features is detectable by advanced + anti-bot systems. Some platform-specific APIs and behaviors + cannot be fully replicated. +

+
+ )} - {/* Blocking Options */} -
- -
-
- - updateConfig("block_images", checked) - } - /> - -
-
- - updateConfig("block_webrtc", checked) - } - /> - -
-
- - updateConfig("block_webgl", checked) - } - /> - -
-
-
- - {/* Geolocation */} -
- -
-
- - - updateConfig("country", e.target.value || undefined) - } - placeholder="e.g., US, GB, DE" - /> -
-
- - -
-
-
-
- - - updateConfig( - "latitude", - e.target.value ? parseFloat(e.target.value) : undefined, - ) - } - placeholder="e.g., 40.7128" - /> -
-
- - - updateConfig( - "longitude", - e.target.value ? parseFloat(e.target.value) : undefined, - ) - } - placeholder="e.g., -74.0060" - /> -
-
-
- - {/* Localization */} -
- - -
- - {/* Screen Resolution */} -
- -
-
- - - updateConfig( - "screen_min_width", - e.target.value ? parseInt(e.target.value) : undefined, - ) - } - placeholder="e.g., 1024" - /> -
-
- - - updateConfig( - "screen_max_width", - e.target.value ? parseInt(e.target.value) : undefined, - ) - } - placeholder="e.g., 1920" - /> -
-
-
-
- - - updateConfig( - "screen_min_height", - e.target.value ? parseInt(e.target.value) : undefined, - ) - } - placeholder="e.g., 768" - /> -
-
- - - updateConfig( - "screen_max_height", - e.target.value ? parseInt(e.target.value) : undefined, - ) - } - placeholder="e.g., 1080" - /> -
-
-
- - {/* Window Size */} -
- -
-
- - - updateConfig( - "window_width", - e.target.value ? parseInt(e.target.value) : undefined, - ) - } - placeholder="e.g., 1366" - /> -
-
- - - updateConfig( - "window_height", - e.target.value ? parseInt(e.target.value) : undefined, - ) - } - placeholder="e.g., 768" - /> -
-
-
- - {/* Advanced Options */} -
- -
-
- - updateConfig("enable_cache", checked) - } - /> - -
-
- - updateConfig("main_world_eval", checked) - } - /> - -
-
-
- - {/* WebGL Settings */} -
- -
-
- - - updateConfig("webgl_vendor", e.target.value || undefined) - } - placeholder="e.g., Intel Inc." - /> -
-
- - - updateConfig( - "webgl_renderer", - e.target.value || undefined, - ) - } - placeholder="e.g., Intel Iris OpenGL Engine" - /> -
-
-
- - {/* Debug Options */} -
- -
- updateConfig("debug", checked)} - /> - -
-
+