forked from maybe1229/jd-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_sharecodes.sh
190 lines (165 loc) · 5.27 KB
/
export_sharecodes.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
#!/usr/bin/env bash
## Author: Evine Deng
## Source: https://github.com/EvineDeng/jd-base
## Modified: 2020-12-26
## Version: v3.1.3
## 文件路径、脚本网址、文件版本以及各种环境的判断
if [ -f /proc/1/cgroup ]
then
isDocker=$(cat /proc/1/cgroup | grep docker)
else
isDocker=""
fi
if [ -z "${isDocker}" ]
then
ShellDir=$(cd $(dirname $0); pwd)
else
ShellDir=${JD_DIR}
fi
LogDir=${ShellDir}/log
ScriptsDir=${ShellDir}/scripts
FileConf=${ShellDir}/config/config.sh
DateToday=$(date "+%Y-%m-%d")
isTermux=${ANDROID_RUNTIME_ROOT}${ANDROID_ROOT}
if [[ ${isTermux} ]]
then
Opt="P"
else
Opt="E"
fi
## 东东小窝,一天一变
function Cat_ScodesSmallHome {
cd ${LogDir}/jd_small_home
if [[ $(ls -r | grep "${DateToday}") != "" ]]; then
for log in $(ls -r | grep "${DateToday}")
do
ScodesSmallHome=$(grep -${Opt} "开始【京东账号|您的东东小窝shareCode|cookie已失效" ${log} | perl -pe "{s|\*+\n|:|g; s|您的.+:【||g; s|\*+开始||g; s|】$||g}")
[ -n "${ScodesSmallHome}" ] && break
done
fi
}
## 东东农场
function Cat_ScodesFruit {
cd ${LogDir}/jd_fruit
for log in $(ls -r)
do
ScodesFruit=$(grep -${Opt} "的东东农场好友互助码" ${log} | perl -pe "s|的东东农场好友互助码||g" | uniq)
[ -n "${ScodesFruit}" ] && break
done
}
## 东东萌宠
function Cat_ScodesPet {
cd ${LogDir}/jd_pet
for log in $(ls -r)
do
ScodesPet=$(grep -${Opt} "的东东萌宠好友互助码" ${log} | perl -pe "s|的东东萌宠好友互助码||g" | uniq)
[ -n "${ScodesPet}" ] && break
done
}
## 种豆得豆
function Cat_ScodesBean {
cd ${LogDir}/jd_plantBean
for log in $(ls -r)
do
ScodesBean=$(grep -${Opt} "的京东种豆得豆好友互助码" ${log} | perl -pe "s|的京东种豆得豆好友互助码||g" | uniq)
[ -n "${ScodesBean}" ] && break
done
}
## 京喜工厂
function Cat_ScodesJx {
cd ${LogDir}/jd_dreamFactory
for log in $(ls -r)
do
ScodesJx=$(grep -${Opt} "的京喜工厂好友互助码" ${log} | perl -pe "s|的京喜工厂好友互助码||g" | uniq)
[ -n "${ScodesJx}" ] && break
done
}
## 东东工厂
function Cat_ScodesDd {
cd ${LogDir}/jd_jdfactory
for log in $(ls -r)
do
ScodesDd=$(grep -${Opt} "的东东工厂好友互助码" ${log} | perl -pe "s|的东东工厂好友互助码||g" | uniq)
[ -n "${ScodesDd}" ] && break
done
}
## 疯狂的JOY
function Cat_ScodesJoy {
cd ${LogDir}/jd_crazy_joy
for log in $(ls -r)
do
ScodesJoy=$(grep -${Opt} "的crazyJoy任务好友互助码" ${log} | perl -pe "s|的crazyJoy任务好友互助码||g" | uniq)
[ -n "${ScodesJoy}" ] && break
done
}
## 京东赚赚
function Cat_ScodesZz {
cd ${LogDir}/jd_jdzz
for log in $(ls -r)
do
ScodesZz=$(grep -${Opt} "的京东赚赚好友互助码" ${log} | perl -pe "s|的京东赚赚好友互助码||g" | uniq)
[ -n "${ScodesZz}" ] && break
done
}
## 健康抽奖机,短期
function Cat_ScodesHealth {
cd ${LogDir}/jd_health
for log in $(ls -r)
do
ScodesHealth=$(grep -${Opt} "开始【京东账号|您的健康抽奖机好友助力邀请码|cookie已失效" ${log} | uniq | perl -pe "{s|您的健康抽奖机好友助力邀请码||g; s|\*+开始||g; s|\*+\n||g}")
[ -n "${ScodesHealth}" ] && break
done
}
## 京东健康,短期
function Cat_ScodesJdh {
cd ${LogDir}/jd_jdh
for log in $(ls -r)
do
ScodesJdh=$(grep -${Opt} "开始【京东账号|您的分享助力码为|cookie已失效" ${log} | uniq | perl -pe "{s|您的分享助力码为||g; s|\*+开始||g; s|\*+\n||g}")
[ -n "${ScodesJdh}" ] && break
done
}
## 汇总
function Cat_All {
echo "东东小窝(一天一变):"
Cat_ScodesSmallHome
if [ -n "${ScodesSmallHome}" ]
then
echo -e "${ScodesSmallHome}\n"
else
echo -e "东东小窝互助码一天一变,未检测到今天的日志...\n"
fi
echo "东东农场(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesFruit
echo -e "${ScodesFruit}\n"
echo "东东萌宠(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesPet
echo -e "${ScodesPet}\n"
echo "种豆得豆(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesBean
echo -e "${ScodesBean}\n"
echo "京喜工厂(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesJx
echo -e "${ScodesJx}\n"
echo "东东工厂(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesDd
echo -e "${ScodesDd}\n"
echo "疯狂的JOY(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesJoy
echo -e "${ScodesJoy}\n"
echo "京东赚赚(缺失的账号意味着在最近一次运行日志中Cookie是失效状态):"
Cat_ScodesZz
echo -e "${ScodesZz}\n"
echo "健康抽奖机(短期):"
Cat_ScodesHealth
echo -e "${ScodesHealth}\n"
echo "京东健康(短期):"
Cat_ScodesJdh
echo -e "${ScodesJdh}\n"
}
## 执行并写入日志
LogTime=$(date "+%Y-%m-%d-%H-%M-%S")
LogFile="${LogDir}/export_sharecodes/${LogTime}.log"
[ ! -d "${LogDir}/export_sharecodes" ] && mkdir -p ${LogDir}/export_sharecodes
touch ${LogFile}
Cat_All | perl -pe "s| |\n|g" | tee ${LogFile}