rustenium-identity 0.1.14

A versatile stealth overlay for rustenium
Documentation
// Navigator overrides
// webdriver: the launch flag --disable-blink-features=AutomationControlled already
// yields the correct `false`. Only spoof when automation left it `true` (e.g. when
// attaching to a remote browser the flag couldn't reach). Never delete it — an
// absent `navigator.webdriver` on a build new enough to have it is itself a tell.
if (navigator.webdriver === true) {
  PropertyModifier.spoofProperty(Navigator.prototype, 'webdriver', false);
}

PropertyModifier.spoofProperty(Navigator.prototype, 'platform', "{{NAVIGATOR_PLATFORM}}");
PropertyModifier.spoofProperty(Navigator.prototype, 'hardwareConcurrency', {{HARDWARE_CONCURRENCY}});
PropertyModifier.spoofProperty(Navigator.prototype, 'deviceMemory', {{MEMORY}});

// WebGL parameter spoofing.
// UNMASKED_VENDOR_WEBGL (37445) / UNMASKED_RENDERER_WEBGL (37446) are only exposed
// once a context calls getExtension('WEBGL_debug_renderer_info'); querying them
// before that returns null on real Chrome. So we delegate to the original first
// and only substitute when it returns a real value — that way the classic probe
// ("read 37445 without enabling the extension") sees the same null a real browser
// would, instead of a GPU string that gives the spoof away.
//
// The same substitution runs in worker scope (see worker_hook.js): a renderer that
// differs between the main thread and a worker is a single-comparison giveaway.
(function () {
  var vendor = "{{WEBGL_VENDOR}}";
  var renderer = "{{WEBGL_RENDERER}}";
  function hook(target) {
    if (typeof target === 'undefined' || !target) return;
    PropertyModifier.spoofMethod(target.prototype, 'getParameter', function (orig) {
      return function getParameter(parameter) {
        var real = orig.apply(this, arguments);
        if (parameter !== 37445 && parameter !== 37446) return real;
        // Mirror native behaviour exactly (incl. null + any GL error state) when
        // the debug extension isn't active; only mask a genuinely exposed value.
        if (real === null || real === undefined) return real;
        return parameter === 37445 ? vendor : renderer;
      };
    });
  }
  hook(typeof WebGLRenderingContext !== 'undefined' ? WebGLRenderingContext : null);
  hook(typeof WebGL2RenderingContext !== 'undefined' ? WebGL2RenderingContext : null);
})();

// History count spoofing
{{HISTORY_BLOCK}}

// Battery status.
// Patch BatteryManager.prototype rather than replacing navigator.getBattery: the
// promise then resolves to a genuine BatteryManager (real prototype chain, real
// EventTarget) instead of an object literal, and Navigator.getBattery — which is
// on every prototype-audit target list — stays completely untouched.
(function () {
  if (typeof BatteryManager === 'undefined') return;
  PropertyModifier.spoofProperty(BatteryManager.prototype, 'charging', {{CHARGING}});
  PropertyModifier.spoofProperty(BatteryManager.prototype, 'chargingTime', {{CHARGING_TIME}});
  PropertyModifier.spoofProperty(BatteryManager.prototype, 'dischargingTime', {{DISCHARGING_TIME}});
  PropertyModifier.spoofProperty(BatteryManager.prototype, 'level', {{BATTERY_PERCENTAGE}} / 100);
})();

// Browser-specific overrides
{{BROWSER_BLOCK}}