From 711b5b45500fff5ca1da62347e9f71e6b797f655 Mon Sep 17 00:00:00 2001 From: daijro Date: Sat, 19 Oct 2024 23:17:47 -0500 Subject: [PATCH] Backwards compatibility with <0.3.0 Change ALL webgl keys to webGl. This keeps backwards compatibility with <0.3.0 versions of the Python library. --- README.md | 28 ++++++++++++++-------------- additions/camoucfg/MaskConfig.hpp | 12 ++++++------ patches/webgl-spoofing.patch | 22 +++++++++++----------- settings/properties.json | 28 ++++++++++++++-------------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 9d013fd..9ad16df 100644 --- a/README.md +++ b/README.md @@ -361,20 +361,20 @@ Camoufox supports spoofing WebGL parameters, supported extensions, context attri | Property | Description | Example | | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | -| webgl:renderer | Spoofs the name of the unmasked WebGL renderer. | `"NVIDIA GeForce GTX 980, or similar"` | -| webgl:vendor | Spoofs the name of the unmasked WebGL vendor. | `"NVIDIA Corporation"` | -| webgl:supportedExtensions | An array of supported WebGL extensions ([full list](https://registry.khronos.org/webgl/extensions/)). | `["ANGLE_instanced_arrays", "EXT_color_buffer_float", "EXT_disjoint_timer_query", ...]` | -| webgl2:supportedExtensions | The same as `webgl:supportedExtensions`, but for WebGL2. | `["ANGLE_instanced_arrays", "EXT_color_buffer_float", "EXT_disjoint_timer_query", ...]` | -| webgl:contextAttributes | A dictionary of WebGL context attributes. | `{"alpha": true, "antialias": true, "depth": true, ...}` | -| webgl2:contextAttributes | The same as `webgl:contextAttributes`, but for WebGL2. | `{"alpha": true, "antialias": true, "depth": true, ...}` | -| webgl:parameters | A dictionary of WebGL parameters. Keys must be GL enums, and values are the values to spoof them as. | `{"2849": 1, "2884": false, "2928": [0, 1], ...}` | -| webgl2:parameters | The same as `webgl:parameters`, but for WebGL2. | `{"2849": 1, "2884": false, "2928": [0, 1], ...}` | -| webgl:parameters:blockIfNotDefined | If set to `true`, only the parameters in `webgl:parameters` will be allowed. Can be dangerous if not used correctly. | `true`/`false` | -| webgl2:parameters:blockIfNotDefined | If set to `true`, only the parameters in `webgl2:parameters` will be allowed. Can be dangerous if not used correctly. | `true`/`false` | -| webgl:shaderPrecisionFormats | A dictionary of WebGL shader precision formats. Keys are formatted as `","`. | `{"35633,36336": {"rangeMin": 127, "rangeMax": 127, "precision": 23}, ...}` | -| webgl2:shaderPrecisionFormats | The same as `webGL:shaderPrecisionFormats`, but for WebGL2. | `{"35633,36336": {"rangeMin": 127, "rangeMax": 127, "precision": 23}, ...}` | -| webgl:shaderPrecisionFormats:blockIfNotDefined | If set to `true`, only the shader percisions in `webgl:shaderPrecisionFormats` will be allowed. | `true`/`false` | -| webgl2:shaderPrecisionFormats:blockIfNotDefined | If set to `true`, only the shader percisions in `webgl2:shaderPrecisionFormats` will be allowed. | `true`/`false` | +| webGl:renderer | Spoofs the name of the unmasked WebGL renderer. | `"NVIDIA GeForce GTX 980, or similar"` | +| webGl:vendor | Spoofs the name of the unmasked WebGL vendor. | `"NVIDIA Corporation"` | +| webGl:supportedExtensions | An array of supported WebGL extensions ([full list](https://registry.khronos.org/webgl/extensions/)). | `["ANGLE_instanced_arrays", "EXT_color_buffer_float", "EXT_disjoint_timer_query", ...]` | +| webGl2:supportedExtensions | The same as `webGl:supportedExtensions`, but for WebGL2. | `["ANGLE_instanced_arrays", "EXT_color_buffer_float", "EXT_disjoint_timer_query", ...]` | +| webGl:contextAttributes | A dictionary of WebGL context attributes. | `{"alpha": true, "antialias": true, "depth": true, ...}` | +| webGl2:contextAttributes | The same as `webGl:contextAttributes`, but for WebGL2. | `{"alpha": true, "antialias": true, "depth": true, ...}` | +| webGl:parameters | A dictionary of WebGL parameters. Keys must be GL enums, and values are the values to spoof them as. | `{"2849": 1, "2884": false, "2928": [0, 1], ...}` | +| webGl2:parameters | The same as `webGl:parameters`, but for WebGL2. | `{"2849": 1, "2884": false, "2928": [0, 1], ...}` | +| webGl:parameters:blockIfNotDefined | If set to `true`, only the parameters in `webGl:parameters` will be allowed. Can be dangerous if not used correctly. | `true`/`false` | +| webGl2:parameters:blockIfNotDefined | If set to `true`, only the parameters in `webGl2:parameters` will be allowed. Can be dangerous if not used correctly. | `true`/`false` | +| webGl:shaderPrecisionFormats | A dictionary of WebGL shader precision formats. Keys are formatted as `","`. | `{"35633,36336": {"rangeMin": 127, "rangeMax": 127, "precision": 23}, ...}` | +| webGl2:shaderPrecisionFormats | The same as `webGL:shaderPrecisionFormats`, but for WebGL2. | `{"35633,36336": {"rangeMin": 127, "rangeMax": 127, "precision": 23}, ...}` | +| webGl:shaderPrecisionFormats:blockIfNotDefined | If set to `true`, only the shader percisions in `webGl:shaderPrecisionFormats` will be allowed. | `true`/`false` | +| webGl2:shaderPrecisionFormats:blockIfNotDefined | If set to `true`, only the shader percisions in `webGl2:shaderPrecisionFormats` will be allowed. | `true`/`false` | diff --git a/additions/camoucfg/MaskConfig.hpp b/additions/camoucfg/MaskConfig.hpp index ba240c1..0e012f0 100644 --- a/additions/camoucfg/MaskConfig.hpp +++ b/additions/camoucfg/MaskConfig.hpp @@ -212,7 +212,7 @@ inline std::optional GetNested(const std::string& domain, template inline std::optional GetAttribute(const std::string attrib, bool isWebGL2) { auto value = MaskConfig::GetNested( - isWebGL2 ? "webgl2:contextAttributes" : "webgl:contextAttributes", + isWebGL2 ? "webGl2:contextAttributes" : "webGl:contextAttributes", attrib); if (!value) return std::nullopt; return value.value().get(); @@ -222,7 +222,7 @@ inline std::optional< std::variant> GLParam(uint32_t pname, bool isWebGL2) { auto value = - MaskConfig::GetNested(isWebGL2 ? "webgl2:parameters" : "webgl:parameters", + MaskConfig::GetNested(isWebGL2 ? "webGl2:parameters" : "webGl:parameters", std::to_string(pname)); if (!value) return std::nullopt; auto data = value.value(); @@ -237,7 +237,7 @@ GLParam(uint32_t pname, bool isWebGL2) { template inline T MParamGL(uint32_t pname, T defaultValue, bool isWebGL2) { if (auto value = MaskConfig::GetNested( - isWebGL2 ? "webgl2:parameters" : "webgl:parameters", + isWebGL2 ? "webGl2:parameters" : "webGl:parameters", std::to_string(pname)); value.has_value()) { return value.value().get(); @@ -250,7 +250,7 @@ inline std::vector MParamGLVector(uint32_t pname, std::vector defaultValue, bool isWebGL2) { if (auto value = MaskConfig::GetNested( - isWebGL2 ? "webgl2:parameters" : "webgl:parameters", + isWebGL2 ? "webGl2:parameters" : "webGl:parameters", std::to_string(pname)); value.has_value()) { if (value.value().is_array()) { @@ -266,8 +266,8 @@ inline std::optional> MShaderData( std::string valueName = std::to_string(shaderType) + "," + std::to_string(precisionType); if (auto value = - MaskConfig::GetNested(isWebGL2 ? "webgl2:shaderPrecisionFormats" - : "webgl:shaderPrecisionFormats", + MaskConfig::GetNested(isWebGL2 ? "webGl2:shaderPrecisionFormats" + : "webGl:shaderPrecisionFormats", valueName)) { // Convert {rangeMin: int, rangeMax: int, precision: int} to array auto data = value.value(); diff --git a/patches/webgl-spoofing.patch b/patches/webgl-spoofing.patch index 91af780..cd5e3af 100644 --- a/patches/webgl-spoofing.patch +++ b/patches/webgl-spoofing.patch @@ -43,7 +43,7 @@ index db60868f65..7361f0fc9c 100644 + result.mStencil = MBoolVal("stencil", options.stencil); + result.mAntialias.Construct(MBoolVal("antialias", options.antialias)); + result.mPremultipliedAlpha = MBoolVal( -+ "webgl:contextAttributes.premultipliedAlpha", options.premultipliedAlpha); ++ "webGl:contextAttributes.premultipliedAlpha", options.premultipliedAlpha); + result.mPreserveDrawingBuffer = + MBoolVal("preserveDrawingBuffer", options.preserveDrawingBuffer); + result.mFailIfMajorPerformanceCaveat = MBoolVal( @@ -161,8 +161,8 @@ index db60868f65..7361f0fc9c 100644 + case dom::WEBGL_debug_renderer_info_Binding::UNMASKED_VENDOR_WEBGL: + break; + default: -+ if (MaskConfig::GetBool(mIsWebGL2 ? "webgl2:parameters:blockIfNotDefined" -+ : "webgl:parameters:blockIfNotDefined")) { ++ if (MaskConfig::GetBool(mIsWebGL2 ? "webGl2:parameters:blockIfNotDefined" ++ : "webGl:parameters:blockIfNotDefined")) { + retval.set(JS::NullValue()); + return; + } @@ -272,7 +272,7 @@ index db60868f65..7361f0fc9c 100644 switch (pname) { case dom::WEBGL_debug_renderer_info_Binding::UNMASKED_RENDERER_WEBGL: -+ if (auto value = MaskConfig::GetString("webgl:renderer")) { ++ if (auto value = MaskConfig::GetString("webGl:renderer")) { + ret = Some(value.value()); + break; + } @@ -283,7 +283,7 @@ index db60868f65..7361f0fc9c 100644 break; case dom::WEBGL_debug_renderer_info_Binding::UNMASKED_VENDOR_WEBGL: -+ if (auto value = MaskConfig::GetString("webgl:vendor")) { ++ if (auto value = MaskConfig::GetString("webGl:vendor")) { + ret = Some(value.value()); + break; + } @@ -317,8 +317,8 @@ index db60868f65..7361f0fc9c 100644 + } + // Check if block if not defined is on + if (MaskConfig::GetBool( -+ mIsWebGL2 ? "webgl2:shaderPrecisionFormats:blockIfNotDefined" -+ : "webgl:shaderPrecisionFormats:blockIfNotDefined")) { ++ mIsWebGL2 ? "webGl2:shaderPrecisionFormats:blockIfNotDefined" ++ : "webGl:shaderPrecisionFormats:blockIfNotDefined")) { + Maybe ret; + return ret; + } @@ -331,8 +331,8 @@ index db60868f65..7361f0fc9c 100644 } + if (std::vector maskValues = -+ MaskConfig::GetStringList(mIsWebGL2 ? "webgl2:supportedExtensions" -+ : "webgl:supportedExtensions"); ++ MaskConfig::GetStringList(mIsWebGL2 ? "webGl2:supportedExtensions" ++ : "webGl:supportedExtensions"); + !maskValues.empty()) { + if (std::find(maskValues.begin(), maskValues.end(), + GetExtensionName(ext)) != maskValues.end()) { @@ -351,8 +351,8 @@ index db60868f65..7361f0fc9c 100644 + + // Implement separately to prevent O(n^2) timing + if (std::vector maskValues = -+ MaskConfig::GetStringList(mIsWebGL2 ? "webgl2:supportedExtensions" -+ : "webgl:supportedExtensions"); ++ MaskConfig::GetStringList(mIsWebGL2 ? "webGl2:supportedExtensions" ++ : "webGl:supportedExtensions"); + !maskValues.empty()) { + for (const auto& ext : maskValues) { + retarr.AppendElement(NS_ConvertUTF8toUTF16(ext)); diff --git a/settings/properties.json b/settings/properties.json index cd54143..a6e6cf1 100644 --- a/settings/properties.json +++ b/settings/properties.json @@ -68,19 +68,19 @@ { "property": "AudioContext:sampleRate", "type": "uint" }, { "property": "AudioContext:outputLatency", "type": "double" }, { "property": "AudioContext:maxChannelCount", "type": "uint" }, - { "property": "webgl:renderer", "type": "str" }, - { "property": "webgl:vendor", "type": "str" }, - { "property": "webgl:supportedExtensions", "type": "array" }, - { "property": "webgl2:supportedExtensions", "type": "array" }, - { "property": "webgl:parameters", "type": "dict" }, - { "property": "webgl:parameters:blockIfNotDefined", "type": "bool" }, - { "property": "webgl2:parameters", "type": "dict" }, - { "property": "webgl2:parameters:blockIfNotDefined", "type": "bool" }, - { "property": "webgl:shaderPrecisionFormats", "type": "dict" }, - { "property": "webgl:shaderPrecisionFormats:blockIfNotDefined", "type": "bool" }, - { "property": "webgl2:shaderPrecisionFormats", "type": "dict" }, - { "property": "webgl2:shaderPrecisionFormats:blockIfNotDefined", "type": "bool" }, - { "property": "webgl:contextAttributes", "type": "dict" }, - { "property": "webgl2:contextAttributes", "type": "dict" }, + { "property": "webGl:renderer", "type": "str" }, + { "property": "webGl:vendor", "type": "str" }, + { "property": "webGl:supportedExtensions", "type": "array" }, + { "property": "webGl2:supportedExtensions", "type": "array" }, + { "property": "webGl:parameters", "type": "dict" }, + { "property": "webGl:parameters:blockIfNotDefined", "type": "bool" }, + { "property": "webGl2:parameters", "type": "dict" }, + { "property": "webGl2:parameters:blockIfNotDefined", "type": "bool" }, + { "property": "webGl:shaderPrecisionFormats", "type": "dict" }, + { "property": "webGl:shaderPrecisionFormats:blockIfNotDefined", "type": "bool" }, + { "property": "webGl2:shaderPrecisionFormats", "type": "dict" }, + { "property": "webGl2:shaderPrecisionFormats:blockIfNotDefined", "type": "bool" }, + { "property": "webGl:contextAttributes", "type": "dict" }, + { "property": "webGl2:contextAttributes", "type": "dict" }, { "property": "debug", "type": "bool" } ] \ No newline at end of file