From da0af075fc164b9135eb8ca931300ed1d3de1f0f Mon Sep 17 00:00:00 2001
From: zhom <2717306+zhom@users.noreply.github.com>
Date: Mon, 4 Aug 2025 07:14:23 +0400
Subject: [PATCH] feat: automatically set max user screen height and width
during profile creation
---
src/components/create-profile-dialog.tsx | 1 +
.../shared-camoufox-config-form.tsx | 30 +++++++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/components/create-profile-dialog.tsx b/src/components/create-profile-dialog.tsx
index d325d8f..04f82ac 100644
--- a/src/components/create-profile-dialog.tsx
+++ b/src/components/create-profile-dialog.tsx
@@ -532,6 +532,7 @@ export function CreateProfileDialog({
diff --git a/src/components/shared-camoufox-config-form.tsx b/src/components/shared-camoufox-config-form.tsx
index 99e70be..17b7563 100644
--- a/src/components/shared-camoufox-config-form.tsx
+++ b/src/components/shared-camoufox-config-form.tsx
@@ -168,12 +168,14 @@ interface SharedCamoufoxConfigFormProps {
config: CamoufoxConfig;
onConfigChange: (key: keyof CamoufoxConfig, value: unknown) => void;
className?: string;
+ isCreating?: boolean; // Flag to indicate if this is for creating a new profile
}
export function SharedCamoufoxConfigForm({
config,
onConfigChange,
className = "",
+ isCreating = false,
}: SharedCamoufoxConfigFormProps) {
const [systemLocale, setSystemLocale] = useState(null);
const [systemTimezone, setSystemTimezone] = useState(
@@ -208,8 +210,30 @@ export function SharedCamoufoxConfigForm({
}
};
+ // Set screen resolution to user's screen size when creating a new profile
+ const setScreenDefaults = () => {
+ if (isCreating && typeof window !== "undefined") {
+ const screenWidth = window.screen.width;
+ const screenHeight = window.screen.height;
+
+ // Only set if not already configured
+ if (!config.screen_max_width) {
+ onConfigChange("screen_max_width", screenWidth);
+ }
+ if (!config.screen_max_height) {
+ onConfigChange("screen_max_height", screenHeight);
+ }
+ }
+ };
+
loadSystemDefaults();
- }, []);
+ setScreenDefaults();
+ }, [
+ isCreating,
+ config.screen_max_width,
+ config.screen_max_height,
+ onConfigChange,
+ ]);
// Determine if automatic location configuration is enabled
// Default to true if geoip is not explicitly set to false
@@ -414,7 +438,9 @@ export function SharedCamoufoxConfigForm({
{/* Screen Resolution */}
-
+
+
+