54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
0 && (module.exports = {
|
|
HTML_LIMITED_BOT_UA_RE: null,
|
|
HTML_LIMITED_BOT_UA_RE_STRING: null,
|
|
getBotType: null,
|
|
isBot: null
|
|
});
|
|
function _export(target, all) {
|
|
for(var name in all)Object.defineProperty(target, name, {
|
|
enumerable: true,
|
|
get: all[name]
|
|
});
|
|
}
|
|
_export(exports, {
|
|
HTML_LIMITED_BOT_UA_RE: function() {
|
|
return _htmlbots.HTML_LIMITED_BOT_UA_RE;
|
|
},
|
|
HTML_LIMITED_BOT_UA_RE_STRING: function() {
|
|
return HTML_LIMITED_BOT_UA_RE_STRING;
|
|
},
|
|
getBotType: function() {
|
|
return getBotType;
|
|
},
|
|
isBot: function() {
|
|
return isBot;
|
|
}
|
|
});
|
|
const _htmlbots = require("./html-bots");
|
|
// Bot crawler that will spin up a headless browser and execute JS
|
|
const HEADLESS_BROWSER_BOT_UA_RE = /Googlebot|Google-PageRenderer|AdsBot-Google|googleweblight|Storebot-Google/i;
|
|
const HTML_LIMITED_BOT_UA_RE_STRING = _htmlbots.HTML_LIMITED_BOT_UA_RE.source;
|
|
function isDomBotUA(userAgent) {
|
|
return HEADLESS_BROWSER_BOT_UA_RE.test(userAgent);
|
|
}
|
|
function isHtmlLimitedBotUA(userAgent) {
|
|
return _htmlbots.HTML_LIMITED_BOT_UA_RE.test(userAgent);
|
|
}
|
|
function isBot(userAgent) {
|
|
return isDomBotUA(userAgent) || isHtmlLimitedBotUA(userAgent);
|
|
}
|
|
function getBotType(userAgent) {
|
|
if (isDomBotUA(userAgent)) {
|
|
return 'dom';
|
|
}
|
|
if (isHtmlLimitedBotUA(userAgent)) {
|
|
return 'html';
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
//# sourceMappingURL=is-bot.js.map
|