puppeteer-detection-100-percent
puppeteer-detection-100-percent copied to clipboard
Interesting stuff
Do you know if Puppeteer Extra package handles this? https://github.com/berstend/puppeteer-extra
page.evaluateOnNewDocument(() => {
class ModifiedError extends Error {
constructor(message) {
super(message)
this.stack = this.stack.replace(
/at __puppeteer_evaluation_script__.*/gmi, 'at (window)'
)
}
}
Object.defineProperty(window, 'Error', { configurable: false, writable: false, value: ModifiedError })
})
checkmate =)
page.evaluateOnNewDocument(() => { class ModifiedError extends Error { constructor(message) { super(message) this.stack = this.stack.replace( /at __puppeteer_evaluation_script__.*/gmi, 'at (window)' ) } } Object.defineProperty(window, 'Error', { configurable: false, writable: false, value: ModifiedError }) })
checkmate =)
Hey Vladislav, is that script stopping the detection of Puppeteer like it's stated by author of this repo?
yep. it overlaps native Error
object with child class which replaces detected string in stack trace on error initialization, and prevents further overlapping of Error
object, before any other script will be executed on page
yep. it overlaps native
Error
object with child class which replaces detected string in stack trace on error initialization, and prevents further overlapping ofError
object, before any other script will be executed on page
Thank you for explanation!
page.evaluateOnNewDocument(() => { class ModifiedError extends Error { constructor(message) { super(message) this.stack = this.stack.replace( /at __puppeteer_evaluation_script__.*/gmi, 'at (window)' ) } } Object.defineProperty(window, 'Error', { configurable: false, writable: false, value: ModifiedError }) })
checkmate =)
Any chance you can help with playwright version? I have used this
page.addInitScript(() => {
class ModifiedError extends Error {
constructor(message) {
super(message)
this.stack = this.stack.replace(
/at __playwright_evaluation_script__.*/gmi, 'at (window)'
)
}
}
Object.defineProperty(window, 'Error', { configurable: false, writable: false, value: ModifiedError })
})
But than almost all youtube buttons stop working. For example when I click "upload" or "Youtube studio" nothing happens except bunch of errors in console.