Skip to content

Commit

Permalink
fix: stop treating ZeroPlugins users as bots, as it's false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 15, 2024
1 parent 957cfdc commit c8396f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/bot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ test('navigator.webdriver means bot', () => {
expect(botDetectionService.isBot()).toBe(BotReason.WebDriver)
})

test('0 plugins means bot', () => {
globalThis.navigator = {
userAgent: userAgentSafari,
plugins: [] as any,
} as Navigator
expect(botDetectionService.isBot()).toBe(BotReason.ZeroPlugins)
})
// test('0 plugins means bot', () => {
// globalThis.navigator = {
// userAgent: userAgentSafari,
// plugins: [] as any,
// } as Navigator
// expect(botDetectionService.isBot()).toBe(BotReason.ZeroPlugins)
// })

test('"" languages means bot', () => {
globalThis.navigator = {
Expand Down
8 changes: 5 additions & 3 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ class BotDetectionService {
return BotReason.WebDriver
}

if (navigator.plugins?.length === 0) {
return BotReason.ZeroPlugins // Headless Chrome
}
// Kirill: commented out, as it's no longer seems reliable,
// e.g generates false positives with latest Android clients (e.g. Chrome 129)
// if (navigator.plugins?.length === 0) {
// return BotReason.ZeroPlugins // Headless Chrome
// }

if ((navigator.languages as any) === '') {
return BotReason.EmptyLanguages // Headless Chrome
Expand Down

0 comments on commit c8396f9

Please sign in to comment.