forked from GH6324/LazyStudy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfloating.js
180 lines (170 loc) · 5.23 KB
/
floating.js
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
toastLog(" 请在无障碍中选择本 APP");
auto.waitFor();
let waysOfShopping = 0;
let window = floaty.window(
<vertical>
<button id="move" text=" 移动 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="switchXX" text=" 切到 学习强国 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="startLL" text=" 开始浏览 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="startSPZ" text=" 收藏评转 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="switchST" text=" 切到 搜题 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="startDT" text=" 挑战答题 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="startMR" text=" 每日答题 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="stop" text=" 停止 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
<button id="exit" text=" 退出悬浮窗 " w="90" h="35" bg="#77ffffff" textSize="10sp" />
</vertical>
);
let deviceWidth = device.width;
let deviceHeight = device.height;
window.setPosition(deviceWidth * 0.6, deviceHeight*0.25);
setInterval(() => {
}, 1000);
let wx, wy, downTime, windowX, windowY;
// 这个函数是对应悬浮窗的移动
window.move.setOnTouchListener(function (view, event) {
switch (event.getAction()) {
case event.ACTION_DOWN:
wx = event.getRawX();
wy = event.getRawY();
windowX = window.getX();
windowY = window.getY();
downTime = new Date().getTime();
return true;
case event.ACTION_MOVE:
// 如果按下的时间超过 xx 秒判断为长按,调整悬浮窗位置
if (new Date().getTime() - downTime > 300) {
window.setPosition(windowX + (event.getRawX() - wx), windowY + (event.getRawY() - wy));
}
return true;
case event.ACTION_UP:
// 手指弹起时如果偏移很小则判断为点击
if (Math.abs(event.getRawY() - wy) < 30 && Math.abs(event.getRawX() - wx) < 30) {
toastLog(" 长按调整位置 ")
}
return true;
}
return true;
});
window.switchXX.click(() => {
toastLog(" 切换到学习强国APP...");
launch("cn.xuexi.android");
});
// 这个函数是对应悬浮窗的退出
window.exit.click(() => {
toastLog(" 退出!");
exit();
});
let th = null;
//切到 搜题
window.switchST.click(() => {
let ss = "./souti.js";
if (th == null) {
th = threads.start(function () {
toastLog(" 开启线程");
let begin = require(ss);
begin();
});
} else {
if (th.isAlive()) {
toastLog(" 脚本都在运行了你还点!?");
} else {
th = threads.start(function () {
let begin = require(ss);
begin();
});
}
}
});
//浏览
window.startLL.click(() => {
let ss = "./liulan.js";
if (th == null) {
th = threads.start(function () {
toastLog(" 开启线程");
let begin = require(ss);
begin();
});
} else {
if (th.isAlive()) {
toastLog(" 脚本都在运行了你还点!?");
} else {
th = threads.start(function () {
let begin = require(ss);
begin();
});
}
}
});
//收藏评论转发
window.startSPZ.click(() => {
let ss = "./shouCangPingZhuan.js";
if (th == null) {
th = threads.start(function () {
toastLog(" 开启线程");
let begin = require(ss);
begin();
});
} else {
if (th.isAlive()) {
toastLog(" 脚本都在运行了你还点!?");
} else {
th = threads.start(function () {
let begin = require(ss);
begin();
});
}
}
});
//挑战答题
window.startDT.click(() => {
let ss = "./dati.js";
if (th == null) {
th = threads.start(function () {
toastLog(" 开启线程");
let begin = require(ss);
begin();
});
} else {
if (th.isAlive()) {
toastLog(" 脚本都在运行了你还点!?");
} else {
th = threads.start(function () {
let begin = require(ss);
begin();
});
}
}
});
//每日答题
window.startMR.click(() => {
let ss = "./meiridati.js";
if (th == null) {
th = threads.start(function () {
toastLog(" 开启线程");
let begin = require(ss);
begin();
});
} else {
if (th.isAlive()) {
toastLog(" 脚本都在运行了你还点!?");
} else {
th = threads.start(function () {
let begin = require(ss);
begin();
});
}
}
});
//停止
window.stop.click(() => {
if (th == null) {
toastLog(" 没有进行中的脚本 ");
} else {
if (th.isAlive()) {
threads.shutDownAll();
toastLog(" 停止!");
} else {
toastLog(" 没有进行中的脚本 ");
}
}
});