### Install DeekeScript App via NPM Source: https://doc.deeke.cn/quick/start Installs the DeekeScript application package using npm. It's recommended to configure your npm registry to an Alibaba Cloud mirror if you experience slow installation. ```bash # If the following code execution is slow, please set the npm mirror to Alibaba Cloud mirror npm i deeke-script-app ``` -------------------------------- ### Clone DeekeScript Project and Install Dependencies Source: https://doc.deeke.cn/quick/start Clones the DeekeScript project from GitHub and installs its dependencies using npm. Similar to the NPM installation, setting an Alibaba Cloud mirror for npm is advised for faster dependency installation. ```bash git clone https://github.com/DeekeScript/DeekeScript ./ # If the following code execution is slow, please set the npm mirror to Alibaba Cloud mirror npm install ``` -------------------------------- ### Configure DY Group Buying Marketing Settings Source: https://doc.deeke.cn/config/config Sets up parameters for the Douyin 'Group Buying Marketing' feature. This includes a notice about location service authorization and starting conditions, and configurations for store name, operation count, like frequency, comment frequency, and private message frequency. ```json { "title": "团购营销", "hidden": false, "columns": 8, "icon": "img/team-buy.png", "jsFile": "tasks/task_dy_team_buy.js", "minVersion": 10001, "settingPage": { "params": [ { "type": "notice", "title": "1.团购功能可能需要多次授权位置服务,请先手动操作一遍流程,再使用软件运行~\n\n2.每次启动该功能,请确保DY界面在首页或者团购页~\n\n3.确保用户列表可以被操作" }, { "type": "textArea", "label": "门店名称", "name": "task_dy_team_buy_text", "value": "" }, { "type": "textArea", "label": "操作次数", "name": "task_dy_team_buy_op_count", "value": "10" }, { "type": "numberRange", "label": "赞频率(%)", "name": "task_dy_team_buy_zan_rate", "max": 100, "value": 50, "min": 0, "step": 1 }, { "type": "numberRange", "label": "评论频率(%)", "name": "task_dy_team_buy_comment_rate", "max": 100, "value": 50, "min": 0, "step": 1 }, { "type": "numberRange", "label": "私信频率(%)", "name": "task_dy_team_buy_private_rate", "max": 100, "value": 50, "min": 0, "step": 1 } ] } } ``` -------------------------------- ### params Parameter Configuration (Select Input) Source: https://doc.deeke.cn/config/config Configures a select dropdown menu for user settings, including options for the user to choose from. ```json { "type": "select", "label": "选项", "value": "1", "name": "selectOption", "options": [ { "selected": false, "label": "选项1", "value": "1" }, { "selected": true, "label": "选项2", "value": "2" } ] } ``` -------------------------------- ### settingLists Parameter Configuration (Qiwei Robot) Source: https://doc.deeke.cn/config/config Configures integration with a Qiwei robot for notifications or form submissions, requiring a specific settingPage configuration. ```json { "title": "企微通知", "icon": "logo/qiwei.png", "type": "qiwei", "settingPage": {} } ``` -------------------------------- ### Configure Douyin Fan Callback Task Source: https://doc.deeke.cn/config/config Sets up the 'Fan Callback' task for Douyin, which aims to increase fan engagement and loyalty by providing a notification. ```javascript { "title": "粉丝回访", "hidden": false, "icon": "img/view_back.png", "jsFile": "tasks/task_dy_fans_back_view.js", "settingPage": { "params": [ { "type": "notice", "title": "粉丝回访,能增加粉丝粘性~" } ] } } ``` -------------------------------- ### Start Activity with Intent (JavaScript) Source: https://doc.deeke.cn/base/app/app Starts an Activity based on a provided Intent object, which can include actions, data URIs, and other launch parameters. This is a more advanced way to interact with activities. ```javascript //跳转到目标APP let intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myapp://second_activity")); startActivity(intent); ``` -------------------------------- ### settingPage Parameter Configuration Source: https://doc.deeke.cn/config/config Defines the structure for user-configurable settings pages, specifying the types of input parameters required. ```json { "params": [] } ``` -------------------------------- ### settingLists Parameter Configuration (Update App) Source: https://doc.deeke.cn/config/config Configures an option to update the application from the settings page, specifying the URL for downloading the APK. ```json { "title": "更新App", "icon": "logo/update.png", "url": "/dke/download/apk", "type": "updateApp" } ``` -------------------------------- ### deekeScript.json Configuration Source: https://doc.deeke.cn/config/config Configuration settings for the deekeScript.json file, covering main parameters, switch settings, function groups, methods, and more. ```APIDOC ## 📄 deekeScript.json File Structure This file is crucial for configuring your DeekeScript project, managing everything from app branding to feature toggles and API interactions. ### Main Parameters (`deekeScript.json`) | Parameter Name | Type | Required | Example | Description | |----------------|--------|----------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `name` | String | Yes | Deeke | The name of the app displayed on the mobile device after installation. | | `versionCode` | String | Yes | 100 | The version number of the app. Used for automatic updates; if the current version is less than the uploaded version, an update is required. | | `versionName` | String | Yes | 1.0.0 | The display name of the app version. It's recommended to keep this consistent with `versionCode` (e.g., versionCode 100 corresponds to versionName 1.0.0). | | `icon` | String | Yes | logo/dke.png | The path to the app's icon. Recommended size is 200x200 pixels for clarity. | | `head` | String | Yes | img/root.png | The avatar displayed on the user settings page within the app. Can be omitted if there is no settings page. | | `debug` | Boolean| No | `true` | Defaults to `true`, allowing the script to run without an activation code. Set to `false` if an activation code is required to use the app. | | `host` | String | Yes | https://xx.xxx.xxx | The base URL for API requests. Ensure corresponding `apis` are configured to avoid script or app malfunction. | | `switchSetting`| Json | Yes | `switchSetting` object | Configuration for feature toggles and settings. | | `groups` | Array | Yes | `groups` array | Defines functional groups displayed on the app's main interface. Each group contains several features. | | `bottomMenus` | Array | Yes | `bottomMenus` array | Defines the bottom navigation menus for the app. Can use system-built-in menus or custom ones. | | `settingLists` | Array | Yes | `settingLists` array | Defines the list items for the app's settings page. Can use system-built-in items or custom ones. | | `apis` | Array | Yes | `apis` array | API configurations, such as for activation codes and validation. Essential for script or app operation. | ### Switch Settings (`switchSetting` parameter) | Parameter Name | Type | Required | Example | Description | |----------------|---------|----------|---------|---------------------| | `alipay` | Boolean | Yes | `true` | Enables Alipay payment. | ### Function Groups (`groups` parameter) | Parameter Name | Type | Required | Example | Description | |----------------|--------|----------|----------------|----------------------------------------------------------------------------| | `title` | String | Yes | XX截流 | The name of the function group on the app's main interface. | | `titleHidden` | String | No | `false` | Hides the function group title on the main interface (defaults to `false`).| | `hidden` | Boolean| No | `false` | Hides the function group visually (defaults to `false`). | | `methods` | Array | Yes | `methods` array| Associated settings pages for the function. If empty, the `jsFile` script is executed directly. | ### Methods (`methods` parameter) | Parameter Name | Type | Required | Example | Description | |----------------|--------|----------|--------------------------|---------------------------------------------------------------------------------------------------------------| | `title` | String | Yes | XX截流 | The name of the function displayed on the app's main interface. | | `icon` | String | Yes | logo/fans.png | The icon for the function on the app's main interface. | | `jsFile` | String | Yes | tasks/task_dy_toker_fans.js | The path to the JavaScript file that executes the function's logic. | | `settingPage` | Json | No | `settingPage` object | Configuration for the function's dedicated settings page. If omitted, the `jsFile` executes directly. | | `hidden` | Boolean| No | `true` | Hides the function module from the interface (defaults to `false`). | | `runType` | String | No | `floatSwitch` | Specifies the execution type. `floatSwitch` requires manual execution via a floating window. | | `packageName` | String | No | com.xingin.xhs | The package name of the app, used in conjunction with `runType`. | | `columns` | Number | No | 8 | Defines the number of columns for displaying function icons. `8` means 3 icons per row (24/8 = 3). | | `autoOpen` | Boolean| No | `true` | Automatically opens the associated interface when used with `packageName` (defaults to `false`). | ### Setting Page (`settingPage` parameter) | Parameter Name | Type | Required | Example | Description | |----------------|--------|----------|--------------|---------------------------------------------------------------------------------------------------------------------| | `params` | Array | Yes | `params` array | Defines the parameters that the user needs to set for this page. | ### Parameters (`params` parameter within `settingPage`) | Parameter Name | Type | Required | Example | Description ``` -------------------------------- ### Configure Douyin Anchor Follow Lead Generation Source: https://doc.deeke.cn/config/config Sets up the 'Anchor Follow Lead Generation' task for Douyin, defining interaction rates for messages, follows, and likes. ```javascript { "title": "关注截流", "icon": "img/anchor_focus.png", "jsFile": "tasks/task_dy_toker_focus.js", "hidden": false, "settingPage": { "params": [ { "type": "numberRange", "label": "私信频率(%)", "name": "focusSetting_privateRate", "max": 100, "min": 0, "step": 1 }, { "type": "numberRange", "label": "关注频率(%)", "name": "focusSetting_focusRate", "max": 100, "min": 0, "step": 1 }, { "type": "numberRange", "label": "点赞频率(%)", "name": "focusSetting_zanRate", "max": 100, "min": 0, "step": 1 } ] } } ``` -------------------------------- ### settingLists Parameter Configuration (Notice) Source: https://doc.deeke.cn/config/config Configures a custom HTML notice page within the settings, requiring a file path to the HTML content. ```json { "title": "自定义页面", "icon": "logo/notice.png", "type": "notice", "file": "task.html" } ``` -------------------------------- ### apis Parameter Configuration (Bind) Source: https://doc.deeke.cn/config/config Defines API endpoints for application binding and activation. The 'bind' type is used for initial activation. ```json { "url": "/dke/bind", "type": "bind" } ``` -------------------------------- ### switchSetting Configuration Source: https://doc.deeke.cn/config/config Configures general application settings, such as enabling or disabling payment methods. Currently supports Alipay. ```json { "alipay": true } ``` -------------------------------- ### params Parameter Configuration (Notice) Source: https://doc.deeke.cn/config/config Configures a notice field to display informational messages or instructions to the user within a settings page. ```json { "type": "notice", "label": "提示", "lines": 5, "notice": "这是一个重要的通知。" } ``` -------------------------------- ### Configure App Start Before Hook in deekeScript.json Source: https://doc.deeke.cn/hook/hook This snippet shows how to configure a hook that runs before the application starts by specifying the path to the JavaScript file in the 'app_start_before' field within the 'hooks' object in deekeScript.json. This is useful for initializing settings or modules before the main app interface loads. ```json { "hooks": { "app_start_before": "scripts/hooks/app_start_before.js" } } ``` -------------------------------- ### Start System Notification Service (DeekeScript) Source: https://doc.deeke.cn/advance/notification Starts the system notification service. It first checks for notification access permission, requests it if unavailable, and then starts the service. Requires the 'Access' and 'NotificationBridge' modules. ```javascript let hasAccess = Access.hasNotificationAccess(); console.log('是否有通知读取权限', hasAccess); if (!hasAccess) { Access.requestNotificationAccess(); System.exit(); } NotificationBridge.startService(); ``` -------------------------------- ### settingLists Parameter Configuration (Statistics) Source: https://doc.deeke.cn/config/config Configures a statistics tracking option, requiring a JavaScript file path to handle data collection. ```json { "title": "统计数据", "icon": "logo/stats.png", "type": "statistics", "jsFile": "statistics/statistics.js" } ``` -------------------------------- ### apis Parameter Configuration (Config) Source: https://doc.deeke.cn/config/config Defines API endpoints for application initialization. The 'config' type is used to fetch initial configuration data. ```json { "url": "/config/init", "type": "config" } ``` -------------------------------- ### System Notification API - startService Source: https://doc.deeke.cn/advance/notification Starts the system notification service. This function should be called before attempting to listen for notifications. ```APIDOC ## startService() ### Description Starts the system notification service. ### Method Not Applicable (JavaScript function call) ### Endpoint Not Applicable ### Parameters None ### Request Example ```javascript let hasAccess = Access.hasNotificationAccess(); console.log('是否有通知读取权限', hasAccess); if (!hasAccess) { Access.requestNotificationAccess(); System.exit(); } NotificationBridge.startService(); ``` ### Response None directly returned, but the service starts. ### Response Example None ``` -------------------------------- ### System Notification API - startListening Source: https://doc.deeke.cn/advance/notification Starts listening for incoming notifications and provides callbacks for when a notification is received or closed. ```APIDOC ## startListening(listener, listenerClosed) ### Description Listens for incoming notifications and registers callbacks for received and closed notification events. ### Method Not Applicable (JavaScript function call) ### Endpoint Not Applicable ### Parameters - **listener** (Function) - Required - A callback function executed when a notification is received. It receives packageName, title, and text as arguments. - **listenerClosed** (Function) - Required - A callback function executed when a notification is closed. It receives packageName, title, and text as arguments. ### Request Example ```javascript let hasAccess = Access.hasNotificationAccess(); console.log('是否有通知读取权限', hasAccess); if (!hasAccess) { Access.requestNotificationAccess(); System.exit(); } NotificationBridge.startService(); NotificationBridge.startListening((packageName, title, text) => { console.log('收到通知', packageName, title, text); }, (packageName, title, text) => { console.log('通知已关闭', packageName, title, text); }); NotificationBridge.startService(); setInterval(() => { console.log('正在监听中...'); }, 10000); ``` ### Response None directly returned, but listeners are registered. ### Response Example None ``` -------------------------------- ### settingLists Parameter Configuration (Clear Cache) Source: https://doc.deeke.cn/config/config Configures items for the settings page, including an option to clear cache with a confirmation prompt. ```json { "title": "清理缓存", "icon": "logo/clear.png", "type": "clear", "description": "确定清理吗?" } ``` -------------------------------- ### Configure Douyin Cancel Like Task Source: https://doc.deeke.cn/config/config Sets up the 'Cancel Like' task for Douyin, primarily providing a notification message to the user. ```javascript { "title": "取消点赞", "hidden": false, "icon": "img/cancel_zan.png", "jsFile": "tasks/task_dy_cancel_zan.js", "settingPage": { "params": [ { "type": "notice", "title": "帮助你快速取消视频点赞~" } ] } } ``` -------------------------------- ### settingLists Parameter Configuration (Upload Log) Source: https://doc.deeke.cn/config/config Configures an option to upload logs from the settings page, requiring a specific URL for the upload endpoint. ```json { "title": "上传日志", "icon": "logo/upload.png", "url": "/dke/uploadLog", "type": "uploadLog" } ``` -------------------------------- ### DeekeScript.json Structure Overview Source: https://doc.deeke.cn/config/config Defines the core parameters for a DeekeScript application, including app name, version, icon, and essential configuration sections like switchSetting, groups, bottomMenus, settingLists, and apis. ```json { "name": "Deeke", "versionCode": "100", "versionName": "1.0.0", "icon": "logo/dke.png", "head": "img/root.png", "debug": true, "host": "https://xx.xxx.xxx", "switchSetting": {}, "groups": [], "bottomMenus": [], "settingLists": [], "apis": [] } ``` -------------------------------- ### apis Parameter Configuration (CheckBind) Source: https://doc.deeke.cn/config/config Defines API endpoints for application binding and activation. The 'checkBind' type is used for verifying activation status on each run. ```json { "url": "/dke/checkBind", "type": "checkBind" } ``` -------------------------------- ### DeekeScript Command Summary Source: https://doc.deeke.cn/config/vscode Provides a table listing various DeekeScript commands available in VSCode and a brief explanation of their functionality, such as connecting/disconnecting, syncing, executing, and stopping scripts. ```markdown ## 📋 命令说明 命令| 功能说明 ---|--- **DeekeScript 关闭连接**| 关闭VSCode和Android手机的连接 **DeekeScript 连接手机**| VSCode连接手机(连接后才能"同步代码"、"执行代码") **DeekeScript 停止所有脚本**| 关闭DeekeScript在Android手机上的所有脚本运行 **DeekeScript 项目同步**| 将VSCode中的项目代码同步到Android手机端 **DeekeScript 仅当前文件执行**| 执行当前JavaScript文件的脚本 **DeekeScript 文件同步**| 仅同步当前文件到Android手机 ``` -------------------------------- ### JSON: DeekeScript Configuration Response Source: https://doc.deeke.cn/backendApi/activationCode Example JSON response for the DeekeScript configuration interface. It includes settings for ads, payment options (with prices and durations), and role definitions for dynamic UI elements. ```json { "code": 0, "msg": "成功", "success": true, "data": { "ad": { "app_open_url" : '开屏广告图片地址,如:https://xx.xx.xx/1.png', "app_pay_ad_url" : '支付宝支付入口广告图片地址,如:https://xx.xx.xx/2.png' }, "payList":{ "switch" => true,//是否开启扫码支付 "money" => [499, 199, 39.9, 299, 99, 599, 9.9], "day" => ['1年', '1月', '3天', '3月', '7天', '2年', '1天'] //money和day一一对应 }, "role": [ "label" : "角色名称,如:营销大师", "value" : 1, "content" : "智能体角色属性设定:你的角色是一个营销大师,xxxxxx", ] } } ``` -------------------------------- ### apis Parameter Configuration (CreateOrder - Alipay) Source: https://doc.deeke.cn/config/config Defines API endpoints for payment processing. The 'createOrder' type is used to initiate payment orders, specifically for Alipay. ```json { "url": "/payment/alipay/order", "type": "createOrder" } ``` -------------------------------- ### Douyin User Focus Settings Source: https://doc.deeke.cn/config/config Configures parameters for focusing on Douyin users based on their activity and profile metrics. Includes settings for comment rate, fan count, and operation count. ```JSON { "type": "numberRange", "label": "评论频率(%)", "name": "focusSetting_commentRate", "max": 100, "min": 0, "step": 1 }, { "type": "digit", "label": "粉丝数(不低于)", "name": "focusSetting_fansMinCount", "value": 0 }, { "type": "digit", "label": "粉丝数(不超过)", "name": "focusSetting_fansMaxCount", "value": 10000 }, { "type": "digit", "label": "作品数(不低于)", "name": "focusSetting_worksMinCount", "value": 0 }, { "type": "digit", "label": "作品数(不超过)", "name": "focusSetting_worksMaxCount", "value": 10000 }, { "type": "number", "label": "操作次数", "name": "focusSetting_opCount", "value": 100 }, { "type": "text", "label": "操作账号", "name": "focusSetting_account", "value": "", "notice": "*可以输入UID,需要在UID前面加上“#”" } ``` -------------------------------- ### params Parameter Configuration (Checkbox Group) Source: https://doc.deeke.cn/config/config Configures a group of checkboxes for user selection, allowing multiple options to be chosen. ```json { "type": "checkboxGroup", "label": "多选", "name": "checkboxes", "columnCount": 3, "children": [ { "label": "选项A", "value": "A" }, { "label": "选项B", "value": "B" }, { "label": "选项C", "value": "C" } ] } ``` -------------------------------- ### groups Parameter Configuration Source: https://doc.deeke.cn/config/config Defines functional groups displayed on the main interface. Each group can have a title, visibility settings, and associated methods. ```json { "title": "XX截流", "titleHidden": false, "hidden": false, "methods": [] } ``` -------------------------------- ### methods Parameter Configuration Source: https://doc.deeke.cn/config/config Specifies individual functions within a group, including their title, icon, script file, and optional settings page or execution type. ```json { "title": "XX截流", "icon": "logo/fans.png", "jsFile": "tasks/task_dy_toker_fans.js", "settingPage": {}, "hidden": true, "runType": "floatSwitch", "packageName": "com.xingin.xhs", "columns": 8, "autoOpen": true } ``` -------------------------------- ### Launch Application by Package Name (JavaScript) Source: https://doc.deeke.cn/base/app/app Starts or launches another application on the device using its package name. This is useful for invoking external applications. ```javascript App.launch("top.deeke.script");//打开DeekeScript ``` -------------------------------- ### Open DeekeScript Console Source: https://doc.deeke.cn/config/vscode Details how to open the DeekeScript console within VSCode, which is essential for viewing script output and other relevant information during development. ```markdown ### 📊 打开控制台 * 打开DeekeScript控制台(可以查看相关信息,包括脚本打印信息),如下图: ``` -------------------------------- ### Run Tests with DeekeScript Source: https://doc.deeke.cn/config/vscode Illustrates how to execute scripts or tests on the Android device using the 'Run' button provided by the DeekeScript extension in VSCode. The result of the execution is also shown. ```markdown ### ▶️ 运行测试 * Android端点击"运行"按钮(安卓图标左侧按钮),运行结果如下图: ``` -------------------------------- ### params Parameter Configuration (Text Input) Source: https://doc.deeke.cn/config/config Configures a text input field for user settings, including its label, initial value, name, and optional validation or display rules. ```json { "type": "text", "label": "用户账号", "value": "miniphper", "name": "account", "notice": "* 注意:用户账号不能为空" } ``` -------------------------------- ### bottomMenus Parameter Configuration Source: https://doc.deeke.cn/config/config Configures the items displayed in the application's bottom navigation bar, including titles, icons, and types (home, setting, speech). ```json { "title": "首页", "icon": "logo/fans.png", "banner": "banner/banner.png", "type": "home" } ``` -------------------------------- ### params Parameter Configuration (Number Range Input) Source: https://doc.deeke.cn/config/config Configures a number range input field for user settings, specifying minimum, maximum, step, and other relevant properties. ```json { "type": "numberRange", "label": "设置范围", "value": [0, 1000], "name": "range", "min": 0, "max": 1000, "step": 1 } ``` -------------------------------- ### Configure Follower Acquisition Task Source: https://doc.deeke.cn/config/config Sets parameters for the 'Fellow Customer Acquisition' task, including the number of runs and the average interval between operations. It also defines the average time spent on user homepages. ```json { "type": "numberRange", "label": "运行次数", "name": "task_xhs_fans_run_count", "value": 10, "max": 300, "min": 1 }, { "type": "numberRange", "label": "操作平均间隔(秒)", "name": "task_xhs_fans_interval", "value": 5, "max": 100, "min": 1, "step": 1 }, { "type": "numberRange", "label": "主页平均停留时间(秒)", "name": "task_xhs_fans_home_wait", "value": 5, "max": 100, "min": 1, "step": 1 } ``` -------------------------------- ### apis Parameter Configuration (GetToken - Alipay) Source: https://doc.deeke.cn/config/config Defines API endpoints for payment processing. The 'getToken' type is used to obtain payment tokens, specifically for Alipay. ```json { "url": "/payment/alipay/token", "type": "getToken" } ``` -------------------------------- ### Get current Activity name with System.currentActivity() Source: https://doc.deeke.cn/base/system/funcs The `System.currentActivity()` function returns the name of the most recently detected running Activity. This function relies on accessibility services, and will throw an exception if they are not enabled, prompting the user to start them. It returns a string representing the Activity name. ```javascript console.log(System.currentActivity()); ``` -------------------------------- ### options Parameter Configuration Source: https://doc.deeke.cn/config/config Defines the options for select, checkbox, or radio button input types, specifying whether an option is selected by default, its label, and its value. ```json { "selected": false, "label": "男", "value": "1" } ``` -------------------------------- ### Get current Package name with System.currentPackage() Source: https://doc.deeke.cn/base/system/funcs The `System.currentPackage()` function returns the name of the most recently detected running Package. Similar to `currentActivity()`, this function requires accessibility services to be enabled and will throw an exception if they are not, guiding the user to enable them. It returns a string representing the Package name. ```javascript console.log(System.currentPackage()); ``` -------------------------------- ### Socket.IO Client Creation and Usage Source: https://doc.deeke.cn/base/socket/client Demonstrates how to create a Socket.IO client instance, handle connection events, and send/receive messages. ```APIDOC ## Socket.IO Client Creation and Usage ### Description This section covers the creation of a Socket.IO client instance, including automatic reconnection and timeout configurations, as well as handling various connection events and basic message exchange. ### Method `SocketIoClient.getInstance(url, reconnect, timeout)` ### Endpoint N/A (Client-side instantiation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript // Create a socket.io client instance with auto-reconnect and a 5000ms reconnect delay let socketIOClient = SocketIoClient.getInstance("http://192.168.1.106:3000", true, 5000); socketIOClient.on("connect_error", (error) => { console.error("Connection Error:", error); }); socketIOClient.on("error", (error) => { console.error("General Error:", error); }); socketIOClient.on("connect_timeout", () => { console.error("Connection Timeout"); }); socketIOClient.on("connect", function(){ console.log('Is connected successfully: ', socketIOClient.isConnected()); socketIOClient.on("message", function(data) { console.log(data); }); // Emit events and data to the server socketIOClient.emit("message", { name: "DeekeScript", age: 3, }); }); socketIOClient.connect(); // Connect before defining event handlers // Keep the main thread alive to prevent premature WebSocket closure setInterval(function() { console.log('Main thread is alive'); }, 1000); ``` ### Response #### Success Response (200) N/A (Client-side connection) #### Response Example N/A ``` -------------------------------- ### apis Parameter Configuration (AISpeechToken) Source: https://doc.deeke.cn/config/config Defines API endpoints for accessing AI services. The 'aiSpeechToken' type is used to obtain tokens for Baidu AI large models. ```json { "url": "/ai/token", "type": "aiSpeechToken" } ``` -------------------------------- ### Douyin Comment Scraping Task Settings Source: https://doc.deeke.cn/config/config Configures parameters for the Douyin comment scraping task. Allows specifying target accounts, comment keywords, and rest intervals between rounds. ```JSON { "type": "textArea", "label": "输入账号(多账号使用逗号隔开)", "name": "task_dy_toker_comment_account", "value": "", "notice": "*可以输入UID,需要在输入框前面加上“#”" }, { "type": "textArea", "label": "评论关键词(多关键词使用逗号隔开)", "name": "task_dy_toker_comment_kw", "value": "" }, { "type": "numberRange", "label": "每轮休息时间(秒)", "name": "task_dy_toker_comment_sleep_second", "value": 600, "max": 3600, "min": 0, "step": 1 } ``` -------------------------------- ### DeekeScript Form Notice Example Source: https://doc.deeke.cn/base/ui/form This snippet demonstrates how to configure a 'notice' type form element in DeekeScript, used to display informational messages to the user. It includes the type and a descriptive title. ```json { "type": "notice", "title": "帮助你快速取消单向关注(你关注他,他没有关注你)的用户~" } ``` -------------------------------- ### Check if App is Installed (JavaScript) Source: https://doc.deeke.cn/base/app/app Determines whether a specific application is installed on the device by providing its package name. Returns a boolean value. ```javascript let isInstalled = App.isAppInstalled("top.deeke.script"); ``` -------------------------------- ### Connect to Socket.IO Server Source: https://doc.deeke.cn/base/socket/client Establishes a connection to the Socket.IO server. ```javascript socketIOClient.connect();//连接服务端 ``` -------------------------------- ### Get UI Element Child Count with DeekeScript Source: https://doc.deeke.cn/base/uiObject/uiObject Demonstrates how to get the number of direct child UI elements a given element possesses using the childCount() method. This is useful for understanding the structure of nested elements. ```javascript let obj = new UiSelector().className("LinearLayout").findOne(); if(obj){ console.log("子控件数量:" + obj.childCount()); } ``` -------------------------------- ### Listen for System Notifications (DeekeScript) Source: https://doc.deeke.cn/advance/notification Starts listening for system notifications and defines callback functions for when a notification is received or closed. It also includes logic to start the service and periodically log that it is listening. Requires notification access. ```javascript let hasAccess = Access.hasNotificationAccess(); console.log('是否有通知读取权限', hasAccess); if (!hasAccess) { Access.requestNotificationAccess(); System.exit(); } NotificationBridge.startService(); NotificationBridge.startListening((packageName, title, text) => { console.log('收到通知', packageName, title, text); }, (packageName, title, text) => { console.log('通知已关闭', packageName, title, text); }); NotificationBridge.startService(); setInterval(() => { console.log('正在监听中...'); }, 10000); ``` -------------------------------- ### 启动前台服务 (JavaScript) Source: https://doc.deeke.cn/advance/foreground 使用ForegroundServiceBridge.startService()方法来启动一个前台服务。此方法不接受任何参数。 ```javascript ForegroundServiceBridge.setContent('测试', '前台服务'); ForegroundServiceBridge.startService(); ``` -------------------------------- ### Get Various Data Types in Javascript Source: https://doc.deeke.cn/base/storage/storage Retrieves data of specific types from local storage, including integers, booleans, doubles, JSON objects, and arrays. Use the corresponding get method based on the stored data type. ```javascript // Assuming 'storage' is created using Storage.create() storage.getInteger("age"); // Outputs: 18 storage.getBoolean("is_success"); // Outputs: true storage.getDouble("money"); // Outputs: 1000000.11 storage.getObj("obj"); // Outputs: {name: "DeekeScript", age: 22} storage.getArray("arr"); // Outputs: [1, 2, 3, 'a', 'c', {name: 'deekeScript'}] ``` -------------------------------- ### UiSelector Filter Example - Bounds Check Source: https://doc.deeke.cn/base/uiSelector/uiSelector Illustrates using the `filter` method with a callback function to select UI elements based on their bounds. This example finds elements whose left boundary is greater than 100px and top boundary is greater than 300px. ```javascript let ui = UiSelector().filter((v)=>{ return v && v.bounds() && v.bounds().left > 100 && v.bounds().top > 300; }).findOne(); ``` -------------------------------- ### connect() Source: https://doc.deeke.cn/base/socket/client Establishes a connection to the Socket.IO server. ```APIDOC ## connect() ### Description Connects to the server. ### Method `socketIOClient.connect()` ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript socketIOClient.connect(); // Connect to the server ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Douyin Easy Customer Acquisition Task Configuration Source: https://doc.deeke.cn/config/config Configuration for the 'Easy Customer Acquisition' task on Douyin. It allows users to set parameters like run count, intervals, wait times on user profiles and posts, and filter users based on follower count. Additional options include specific actions like 'follow', 'private message', and 'like first post'. This task operates on user's fan or following lists. ```json { "title": "轻松拓客", "icon": "img/qingsong.png", "jsFile": "tasks/task_dy_qingsong_tuoke.js", "runType": "floatSwitch", "autoOpen": true, "packageName": "com.ss.android.ugc.aweme", "settingPage": { "params": [ { "type": "numberRange", "label": "运行次数", "name": "task_dy_qingsong_tuoke_run_count", "value": 10, "max": 1000, "min": 1 }, { "type": "numberRange", "label": "操作平均间隔(秒)", "name": "task_dy_qingsong_tuoke_interval", "value": 5, "max": 100, "min": 1, "step": 1 }, { "type": "numberRange", "label": "主页平均停留时间(秒)", "name": "task_dy_qingsong_tuoke_home_wait", "value": 5, "max": 100, "min": 1, "hidden": true, "step": 1 }, { "type": "numberRange", "label": "作品平均停留时间(秒)", "name": "task_dy_qingsong_tuoke_work_wait", "value": 5, "max": 100, "min": 2, "hidden": true, "step": 1 }, { "type": "number", "label": "粉丝数量不少于", "name": "task_dy_qingsong_tuoke_min_fans", "value": 0, "hidden": true }, { "type": "number", "label": "粉丝数量不大于", "name": "task_dy_qingsong_tuoke_max_fans", "value": 10000, "hidden": true }, { "type": "number", "label": "作品数大于", "name": "task_dy_qingsong_tuoke_min_work", "value": 1, "hidden": true }, { "type": "checkboxGroup", "label": "功能", "name": "task_dy_qingsong_tuoke_op", "columnCount": 6, "children": [ "关注", "私信", "首作品点赞" ], "values": [ "0", "2" ], "hidden": true }, { "type": "checkboxGroup", "label": "私信模式", "name": "task_dy_qingsong_tuoke_private_type", "children": [ "对普通用户私信", "对蓝V用户私信" ], "values": [], "hidden": true }, { "type": "notice", "title": "功能说明:在其他账号的 “粉丝” 或者 “关注” 界面运行,系统会对用户首作品点赞。" } ] } } ``` -------------------------------- ### System.currentPackage() Source: https://doc.deeke.cn/base/system/funcs Gets the name of the currently running package. Requires accessibility service. ```APIDOC ## System.currentPackage() ### Description Returns the name of the most recently detected running Package, generally considered the current Package. This function relies on the accessibility service; it will throw an exception and prompt the user to start the service if it's not running. ### Method System.currentPackage ### Returns - **string** - The name of the current package. ### Response Example ```javascript console.log(System.currentPackage()); // Output: top.deeke.script ``` ``` -------------------------------- ### System.currentActivity() Source: https://doc.deeke.cn/base/system/funcs Gets the name of the currently running activity. Requires accessibility service. ```APIDOC ## System.currentActivity() ### Description Returns the name of the most recently detected running Activity, generally considered the current Activity. This function relies on the accessibility service; it will throw an exception and prompt the user to start the service if it's not running. ### Method System.currentActivity ### Returns - **string** - The name of the current activity. ### Response Example ```javascript console.log(System.currentActivity()); // Output: top.deeke.script ``` ``` -------------------------------- ### Swipe Gesture Source: https://doc.deeke.cn/base/gesture/gesture Simulates a swipe gesture from a starting coordinate to an ending coordinate with a specified duration. ```APIDOC ## POST /gesture/swipe ### Description Simulates a swipe gesture from a starting coordinate to an ending coordinate with a specified duration. ### Method POST ### Endpoint /gesture/swipe ### Parameters #### Request Body - **startX** (number) - Required - The starting x-coordinate of the swipe. - **startY** (number) - Required - The starting y-coordinate of the swipe. - **endX** (number) - Required - The ending x-coordinate of the swipe. - **endY** (number) - Required - The ending y-coordinate of the swipe. - **duration** (number) - Required - The duration of the swipe in milliseconds. ### Request Example ```json { "startX": 100, "startY": 200, "endX": 500, "endY": 400, "duration": 200 } ``` ### Response #### Success Response (200) - **result** (boolean) - Indicates if the swipe operation was successful. #### Response Example ```json { "result": true } ``` ```