Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0Developer committed Sep 11, 2023
1 parent 9111960 commit 980248c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/detectors/eval_length.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { BrowserEngineKind, BrowserKind, ComponentDict, DetectorResponse, State

export function detectEvalLengthInconsistency({
evalLength,
browser: browserComponent
browser: browserComponent,
}: ComponentDict): DetectorResponse {
if (evalLength.state !== State.Success || browserComponent.state !== State.Success) return
const { browserKind, browserEngineKind } = browserComponent.value

const { browserKind, browserEngineKind } = browserComponent.value
const length = evalLength.value
return (
(length === 37 && !arrayIncludes([BrowserEngineKind.Webkit, BrowserEngineKind.Gecko], browserEngineKind)) ||
Expand Down
5 changes: 1 addition & 4 deletions src/detectors/notification_permissions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { BotKind, BrowserKind, ComponentDict, DetectorResponse, State } from '../types'

export function detectNotificationPermissions({
notificationPermissions,
browser
}: ComponentDict): DetectorResponse {
export function detectNotificationPermissions({ notificationPermissions, browser }: ComponentDict): DetectorResponse {
if (browser.state !== State.Success || browser.value.browserKind !== BrowserKind.Chrome) return false

if (notificationPermissions.state === State.Success && notificationPermissions.value) {
Expand Down
9 changes: 3 additions & 6 deletions src/detectors/plugins_inconsistency.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { BotKind, BrowserEngineKind, BrowserKind, ComponentDict, DetectorResponse, State } from '../types'

export function detectPluginsLengthInconsistency({
pluginsLength,
browser
}: ComponentDict): DetectorResponse {
if (pluginsLength.state !== State.Success || browser.state !== State.Success) return
const { isAndroid, browserKind, browserEngineKind } = browser.value
export function detectPluginsLengthInconsistency({ pluginsLength, browser }: ComponentDict): DetectorResponse {
if (pluginsLength.state !== State.Success || browser.state !== State.Success) return
const { isAndroid, browserKind, browserEngineKind } = browser.value
if (browserKind !== BrowserKind.Chrome || isAndroid || browserEngineKind !== BrowserEngineKind.Chromium) return
if (pluginsLength.value === 0) return BotKind.HeadlessChrome
}
2 changes: 1 addition & 1 deletion src/detectors/product_sub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BotKind, BrowserKind, ComponentDict, DetectorResponse, State } from '..

export function detectProductSub({ productSub, browser }: ComponentDict): DetectorResponse {
if (productSub.state !== State.Success || browser.state !== State.Success) return false
const { browserKind } = browser.value
const { browserKind } = browser.value
if (
(browserKind === BrowserKind.Chrome ||
browserKind === BrowserKind.Safari ||
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/rtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BotKind, ComponentDict, DetectorResponse, State } from '../types'

export function detectRTT({ rtt, browser }: ComponentDict): DetectorResponse {
if (rtt.state !== State.Success || browser.state !== State.Success) return
const { isAndroid } = browser.value
const { isAndroid } = browser.value
// Rtt is 0 on android webview
if (isAndroid) return
if (rtt.value === 0) return BotKind.HeadlessChrome
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/window_size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BotKind, ComponentDict, DetectorResponse, State } from '../types'
export function detectWindowSize({ windowSize, browser }: ComponentDict): DetectorResponse {
if (windowSize.state !== State.Success || browser.state !== State.Success) return false
const { outerWidth, outerHeight } = windowSize.value
const { documentFocus } = browser.value
const { documentFocus } = browser.value
// When a page is opened in a new tab without focusing it right away, the window outer size is 0x0
if (!documentFocus) return
if (outerWidth === 0 && outerHeight === 0) return BotKind.HeadlessChrome
Expand Down
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export type AbstractDetectionsDict = Record<string, BotDetectionResult>
/**
* Represents a dictionary of detectors detection.
*/
export type DetectionDict<T extends AbstractDetectorDict<any> = DefaultDetectorDict> = Record<keyof T, BotDetectionResult>
export type DetectionDict<T extends AbstractDetectorDict<any> = DefaultDetectorDict> = Record<
keyof T,
BotDetectionResult
>

/**
* Dictionary of components.
Expand Down

0 comments on commit 980248c

Please sign in to comment.