Browse Source

add botOption for all bots

master
filesite 7 months ago
parent
commit
5b8aa16ca1
  1. 6
      bot/Bilibili.mjs
  2. 6
      bot/Douyin.mjs
  3. 7
      bot/HeroBot.mjs
  4. 6
      bot/Kuaishou.mjs
  5. 6
      bot/Xigua.mjs
  6. 12
      config.mjs

6
bot/Bilibili.mjs

@ -11,12 +11,10 @@ class Bilibili extends HeroBot {
let options = { let options = {
userAgent: configs.userAgent, userAgent: configs.userAgent,
viewport: configs.viewport, viewport: configs.viewport,
showChrome: configs.showChrome,
showChromeInteractions: configs.showChromeInteractions,
showDevtools: configs.showDevtools,
showChromeAlive: configs.showChromeAlive,
}; };
options = common.mergeConfigs(configs.botOptions, options);
if (this.heroServer) { if (this.heroServer) {
options.connectionToCore = this.heroServer; options.connectionToCore = this.heroServer;
} }

6
bot/Douyin.mjs

@ -11,12 +11,10 @@ class Douyin extends HeroBot {
let options = { let options = {
userAgent: configs.userAgent, userAgent: configs.userAgent,
viewport: configs.viewport, viewport: configs.viewport,
showChrome: configs.showChrome,
showChromeInteractions: configs.showChromeInteractions,
showDevtools: configs.showDevtools,
showChromeAlive: configs.showChromeAlive,
}; };
options = common.mergeConfigs(configs.botOptions, options);
if (this.heroServer) { if (this.heroServer) {
options.connectionToCore = this.heroServer; options.connectionToCore = this.heroServer;
} }

7
bot/HeroBot.mjs

@ -3,6 +3,7 @@ import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import ClientLogPlugin from '../plugin/ClientLogPlugin.mjs'; import ClientLogPlugin from '../plugin/ClientLogPlugin.mjs';
import common from '../lib/common.mjs';
class HeroBot { class HeroBot {
constructor(heroCloudServer) { constructor(heroCloudServer) {
@ -34,12 +35,10 @@ class HeroBot {
let options = { let options = {
userAgent: configs.userAgent, userAgent: configs.userAgent,
viewport: configs.viewport, viewport: configs.viewport,
showChrome: configs.showChrome,
showChromeInteractions: configs.showChromeInteractions,
showDevtools: configs.showDevtools,
showChromeAlive: configs.showChromeAlive,
}; };
options = common.mergeConfigs(configs.botOptions, options);
if (this.heroServer) { if (this.heroServer) {
options.connectionToCore = this.heroServer; options.connectionToCore = this.heroServer;
} }

6
bot/Kuaishou.mjs

@ -11,12 +11,10 @@ class Kuaishou extends HeroBot {
let options = { let options = {
userAgent: configs.userAgent, userAgent: configs.userAgent,
viewport: configs.viewport, viewport: configs.viewport,
showChrome: configs.showChrome,
showChromeInteractions: configs.showChromeInteractions,
showDevtools: configs.showDevtools,
showChromeAlive: configs.showChromeAlive,
}; };
options = common.mergeConfigs(configs.botOptions, options);
if (this.heroServer) { if (this.heroServer) {
options.connectionToCore = this.heroServer; options.connectionToCore = this.heroServer;
} }

6
bot/Xigua.mjs

@ -11,12 +11,10 @@ class Xigua extends HeroBot {
let options = { let options = {
userAgent: configs.userAgent, userAgent: configs.userAgent,
viewport: configs.viewport, viewport: configs.viewport,
showChrome: configs.showChrome,
showChromeInteractions: configs.showChromeInteractions,
showDevtools: configs.showDevtools,
showChromeAlive: configs.showChromeAlive,
}; };
options = common.mergeConfigs(configs.botOptions, options);
if (this.heroServer) { if (this.heroServer) {
options.connectionToCore = this.heroServer; options.connectionToCore = this.heroServer;
} }

12
config.mjs

@ -32,10 +32,14 @@ let configs = {
width: 1440, width: 1440,
height: 900 height: 900
}, },
showChrome: false,
showChromeInteractions: false, //可选项参考官方文档:https://ulixee.org/docs/hero/basic-client/hero
showDevtools: false, botOptions: {
showChromeAlive: false, showChrome: false,
showChromeInteractions: false,
showDevtools: false,
showChromeAlive: false,
},
viewports: { viewports: {
mob: { mob: {

Loading…
Cancel
Save