Home Web Front-end JS Tutorial Use adb shell+node.js to realize Douyin automatically grab red envelopes

Use adb shell+node.js to realize Douyin automatically grab red envelopes

Apr 12, 2018 pm 04:52 PM
javascript Red envelope

This time I will bring you how to use adb shell node.js to realize Douyin’s automatic grabbing of red envelopes, and use adb shell node.js to realize Douyin’s automatic grabbing of red envelopes. NotesWhat are they? The following is a practical case. Let’s take a look.

The logic is very simple. After the Douyin video is played, if it is a red envelope video, the red envelope will pop up. Our simulation logic is as follows:

  1. Click the center of the screen. If there is a red envelope, open the red envelope. If there is no red envelope, the video will be paused.

  2. Click the return button. If there is a red envelope, close the red envelope interface. If there is no red envelope, press to exit (actually, it does not exit).

  3. #Swipe up to go to the next video.

Click, return, and swipe up, just three steps. It works regardless of whether there is a red envelope or not, as long as you calculate the time.

Code

The following is a piece of node.js code:

touch.js

var process = require('child_process');
function exec(shell) {
 process.exec(shell,function (error, stdout, stderr) {
 if (error !== null) {
  console.log('exec error: ' + error);
 }
 });
}
function click() {
 console.log('click')
 exec(`adb shell input tap 400 600`)
 setTimeout(back, 1000)
}
function swipe() {
 console.log('swipe')
 exec(`adb shell input swipe 400 800 400 0 500`)
 setTimeout(click, 20000)
}
function back() {
 console.log('back')
 exec(`adb shell input keyevent 4`)
 setTimeout(swipe, 1000)
}
swipe()
Copy after login

Turn on the developer mode of the phone and start USBdebugging. If it is Xiaomi, please also turn on USB debugging (Security settings). Connect your phone and open the main interface of Douyin. Save this js locally and execute it using node.

$ node touch.js
Copy after login

If you find that Douyin slides up every 20 seconds, it means it is successful~

Principle

Articles similar to using adb shell to operate mobile phones also include jump operations, etc. The principle is explained below.

child_process.exec(command[, options][, callback])
Copy after login

The function of this method is to spawn a shell, then execute the command in the shell, and buffer any generated output. For details, please refer to the reference document. In fact, it is equivalent to executing scripts and shell commands. We use it to execute adb shell commands.

adb shell

adb is a development tool for connecting computers to mobile phones. All computer operations on mobile phones are actually completed by adb, including various mobile phone assistants that help you install APPs. PS: I have been working on mobile phones for so long, and I just discovered this interesting function today... Sigh...

adb shell can install apk, view mobile phone information, operate mobile phone files, simulate click behavior and other functions, it is very powerful. Our main purpose here is to simulate the click behavior of adb shell input. The functions are listed below:

// 输入文本 content
$ adb shell input text “hello” 
// 点击返回按钮 keynumber
$ adb shell input keyevent 4
// 点击屏幕某个点 x y
$ adb shell input tap 400 400
// 滑动 x1 y1 x2 y2 time
$ adb shell input swipe 400 800 400 0 500
// 下面三个不太清楚,再研究
$ adb shell input press
$ adb shell input roll
$ adb shell input tmode
Copy after login

For more key corresponding values, you can see the corresponding values ​​​​of Android keyevent. Through these commands, we can perform some simple operations on the mobile phone~

at last

This is actually a very simple logic, but it gave me a lot of inspiration. If there are any simple operations in the future, I can use adb and node to repeat them~ Finally, I will complain: There are really few red envelopes on Douyin. I spent 3 hours browsing yesterday. It’s just a few cents, which is not enough for the electricity bill. Just treat it as entertainment~

PS: The following introduces the corresponding values ​​​​of Android keyevent

Each value in Android keyevent can be used when using adb shell input.

KEYCODE_UNKNOWN=0;
KEYCODE_SOFT_LEFT=1;
KEYCODE_SOFT_RIGHT=2;
KEYCODE_HOME=3;
KEYCODE_BACK=4;
KEYCODE_CALL=5;
KEYCODE_ENDCALL=6;
KEYCODE_0=7;
KEYCODE_1=8;
KEYCODE_2=9;
KEYCODE_3=10;
KEYCODE_4=11;
KEYCODE_5=12;
KEYCODE_6=13;
KEYCODE_7=14;
KEYCODE_8=15;
KEYCODE_9=16;
KEYCODE_STAR=17;
KEYCODE_POUND=18;
KEYCODE_DPAD_UP=19;
KEYCODE_DPAD_DOWN=20;
KEYCODE_DPAD_LEFT=21;
KEYCODE_DPAD_RIGHT=22;
KEYCODE_DPAD_CENTER=23;
KEYCODE_VOLUME_UP=24;
KEYCODE_VOLUME_DOWN=25;
KEYCODE_POWER=26;
KEYCODE_CAMERA=27;
KEYCODE_CLEAR=28;
KEYCODE_A=29;
KEYCODE_B=30;
KEYCODE_C=31;
KEYCODE_D=32;
KEYCODE_E=33;
KEYCODE_F=34;
KEYCODE_G=35;
KEYCODE_H=36;
KEYCODE_I=37;
KEYCODE_J=38;
KEYCODE_K=39;
KEYCODE_L=40;
KEYCODE_M=41;
KEYCODE_N=42;
KEYCODE_O=43;
KEYCODE_P=44;
KEYCODE_Q=45;
KEYCODE_R=46;
KEYCODE_S=47;
KEYCODE_T=48;
KEYCODE_U=49;
KEYCODE_V=50;
KEYCODE_W=51;
KEYCODE_X=52;
KEYCODE_Y=53;
KEYCODE_Z=54;
KEYCODE_COMMA=55;
KEYCODE_PERIOD=56;
KEYCODE_ALT_LEFT=57;
KEYCODE_ALT_RIGHT=58;
KEYCODE_SHIFT_LEFT=59;
KEYCODE_SHIFT_RIGHT=60;
KEYCODE_TAB=61;
KEYCODE_SPACE=62;
KEYCODE_SYM=63;
KEYCODE_EXPLORER=64;
KEYCODE_ENVELOPE=65;
KEYCODE_ENTER=66;
KEYCODE_DEL=67;
KEYCODE_GRAVE=68;
KEYCODE_MINUS=69;
KEYCODE_EQUALS=70;
KEYCODE_LEFT_BRACKET=71;
KEYCODE_RIGHT_BRACKET=72;
KEYCODE_BACKSLASH=73;
KEYCODE_SEMICOLON=74;
KEYCODE_APOSTROPHE=75;
KEYCODE_SLASH=76;
KEYCODE_AT=77;
KEYCODE_NUM=78;
KEYCODE_HEADSETHOOK=79;
KEYCODE_FOCUS=80;//*Camera*focus
KEYCODE_PLUS=81;
KEYCODE_MENU=82;
KEYCODE_NOTIFICATION=83;
KEYCODE_SEARCH=84;
KEYCODE_MEDIA_PLAY_PAUSE=85;
KEYCODE_MEDIA_STOP=86;
KEYCODE_MEDIA_NEXT=87;
KEYCODE_MEDIA_PREVIOUS=88;
KEYCODE_MEDIA_REWIND=89;
KEYCODE_MEDIA_FAST_FORWARD=90;
KEYCODE_MUTE=91;
Copy after login

Okay, that’s all.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of Vuex’s mutations and actions

Vue determines whether the input content has spaces

The above is the detailed content of Use adb shell+node.js to realize Douyin automatically grab red envelopes. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

How to implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

Where is the Alipay red envelope code? Where is the Alipay red envelope code? Apr 25, 2024 am 10:20 AM

1. Open the Alipay app, click on the search box at the top, and enter [make money with red envelopes]. 2. Click [Go and Share to Earn Cash] or [Earn Cash Rewards Immediately] to generate a red envelope code for making money. 3. Users can choose to save the money-making red envelope code to the photo album, or share it directly with friends such as WeChat/Alipay/QQ. 4. Users can also choose to copy the password and share it with friends on various social software.

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

JavaScript and WebSocket: Building an efficient real-time weather forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

See all articles