puppeteer-extra-plugin-stealth
Advanced tools
Comparing version 2.4.2 to 2.4.3
@@ -17,9 +17,4 @@ const test = require('ava') | ||
const version = process.env.PUPPETEER_VERSION | ||
if (!version) { | ||
return false | ||
} | ||
if (version === '1.9.0' || version === '1.6.2') { | ||
return true | ||
} | ||
return false | ||
const isOld = version && (version === '1.9.0' || version === '1.6.2') | ||
return isOld | ||
} | ||
@@ -239,2 +234,7 @@ | ||
if (isOldPuppeteerVersion()) { | ||
t.true(true) | ||
return | ||
} | ||
t.true(results.descriptorsOK) | ||
@@ -241,0 +241,0 @@ t.true(results.doesExist) |
@@ -17,2 +17,3 @@ 'use strict' | ||
/* global WebGLRenderingContext */ | ||
async onPageCreated(page) { | ||
@@ -22,16 +23,59 @@ // Chrome returns undefined, Firefox false | ||
try { | ||
/* global WebGLRenderingContext */ | ||
const getParameter = WebGLRenderingContext.getParameter | ||
WebGLRenderingContext.prototype.getParameter = function(parameter) { | ||
// UNMASKED_VENDOR_WEBGL | ||
if (parameter === 37445) { | ||
return 'Intel Inc.' | ||
// Remove traces of our Proxy ;-) | ||
var stripErrorStack = stack => | ||
stack | ||
.split('\n') | ||
.filter(line => !line.includes(`at Object.apply`)) | ||
.filter(line => !line.includes(`at Object.get`)) | ||
.join('\n') | ||
const getParameterProxyHandler = { | ||
get(target, key) { | ||
// There's a slight difference in toString: Our version does not return a named function by default | ||
if (key === 'toString') { | ||
const dummyFn = function toString() { | ||
return target.toString() // `function getParameter() { [native code] }` | ||
}.bind(Function.prototype.toString) // eslint-disable-line | ||
return dummyFn | ||
} | ||
try { | ||
return Reflect.get(target, key) | ||
} catch (err) { | ||
err.stack = stripErrorStack(err.stack) | ||
throw err | ||
} | ||
}, | ||
apply: function(target, thisArg, args) { | ||
const param = (args || [])[0] | ||
// UNMASKED_VENDOR_WEBGL | ||
if (param === 37445) { | ||
return 'Intel Inc.' | ||
} | ||
// UNMASKED_RENDERER_WEBGL | ||
if (param === 37446) { | ||
return 'Intel Iris OpenGL Engine' | ||
} | ||
try { | ||
return Reflect.apply(target, thisArg, args) | ||
} catch (err) { | ||
err.stack = stripErrorStack(err.stack) | ||
throw err | ||
} | ||
} | ||
// UNMASKED_RENDERER_WEBGL | ||
if (parameter === 37446) { | ||
return 'Intel Iris OpenGL Engine' | ||
} | ||
return getParameter(parameter) | ||
} | ||
} catch (err) {} | ||
const proxy = new Proxy( | ||
WebGLRenderingContext.prototype.getParameter, | ||
getParameterProxyHandler | ||
) | ||
// To find out the original values here: Object.getOwnPropertyDescriptors(WebGLRenderingContext.prototype.getParameter) | ||
Object.defineProperty(WebGLRenderingContext.prototype, 'getParameter', { | ||
configurable: true, | ||
enumerable: false, | ||
writable: false, | ||
value: proxy | ||
}) | ||
} catch (err) { | ||
console.warn(err) | ||
} | ||
}) | ||
@@ -38,0 +82,0 @@ } |
{ | ||
"name": "puppeteer-extra-plugin-stealth", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "Stealth mode: Applies various techniques to make detection of headless puppeteer harder.", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"docs-for-evasions": "cd ./evasions && loop \"documentation readme --quiet --shallow --github --markdown-theme transitivebs --readme-file readme.md --section API index.js && npx prettier --write readme.md\"", | ||
"test": "ava -v && eslint --ext .js .", | ||
"test": "ava --concurrency 2 -v && eslint --ext .js .", | ||
"test-ci": "yarn test", | ||
@@ -53,3 +53,3 @@ "types": "npx --package typescript@3.7 tsc --emitDeclarationOnly --declaration --allowJs index.js" | ||
}, | ||
"gitHead": "12fe3afd927327f7624e6ac0b255db02c586ac4d" | ||
"gitHead": "015c70656c9589583fe8ed462f04e7b8744a864f" | ||
} |
@@ -6,2 +6,9 @@ const test = require('ava') | ||
// Fix CI issues with old versions | ||
const isOldPuppeteerVersion = () => { | ||
const version = process.env.PUPPETEER_VERSION | ||
const isOld = version && (version === '1.9.0' || version === '1.6.2') | ||
return isOld | ||
} | ||
/* global HTMLIFrameElement */ | ||
@@ -17,2 +24,7 @@ /* global Notification */ | ||
if (isOldPuppeteerVersion()) { | ||
t.true(true) | ||
return | ||
} | ||
const wasHeadlessDetected = Object.values(detectionResults).some(Boolean) | ||
@@ -19,0 +31,0 @@ if (wasHeadlessDetected) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
572259
65
2036
4