puppeteer-extra icon indicating copy to clipboard operation
puppeteer-extra copied to clipboard

[Feature] There's no way to programatically set WebGL Renderer and Vendor

Open Pic2490 opened this issue 1 year ago • 12 comments

Feature request I think it would be essential if someone could change out the hardcoded values in WebGl Renderer and Vendor like the way one can .setUserAgent() on Start Up

Pic2490 avatar Oct 11 '23 20:10 Pic2490

Not sure this is still maintained given no updates for a long time. You can manually change it.

find the file ...\node_modules\puppeteer-extra-plugin-stealth\evasions\webgl.vendor\index.js and modify it as you wish

// UNMASKED_VENDOR_WEBGL if (param === 37445) { return opts.vendor || 'Google Inc. (NVIDIA)' // default in headless: Google Inc. } // UNMASKED_RENDERER_WEBGL if (param === 37446) { return opts.renderer || 'ANGLE (NVIDIA, NVIDIA GeForce RTX 2080 TI Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6079)' // default in headless: Google SwiftShader }

GiveDaData avatar Oct 11 '23 21:10 GiveDaData

Not sure this is still maintained given no updates for a long time. You can manually change it.

find the file ...\node_modules\puppeteer-extra-plugin-stealth\evasions\webgl.vendor\index.js and modify it as you wish

// UNMASKED_VENDOR_WEBGL if (param === 37445) { return opts.vendor || 'Google Inc. (NVIDIA)' // default in headless: Google Inc. } // UNMASKED_RENDERER_WEBGL if (param === 37446) { return opts.renderer || 'ANGLE (NVIDIA, NVIDIA GeForce RTX 2080 TI Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6079)' // default in headless: Google SwiftShader }

Appreciate the swift response, I'm aware of changing it manually but do you know if there's a way to change it programmatically?

Pic2490 avatar Oct 11 '23 21:10 Pic2490

Not sure this is still maintained given no updates for a long time. You can manually change it. find the file ...\node_modules\puppeteer-extra-plugin-stealth\evasions\webgl.vendor\index.js and modify it as you wish // UNMASKED_VENDOR_WEBGL if (param === 37445) { return opts.vendor || 'Google Inc. (NVIDIA)' // default in headless: Google Inc. } // UNMASKED_RENDERER_WEBGL if (param === 37446) { return opts.renderer || 'ANGLE (NVIDIA, NVIDIA GeForce RTX 2080 TI Direct3D11 vs_5_0 ps_5_0, D3D11-27.21.14.6079)' // default in headless: Google SwiftShader }

Appreciate the swift response, I'm aware of changing it manually but do you know if there's a way to change it programmatically?

Looking at the codes, I do not think there is such function

GiveDaData avatar Oct 11 '23 21:10 GiveDaData

You can pass in opts if you new up the plugin yourself - I was able to do the following:

import pxe from "playwright-extra";
import stealth from "puppeteer-extra-plugin-stealth";
import WebGlVendorPlugin from "puppeteer-extra-plugin-stealth/evasions/webgl.vendor/index.js";
pxe.chromium.use(stealth({
  "enabledEvasions": new Set([
    // all from https://github.com/berstend/puppeteer-extra/blob/master/packages/puppeteer-extra-plugin-stealth/index.js#L82
    "chrome.app",
    "chrome.csi",
    "chrome.loadTimes",
    "chrome.runtime",
    "defaultArgs",
    "iframe.contentWindow",
    "media.codecs",
    "navigator.hardwareConcurrency",
    "navigator.languages",
    "navigator.permissions",
    "navigator.plugins",
    "navigator.webdriver",
    "sourceurl",
    "user-agent-override",
    // "webgl.vendor",
    "window.outerdimensions"
  ])
})).use(new WebGlVendorPlugin({
  vendor: "please no more captchas",
  renderer: "i'm begging you"
}));

fxyoge avatar Nov 21 '23 06:11 fxyoge

@fxyoge Can we do it using Puppeteer only or how can we do it manually

arjunsharma1152 avatar Nov 22 '23 17:11 arjunsharma1152

It certainly possibile, try something like this, of course it could be simpler.

const StealthPlugin = PuppeteerStealth(); StealthPlugin.enabledEvasions.delete('webgl.vendor'); let customGpu = require('puppeteer-extra-plugin-stealth/evasions/webgl.vendor')({ vendor: gpu.vendor, renderer: gpu.renderer }) Puppeteer.use(customGpu);

marcusdiy avatar Jan 04 '24 00:01 marcusdiy

const StealthPlugin = PuppeteerStealth(); StealthPlugin.enabledEvasions.delete('webgl.vendor'); let customGpu = require('puppeteer-extra-plugin-stealth/evasions/webgl.vendor')({ vendor: gpu.vendor, renderer: gpu.renderer }) Puppeteer.use(customGpu);

Does it even work at all?

imaxs avatar Apr 13 '24 02:04 imaxs

const StealthPlugin = PuppeteerStealth(); StealthPlugin.enabledEvasions.delete('webgl.vendor'); let customGpu = require('puppeteer-extra-plugin-stealth/evasions/webgl.vendor')({ vendor: gpu.vendor, renderer: gpu.renderer }) Puppeteer.use(customGpu);

I'm checking it out on https://browserleaks.com/webgl

And I see the values of vendor and renderer have NOT changed in any way

imaxs avatar Apr 13 '24 13:04 imaxs

I'm checking it out on https://browserleaks.com/webgl

Below is a method that works fine for me

await page.evaluateOnNewDocument(() => { WebGLRenderingContext.prototype.getParameter = function(origFn) { const paramMap = {}; paramMap[0x9245] = "ARM"; // UNMASKED_VENDOR_WEBGL paramMap[0x9246] = "Mali-G71"; // UNMASKED_RENDERER_WEBGL return function(parameter) { return paramMap[parameter] || origFn.call(this, parameter); }; }(WebGLRenderingContext.prototype.getParameter); WebGL2RenderingContext.prototype.getParameter = function(origFn) { const paramMap = {}; paramMap[0x9245] = "ARM"; // UNMASKED_VENDOR_WEBGL paramMap[0x9246] = "Mali-G71"; // UNMASKED_RENDERER_WEBGL return function(parameter) { return paramMap[parameter] || origFn.call(this, parameter); }; }(WebGL2RenderingContext.prototype.getParameter); });

imaxs avatar Apr 13 '24 14:04 imaxs

^ This is easily detectable WebGLRenderingContext.prototype.getParameter.toString()

vladtreny avatar Apr 13 '24 16:04 vladtreny

^ This is easily detectable WebGLRenderingContext.prototype.getParameter.toString()

Well what solution can you offer to solve it?

imaxs avatar Apr 13 '24 18:04 imaxs

^ This is easily detectable WebGLRenderingContext.prototype.getParameter.toString()

Well what solution can you offer to solve it?

No mind the guy joor. your solution was perfect. any suggestions for broken Image dimension ?

dannyokec avatar May 05 '24 17:05 dannyokec