Skip to content

Commit

Permalink
fix: BotReason.ChromeWithoutChrome removed due to false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 15, 2024
1 parent c8396f9 commit 17ce008
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/bot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ test('"" languages means bot', () => {
expect(botDetectionService.isBot()).toBe(BotReason.EmptyLanguages)
})

test('Chrome without chrome means bot', () => {
globalThis.navigator = {
userAgent: userAgentChrome,
} as Navigator
expect(botDetectionService.isBot()).toBe(BotReason.ChromeWithoutChrome)
})
// test('Chrome without chrome means bot', () => {
// globalThis.navigator = {
// userAgent: userAgentChrome,
// } as Navigator
// expect(botDetectionService.isBot()).toBe(BotReason.ChromeWithoutChrome)
// })

// This test helps with coverage, while not really testing anything useful
test('cdp in jest looks like a bot, because it does error serialization', () => {
Expand Down
7 changes: 4 additions & 3 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class BotDetectionService {
// isChrome is true if the browser is Chrome, Chromium or Opera
// this is "the chrome test" from https://intoli.com/blog/not-possible-to-block-chrome-headless/
// this property is for some reason not present by default in headless chrome
if (userAgent.includes('Chrome') && !(globalThis as any).chrome) {
return BotReason.ChromeWithoutChrome // Headless Chrome
}
// Kirill: criterium removed due to false positives with Android
// if (userAgent.includes('Chrome') && !(globalThis as any).chrome) {
// return BotReason.ChromeWithoutChrome // Headless Chrome
// }
}

/**
Expand Down

0 comments on commit 17ce008

Please sign in to comment.