UNPKG

ayakashi

Version:

The next generation web scraping framework

40 lines (39 loc) 1.98 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateStealthPatches = void 0; const util_1 = require("util"); const path_1 = require("path"); const fs_1 = require("fs"); const child_process_1 = require("child_process"); const opLog_1 = require("../opLog/opLog"); const exec = util_1.promisify(child_process_1.exec); const rename = util_1.promisify(fs_1.rename); const opLog = opLog_1.getOpLog(); function updateStealthPatches() { return __awaiter(this, void 0, void 0, function* () { const localPath = process.cwd(); const stealthPath = path_1.resolve(__dirname, "../..", "lib", "detection"); try { process.chdir(stealthPath); const waiter = opLog.waiter("Downloading and building detection patches, this might take a while"); yield exec("npx extract-stealth-evasions"); yield rename(path_1.resolve(stealthPath, "stealth.min.js"), path_1.resolve(stealthPath, "stealth.js")); waiter.succeed("done!"); process.chdir(localPath); } catch (_e) { process.chdir(localPath); opLog.error("Failed to update detection patches. Builtin patches will be used"); } }); } exports.updateStealthPatches = updateStealthPatches;