├── .gitignore
├── README.md
├── .prettierrc
└── main.js
/.gitignore:
--------------------------------------------------------------------------------
1 | *.zip
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 京东双十一自动任务脚本
2 |
3 | 1. 基于 autojs
4 | 2. 京东 app 打开任务列表再运行脚本
5 | 3. interval 的值可以根据手机情况调整
6 | 4. btnIndex 为跳过前多少个任务,根据自身情况调整
7 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "eslintIntegration": true,
3 | "arrowParens": "avoid",
4 | "bracketSpacing": true,
5 | "singleQuote": true,
6 | "trailingComma": "none",
7 | "printWidth": 80,
8 | "semi": false,
9 | "endOfLine": "auto",
10 | "vueIndentScriptAndStyle": true
11 | }
12 |
--------------------------------------------------------------------------------
/main.js:
--------------------------------------------------------------------------------
1 | let btnIndex = 1 //将要点击按钮的序号,跳过一些无法完成的任务
2 | let itemCount = 0 //浏览、加购商品计数
3 | const interval = 2000 //任务执行间隔,手机性能差的设置大一些
4 | const member = false //设置是否加入会员。true为加入、false为跳过
5 |
6 | const backToTaskPage = () => {
7 | //如果在任务首页,不走返回逻辑
8 | const ifHomePage =
9 | textContains('去完成').exists() && textContains('签到').exists()
10 | if (!ifHomePage) {
11 | if (id('title_back').exists()) {
12 | id('title_back').findOne().click()
13 | } else if (id('yl').exists()) {
14 | id('yl').findOne().click()
15 | } else if (id('yp').exists()) {
16 | id('yp').findOne().click()
17 | } else if (id('com.jd.lib.jshop:id/fd').exists()) {
18 | id('com.jd.lib.jshop:id/fd').findOne().click()
19 | } else if (id('com.jd.lib.jshop:id/fe').exists()) {
20 | id('com.jd.lib.jshop:id/fe').findOne().click()
21 | } else if (id('d').exists()) {
22 | id('d').findOne().click()
23 | } else if (
24 | classNameContains('android.view.ViewGroup').desc('返回按钮').exists()
25 | ) {
26 | classNameContains('android.view.ViewGroup')
27 | .desc('返回按钮')
28 | .findOne()
29 | .click()
30 | } else if (id('com.jingdong.app.mall:id/fe').exists()) {
31 | id('com.jingdong.app.mall:id/fe').findOne().click()
32 | } else if (id('com.jingdong.app.mall:id/fd').exists()) {
33 | id('com.jingdong.app.mall:id/fd').findOne().click()
34 | } else if (id('fe').exists()) {
35 | id('fe').findOne().click()
36 | } else if (id('fd').exists()) {
37 | id('fd').findOne().click()
38 | } else if (
39 | classNameContains('android.widget.FrameLayout')
40 | .boundsInside(800, 1000, device.width, device.height)
41 | .exists()
42 | ) {
43 | classNameContains('android.widget.FrameLayout')
44 | .boundsInside(800, 1000, device.width, device.height)
45 | .findOne()
46 | .click()
47 | } else if (
48 | className('android.view.View')
49 | .boundsInside(800, 1000, device.width, device.height)
50 | .clickable(true)
51 | .depth(7)
52 | .exists()
53 | ) {
54 | className('android.view.View')
55 | .boundsInside(800, 1000, device.width, device.height)
56 | .clickable(true)
57 | .depth(7)
58 | .findOne()
59 | .click()
60 | } else if (
61 | className('android.view.View')
62 | .boundsInside(800, 1000, device.width, device.height)
63 | .clickable(true)
64 | .depth(9)
65 | .exists()
66 | ) {
67 | className('android.view.View')
68 | .boundsInside(800, 1000, device.width, device.height)
69 | .clickable(true)
70 | .depth(9)
71 | .findOne()
72 | .click()
73 | } else {
74 | back()
75 | }
76 | }
77 | }
78 |
79 | function Task(btnIndex, itemCount, interval, member) {
80 | this.btnIndex = btnIndex
81 | this.itemCount = itemCount
82 | this.interval = interval
83 | this.member = member
84 | this.next = true
85 | this.switch = true
86 |
87 | //等待8秒任务
88 | this.waitingPage = () => {
89 | if (
90 | this.next &&
91 | textStartsWith('获得').exists() &&
92 | textEndsWith('金币').exists()
93 | ) {
94 | toast('等待8秒任务')
95 | this.next = false
96 | backToTaskPage()
97 | }
98 | }
99 |
100 | //加购任务页
101 | this.cartTaskPage = () => {
102 | const conditions = textContains('购物车加购5个商品').exists()
103 | if (this.next && conditions) {
104 | toast('加购任务')
105 | this.next = false
106 | if (this.itemCount >= 5) {
107 | this.itemCount = 0
108 | return backToTaskPage()
109 | }
110 | textContains('¥').find()[this.itemCount].parent().child(5).click()
111 | this.itemCount++
112 | }
113 | }
114 |
115 | //商品详情页面
116 | this.detadilsPage = () => {
117 | const conditions1 =
118 | textContains('店铺').exists() && textContains('购物车').exists()
119 | const conditions2 =
120 | textContains('客服').exists() && textContains('购物车').exists()
121 | if (this.next && (conditions1 || conditions2)) {
122 | toast('商品详情')
123 | this.next = false
124 | sleep(1000)
125 | back()
126 | }
127 | }
128 |
129 | //会员任务
130 | this.memberPage = () => {
131 | const conditions = textContains('品牌会员联合开卡').exists()
132 | if (this.next && conditions) {
133 | toast('会员任务')
134 | this.next = false
135 | if (this.member) {
136 | if (textContains('恭喜您已集齐所有会员卡').exists()) {
137 | back()
138 | }
139 | textContains('确认授权并加入店铺会员').findOne().click()
140 | } else {
141 | toast('跳过所有会员任务')
142 | this.btnIndex++
143 | back()
144 | }
145 | }
146 | }
147 |
148 | //可以直接返回的任务
149 | this.backPage = () => {
150 | sleep(5000)
151 | if (textStartsWith('逛精').exists() && textEndsWith('金币').exists()) {
152 | return
153 | } else if (this.next) {
154 | toast('可以直接返回的任务')
155 | this.next = false
156 | back()
157 | }
158 | }
159 |
160 | //任务列表
161 | this.taskListPage = () => {
162 | const conditions = textContains('邀请好友助力').exists()
163 | if (this.next && conditions) {
164 | toast('任务列表')
165 | if (!this.btnIndex) {
166 | this.btnIndex++
167 | }
168 | if (textContains('去完成').exists()) {
169 | const result = click('去完成', this.btnIndex)
170 | sleep(1000)
171 | if (!result) {
172 | toast('已经完成所有任务')
173 | this.switch = false
174 | }
175 | }
176 | this.next = false
177 | }
178 | }
179 |
180 | //返回任务列表
181 | this.start = () => {
182 | toast('脚本运行中,请打开任务列表')
183 | for (;;) {
184 | if (!this.switch) {
185 | toast('停止一般任务')
186 | break
187 | }
188 | this.next = true
189 | sleep(this.interval)
190 | this.detadilsPage()
191 | this.cartTaskPage()
192 | this.taskListPage()
193 | this.waitingPage()
194 | this.backPage()
195 | this.memberPage()
196 | }
197 | }
198 |
199 | this.stop = () => {
200 | this.switch = false
201 | }
202 | }
203 |
204 | const task = new Task(btnIndex, itemCount, interval, member)
205 |
206 | const taskBtn = floaty.window(
207 |
208 |
209 |
210 | )
211 |
212 | const stopBtn = floaty.window(
213 |
214 |
215 |
216 | )
217 |
218 | taskBtn.setPosition(150, 0)
219 | stopBtn.setPosition(150, 150)
220 |
221 | taskBtn.task.click(() => {
222 | threads.shutDownAll()
223 | threads.start(function () {
224 | toast('重新执行一般任务')
225 | task.stop()
226 | task.switch = true
227 | task.start()
228 | })
229 | })
230 |
231 | stopBtn.stop.click(() => {
232 | toast('停止所有任务')
233 | threads.shutDownAll()
234 | task.switch = false
235 | })
236 |
237 | //by 坛友mouse040429
238 | const nextBtn = floaty.window(
239 |
240 |
241 |
242 | )
243 | nextBtn.setPosition(150, 300)
244 | nextBtn.stop.click(() => {
245 | task.btnIndex++
246 | toast('成功跳过任务,当前任务序列' + task.btnIndex)
247 | })
248 |
249 | threads.start(function () {
250 | task.start()
251 | })
252 |
253 | setInterval(() => {}, 500)
254 |
--------------------------------------------------------------------------------