is-antibot 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -2
  2. package/src/index.js +6 -5
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "is-antibot",
3
3
  "description": "Detect Captcha responses",
4
4
  "homepage": "https://github.com/kikobeats/is-antibot",
5
- "version": "0.0.0",
5
+ "version": "0.0.2",
6
6
  "author": {
7
7
  "name": "Kiko Beats",
8
8
  "email": "josefrancisco.verdu@gmail.com",
@@ -22,7 +22,6 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@metascraper/helpers": "~5.49.15",
25
- "cheerio": "~1.1.2",
26
25
  "debug-logfmt": "~1.4.7"
27
26
  },
28
27
  "files": [
package/src/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const { parseUrl } = require('@metascraper/helpers')
4
4
  const debug = require('debug-logfmt')('is-antibot')
5
5
 
6
- module.exports = ({ url, $, html, headers = {} } = {}) => {
6
+ module.exports = ({ url, htmlDom, html, headers = {} } = {}) => {
7
7
  // https://developers.cloudflare.com/cloudflare-challenges/challenge-types/challenge-pages/detect-response/
8
8
  if (headers['cf-mitigated'] === 'challenge') {
9
9
  debug({ provider: 'cloudflare' })
@@ -16,16 +16,17 @@ module.exports = ({ url, $, html, headers = {} } = {}) => {
16
16
  return true
17
17
  }
18
18
 
19
- const { domainWithoutSuffix } = parseUrl(url)
19
+ const parsedUrl = parseUrl(url)
20
20
 
21
- if (domainWithoutSuffix === 'reddit') {
22
- $ = $ || require('cheerio').load(html)
23
- const condition = $('title').text().includes('Prove your humanity')
21
+ if (parsedUrl.domainWithoutSuffix === 'reddit') {
22
+ const condition = htmlDom.text().includes('Prove your humanity')
24
23
  if (condition) {
25
24
  debug({ provider: 'reddit' })
26
25
  return true
27
26
  }
28
27
  }
29
28
 
29
+ debug({ provider: 'unknown', ...parsedUrl })
30
+
30
31
  return false
31
32
  }