diff --git a/Makefile b/Makefile index 663c442..b57a3f1 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,7 @@ package-linux: python3 scripts/package.py linux \ --includes \ settings/chrome.css \ + settings/properties.json \ bundle/fontconfigs \ --version $(version) \ --release $(release) \ @@ -120,6 +121,7 @@ package-macos: python3 scripts/package.py macos \ --includes \ settings/chrome.css \ + settings/properties.json \ --version $(version) \ --release $(release) \ --arch $(arch) \ @@ -130,6 +132,7 @@ package-windows: python3 scripts/package.py windows \ --includes \ settings/chrome.css \ + settings/properties.json \ ~/.mozbuild/vs/VC/Redist/MSVC/14.38.33135/$(vcredist_arch)/Microsoft.VC143.CRT/*.dll \ --version $(version) \ --release $(release) \ diff --git a/README.md b/README.md index 90ab86a..3a5aa2d 100644 --- a/README.md +++ b/README.md @@ -151,13 +151,17 @@ Screen | screen.availWidth | ✅ | | screen.availTop | ✅ | | screen.availLeft | ✅ | -| screen.colorDepth | ✅ | | screen.height | ✅ | | screen.width | ✅ | +| screen.colorDepth | ✅ | | screen.pixelDepth | ✅ | | screen.pageXOffset | ✅ | | screen.pageYOffset | ✅ | +**Notes:** + +- `screen.colorDepth` and `screen.pixelDepth` are synonymous. +
@@ -165,20 +169,20 @@ Screen Window -| Property | Status | -| ----------------------- | --------------------------- | -| window.scrollMinX | ✅ | -| window.scrollMinY | ✅ | -| window.scrollMaxX | ✅ | -| window.scrollMaxY | ✅ | -| window.innerHeight | ✅ | -| window.outerHeight | ✅ | -| window.outerWidth | ✅ | -| window.innerWidth | ✅ | -| window.screenX | ✅ | -| window.screenY | ✅ | -| window.history.length | ✅ | -| window.devicePixelRatio | Works, but not recommended! | +| Property | Status | Notes | +| ----------------------- | ------ | ------------------------------- | +| window.scrollMinX | ✅ | +| window.scrollMinY | ✅ | +| window.scrollMaxX | ✅ | +| window.scrollMaxY | ✅ | +| window.outerHeight | ✅ | Sets the window height. | +| window.outerWidth | ✅ | Sets the window width. | +| window.innerHeight | ✅ | Sets the inner viewport height. | +| window.innerWidth | ✅ | Sets the inner viewport width. | +| window.screenX | ✅ | +| window.screenY | ✅ | +| window.history.length | ✅ | +| window.devicePixelRatio | ✅ | Works, but not recommended. | **Notes:** @@ -269,7 +273,7 @@ You can also exclude default addons with the `--exclude-addons` flag: Miscellaneous (WebGl spoofing, battery status, etc) -| Property | Status | Notes | +| Property | Status | Description | | ----------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | | pdfViewer | ✅ | Sets navigator.pdfViewerEnabled. Please keep this on though, many websites will flag a lack of pdfViewer as a headless browser. | | webGl:renderer | ✅ | Spoofs the name of the unmasked WebGL renderer. Can cause leaks, use at your own caution! Also note, webGl is disabled in Camoufox by default. | diff --git a/launcher/main.go b/launcher/main.go index 745461b..8b34fd4 100644 --- a/launcher/main.go +++ b/launcher/main.go @@ -24,6 +24,7 @@ func main() { // Read and parse the config file var configMap map[string]interface{} parseJson(configPath, &configMap) + validateConfig(configMap) //*** PARSE ADDONS ***// @@ -199,7 +200,7 @@ func setEnvironmentVariables(configMap map[string]interface{}, userAgentOS strin } if normalizeOS(runtime.GOOS) == "linux" { - fontconfigPath := filepath.Join("fontconfig", userAgentOS) + fontconfigPath := getPath(filepath.Join("fontconfig", userAgentOS)) os.Setenv("FONTCONFIG_PATH", fontconfigPath) } } diff --git a/launcher/validate.go b/launcher/validate.go new file mode 100644 index 0000000..9fca2a2 --- /dev/null +++ b/launcher/validate.go @@ -0,0 +1,67 @@ +package main + +import ( + "fmt" + "math" + "os" + "reflect" +) + +type Property struct { + Property string `json:"property"` + Type string `json:"type"` +} + +func validateConfig(configMap map[string]interface{}) { + properties := loadProperties() + + // Create a map for quick lookup of property types + propertyTypes := make(map[string]string) + for _, prop := range properties { + propertyTypes[prop.Property] = prop.Type + } + + for key, value := range configMap { + expectedType, exists := propertyTypes[key] + if !exists { + fmt.Printf("Warning: Unknown property %s in config\n", key) + continue + } + + if !validateType(value, expectedType) { + fmt.Printf("Invalid type for property %s. Expected %s, got %T\n", key, expectedType, value) + os.Exit(1) + } + } +} + +func loadProperties() []Property { + propertiesPath := getPath("properties.json") + var properties []Property + parseJson(propertiesPath, &properties) + return properties +} + +func validateType(value interface{}, expectedType string) bool { + switch expectedType { + case "str": + _, ok := value.(string) + return ok + case "int": + v, ok := value.(float64) + return ok && v == math.Trunc(v) + case "uint": + v, ok := value.(float64) + return ok && v == math.Trunc(v) && v >= 0 + case "double": + _, ok := value.(float64) + return ok + case "bool": + _, ok := value.(bool) + return ok + case "array": + return reflect.TypeOf(value).Kind() == reflect.Slice + default: + return false + } +} diff --git a/patches/xmas-modified.patch b/patches/xmas-modified.patch index 14669f2..72565f7 100644 --- a/patches/xmas-modified.patch +++ b/patches/xmas-modified.patch @@ -18,10 +18,11 @@ diff --git a/lw/moz.build b/lw/moz.build index e69de29bb2..208184547e 100644 --- a/lw/moz.build +++ b/lw/moz.build -@@ -0,0 +1,13 @@ +@@ -0,0 +1,14 @@ +FINAL_TARGET_FILES += [ + "camoufox.cfg", + "chrome.css", ++ "properties.json" +] + +FINAL_TARGET_FILES.distribution += [ diff --git a/scripts/copy-additions.sh b/scripts/copy-additions.sh index 5d03bd7..aafc19f 100644 --- a/scripts/copy-additions.sh +++ b/scripts/copy-additions.sh @@ -36,6 +36,7 @@ run 'cp -v ../../settings/camoufox.cfg .' run 'cp -v ../../settings/distribution/policies.json .' run 'cp -v ../../settings/defaults/pref/local-settings.js .' run 'cp -v ../../settings/chrome.css .' +run 'cp -v ../../settings/properties.json .' run 'touch moz.build' popd > /dev/null diff --git a/settings/properties.json b/settings/properties.json new file mode 100644 index 0000000..705658c --- /dev/null +++ b/settings/properties.json @@ -0,0 +1,58 @@ +[ + { "property": "navigator.userAgent", "type": "str" }, + { "property": "navigator.doNotTrack", "type": "str" }, + { "property": "navigator.appCodeName", "type": "str" }, + { "property": "navigator.appName", "type": "str" }, + { "property": "navigator.appVersion", "type": "str" }, + { "property": "navigator.oscpu", "type": "str" }, + { "property": "navigator.language", "type": "str" }, + { "property": "navigator.languages", "type": "array" }, + { "property": "navigator.platform", "type": "str" }, + { "property": "navigator.hardwareConcurrency", "type": "uint" }, + { "property": "navigator.product", "type": "str" }, + { "property": "navigator.productSub", "type": "str" }, + { "property": "navigator.maxTouchPoints", "type": "uint" }, + { "property": "navigator.cookieEnabled", "type": "bool" }, + { "property": "navigator.globalPrivacyControl", "type": "bool" }, + { "property": "navigator.buildID", "type": "str" }, + { "property": "navigator.onLine", "type": "bool" }, + { "property": "screen.availHeight", "type": "uint" }, + { "property": "screen.availWidth", "type": "uint" }, + { "property": "screen.availTop", "type": "uint" }, + { "property": "screen.availLeft", "type": "uint" }, + { "property": "screen.height", "type": "uint" }, + { "property": "screen.width", "type": "uint" }, + { "property": "screen.colorDepth", "type": "uint" }, + { "property": "screen.pixelDepth", "type": "uint" }, + { "property": "screen.pageXOffset", "type": "double" }, + { "property": "screen.pageYOffset", "type": "double" }, + { "property": "window.scrollMinX", "type": "int" }, + { "property": "window.scrollMinY", "type": "int" }, + { "property": "window.scrollMaxX", "type": "int" }, + { "property": "window.scrollMaxY", "type": "int" }, + { "property": "window.outerHeight", "type": "uint" }, + { "property": "window.outerWidth", "type": "uint" }, + { "property": "window.innerHeight", "type": "uint" }, + { "property": "window.innerWidth", "type": "uint" }, + { "property": "window.screenX", "type": "int" }, + { "property": "window.screenY", "type": "int" }, + { "property": "window.history.length", "type": "uint" }, + { "property": "window.devicePixelRatio", "type": "double" }, + { "property": "document.body.clientWidth", "type": "uint" }, + { "property": "document.body.clientHeight", "type": "uint" }, + { "property": "document.body.clientTop", "type": "uint" }, + { "property": "document.body.clientLeft", "type": "uint" }, + { "property": "headers.User-Agent", "type": "str" }, + { "property": "headers.Accept-Language", "type": "str" }, + { "property": "headers.Accept-Encoding", "type": "str" }, + { "property": "webrtc:ipv4", "type": "str" }, + { "property": "webrtc:ipv6", "type": "str" }, + { "property": "pdfViewerEnabled", "type": "bool" }, + { "property": "webGl:renderer", "type": "str" }, + { "property": "webGl:vendor", "type": "str" }, + { "property": "battery:charging", "type": "bool" }, + { "property": "battery:chargingTime", "type": "double" }, + { "property": "battery:dischargingTime", "type": "double" }, + { "property": "battery:level", "type": "double" }, + { "property": "fonts", "type": "array" } +]