-
Notifications
You must be signed in to change notification settings - Fork 42
/
0.sh
executable file
·334 lines (305 loc) · 8.27 KB
/
0.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/usr/bin/env bash
{
root=$(dirname "$0")
init() {
declare -A serial
# serial=([k40]=df7592c8 [l]=localhost:5555 [z9]=z9:5555 [z9v]=z9:5667 )
# export ANDROID_SERIAL=${serial[${1:-l}]}
export ANDROID_SERIAL=$1
adb forward --remove tcp:9095
adb forward --remove tcp:9090
adb forward tcp:9095 tcp:9095
adb forward tcp:9090 tcp:9090
}
restartcolor() { # 重启节点精灵,以适应分辨率变更
adb shell am force-stop com.aojoy.aplug
sleep 1
# === no need to start from launcher
adb shell monkey -p com.aojoy.aplug -c android.intent.category.LAUNCHER 1
sleep 1
# === to find the service name
# adb shell dumpsys activity services aojoy
# com.aojoy.aplug/com.aojoy.server.CmdAccessibilityService
# adb shell settings put secure enabled_accessibility_services com.aojoy.aplug/com.aojoy.server.floatwin.FloatService
# adb shell settings put secure enabled_accessibility_services com.aojoy.aplug/com.aojoy.server.CmdAccessibilityService
# adb shell settings put secure enabled_accessibility_services com.aojoy.aplug/com.aojoy.server.CmdService
# sleep 2
# adb shell am start com.hypergryph.arknights
# adb shell input keyevent KEYCODE_APP_SWITCH
# adb shell input keyevent KEYCODE_APP_SWITCH
#adb shell monkey -p com.hypergryph.arknights -c android.intent.category.LAUNCHER 1
# sleep 2
}
remove() {
curl 'http://localhost:9090/script/del?name=test' -X 'POST'
}
beta() {
release 'script.lr.beta'
}
extract() {
rm -rf arknights
rm -rf arknights_extract
unzip ${1:-arknights.apk} -d arknights
./extract.py unpack
}
release() {
# local lr=docs/.vuepress/public/${1:-script.lr}
local lr=release/${1:-script.lr}
git add -u
# cd release
cp /F/software/懒人精灵3.8.3/out/main.lr $lr
# cp ../README.md README.md
numfmt --to=iec $(stat -c %s $lr)
local md5=$(md5sum $lr | cut -d' ' -f1)
echo $md5 >$lr.md5
cp $lr release/${lr##*/}
cp $lr.md5 release/${lr##*/}.md5
git -C release add -u
git -C release commit --amend --allow-empty-message -m ""
git -C release push --force
cp ../dlt/dlt.py dlt.py
git add -u
git status
# # ==== 用js后缀会变快吗,不会
# cp $lr $lr.js
# cp $lr.md5 $lr.md5.js
# git add -A
# git commit --amend --date=now -m "$md5"
# git push --force
}
stop() {
i3-msg 'focus left'
xte 'keydown F6'
xte 'keyup F6'
i3-msg 'focus left'
}
findr() {
# 测试不同分辨率下脚本结果
local option=(
1080x2400
720x1280
1080x1920
1080x2340
)
if [[ -n $1 ]]; then
option=(${option[$1]})
shift
fi
for ((i = 0; i < ${#option[@]}; ++i)); do
adb shell wm size ${option[$i]}
# restartcolor "$@"
# if [[ $i -eq 0 ]]; then
# save "$@"
# fi
# run "$@"
done
}
run() {
i3-msg 'focus left'
xte 'keydown F6'
xte 'keyup F6'
sleep .1
xte 'keydown F5'
xte 'keyup F5'
i3-msg 'focus left'
}
save() {
sed -i -r 's/^(release_date =).+$/\1 "'"$(date +'%m.%d %k:%M')"'"/' main.lua
local dst_dir=/F/software/懒人精灵3.6.0/script/main
dst="$dst_dir"/脚本
mkdir -p $dst
while IFS= read -r -d '' f; do
iconv -f UTF-8 -t GB18030 "$f" -o "$dst/$f"
done < <(find . -maxdepth 1 -type f -name '*.lua' -printf '%P\0')
dst="$dst_dir"/界面
mkdir -p $dst
while IFS= read -r -d '' f; do
iconv -f UTF-8 -t GB18030 "$f" -o "$dst/$f"
done < <(find . -maxdepth 1 -type f -name '*.ui' -printf '%P\0')
}
saverun() {
save
run
}
timer() {
local start=$(date +"%s.%N" -d "${1:-now}")
local cur
while :; do
cur=$(date +"%s.%N")
printf "\r$(date -d "0 $cur seconds - $start seconds" +"%H:%M:%S")"
sleep 1
done
}
scrcpy() {
scrcpy "$@"
}
png2rgb() {
convert "$1" txt:- | tail -n +2 | sed -nr 's/.*(#.{6}).*/\1/p'
}
png2alpha() {
convert "$1" txt:- | tail -n +2 | sed -nr 's/.*,([^,]+)\)$/\1/p'
}
dim() {
# make dim version of skill icon
local src=${1:-png}
local dst=${2:-png_noalpha_dim}
mkdir -p "$dst"
mogrify -path "$dst" -alpha set -channel A -evaluate multiply 0.4 +channel -alpha remove -alpha off -background '#202020' "$src"/'*.png'
}
noalpha() {
# make noalpha version of skill icon
local src=${1:-png}
local dst=${2:-png_noalpha}
mkdir -p "$dst"
# mogrify -path "$dst" -alpha remove -alpha off -background '#3D3D3D' "$src"/'*.png'
mogrify -path "$dst" -alpha remove -alpha off -background '#3D3D3D' "$src"/'*'.png
}
noalphaavatar() {
# make noalpha version of avatar icon
local src=${1:-'arknights_extract/assets/torappu/dynamicassets/arts/charavatars'}
local dst=${2:-png_noalpha}
mkdir -p "$dst"
for x in $src/'char_*' $src/skins/'char_*.png' $src/elite/'char_*.png'; do
mogrify -path "$dst" -alpha remove -alpha off -background '#FFFFFF' -resize 36x36 "$x"
done
}
fetchbuildingskill() {
echo "deprecated, use buildingskill instead"
exit
local a="
prts.wiki/images/d/d9/Bskill_meet_spd2.png
prts.wiki/images/a/a0/Bskill_meet_spd1.png
"
rm -rf png
rm -rf png_noalpha
rm -rf release/skill.zip
mkdir -p png
cd png
xargs -I % -P 100 curl -sSLO % <<<"$a"
cd ..
noalpha png png_noalpha
touch png_noalpha/.nomedia
zip release/skill.zip -q -r -j png_noalpha
local md5=$(md5sum release/skill.zip | cut -d' ' -f1)
echo $md5 >release/skill.zip.md5
}
buildingskill() {
# local png=$root/arknights_extract/assets/torappu/dynamicassets/arts/building/skills
local png='../ArkAssetsTool/ArkAssets/spritepack/[unpack]building_ui_buff_skills_h1_0'
# ==> paint background
local png_noalpha=png_noalpha
rm -rf $png_noalpha
mkdir $png_noalpha
noalpha $png $png_noalpha
# ==> remove prefix
while IFS= read -r -d '' f; do
mv $png_noalpha/"$f" $png_noalpha/"${f#(Sprite)}"
done < <(find $png_noalpha -maxdepth 1 -type f -printf '%P\0')
# ==> only bskill
find $png_noalpha -type f -not -name 'bskill_*' -delete
echo -n "==> total "
ls $png_noalpha | wc -l
touch $png_noalpha/.nomedia
# git submodule update --init --recursive --remote
./extract.py skillicon2operator >$png_noalpha/skillicon2operator.json
# local skill=docs/.vuepress/public/skill.zip
local skill=dist/skill.zip
mkdir -p "$(dirname "$skill")"
rm -rf $skill
zip $skill -q -r -j $png_noalpha
local md5=$(md5sum $skill | cut -d' ' -f1)
echo $md5 >$skill.md5
cp $skill release/${skill##*/}
cp $skill.md5 release/${skill##*/}.md5
}
recruit() {
./extract.py recruit
}
# ==== 华云外置保活
hy() {
# for x in "$@"; do
local x=$1
[[ -z $x ]] && continue
# echo === $x
adb connect $x >/dev/null
adb -s $x shell "nohup sh -c 'nc -klp49876 -e sh' > /dev/null 2>&1 &"
# done
}
# === adb 修改模式
dlt() {
../dlt/dlt.py dlt
}
m() {
../dlt/dlt.py mode "$@"
}
u() {
../dlt/dlt.js upload --search=$1' ' --path=$D/qq.jpg
}
d() {
# ./dlt.js detail --search=$1' '
../dlt/dlt.py DLT detail "$1"
}
o() {
# ./dlt.js order --search=$1' '
../dlt/dlt.py DLT order "$@"
}
submit() {
# ./dlt.js order --search=$1' '
../dlt/dlt.py DLT submit "$@"
}
first() {
../dlt/dlt.py DLT first "$@"
}
last() {
../dlt/dlt.py DLT last "$@"
}
over() {
../dlt/dlt.py DLT over "$1"
}
my() {
../dlt/dlt.py DLT my "$@"
}
count() {
../dlt/dlt.py DLT count "$@"
}
check() {
../dlt/dlt.py check "$@"
}
users() {
../dlt/dlt.py users "$@"
}
serial() {
../dlt/dlt.py DLT all2serial $@
}
edu() {
../dlt/dlt.py edu $@
}
daily() {
../dlt/dlt.py daily $@
}
a() {
../dlt/dlt.py account_exist "$@"
}
g() {
# restart genymotion every 8 hours
while :; do
for ((i = 0; i < 3; ++i)); do
genymotion-player --vm-name 8 &
sleep 5
genymotion-player --vm-name 8 --poweroff
sleep 1
done
genymotion-player --vm-name 8 &
echo == 1
adb connect 127.0.0.1:5555
adb -s 127.0.0.1:5555 wait-for-device
echo == 2
0 m 0 rg2
echo == 3
sleep $((3600*4))
done
}
"$@"
wait
exit 0
}