-
Notifications
You must be signed in to change notification settings - Fork 6
/
galex_bind.js
239 lines (208 loc) · 9.5 KB
/
galex_bind.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
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
// ==UserScript==
// @name Galxe自动化任务
// @namespace http://tampermonkey.net/
// @version 2024-09-04
// @description Galxe自动化任务
// @author You
// @match https://app.galxe.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=galxe.com
// @grant none
// @tag Galxe
// ==/UserScript==
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function findButtonElementByText(text) {
let tweetButtonList = document.querySelectorAll('button');
for (let tweetButtonIndex of tweetButtonList) {
let tweetButtonText = tweetButtonIndex.innerText;
if (tweetButtonText.startsWith(text)) {
return tweetButtonIndex;
}
}
return null;
}
function findButtonElementByIncludeText(text) {
let tweetButtonList = document.querySelectorAll('button');
for (let tweetButtonIndex of tweetButtonList) {
let tweetButtonText = tweetButtonIndex.innerText;
if (tweetButtonText.indexOf(text) >= 0) {
return tweetButtonIndex;
}
}
return null;
}
function checkClaim() {
console.log('Galxe自动化任务交互脚本领取结果');
let claimButton = findButtonElementByIncludeText('Claim');
if (claimButton) {
console.log('Galxe自动化任务交互脚本领取结果中');
claimButton.click();
}
console.log('Galxe自动化任务交互脚本结束');
}
async function checkAllTaskState() {
let currentURL = window.location.href;
if (currentURL.startsWith('https://app.galxe.com/quest/')) {
console.log('Galxe自动化任务检查所有结果中');
let taskButtonList = document.querySelectorAll('div[type="button"]');
for (let taskButtonIndex of taskButtonList) {
// 任务完成后自动点击刷新状态
console.log(taskButtonIndex.querySelectorAll('button'));
try {
let subButtonList = taskButtonIndex.querySelectorAll('button');
let refreshTaskState = subButtonList[subButtonList.length - 1];
refreshTaskState.click();
await delay(500);
} catch(e) {}
}
}
}
async function mainLogic() {
console.log("Galxe自动化插件加载");
let currentURL = window.location.href;
if (currentURL == 'https://app.galxe.com/accountSetting/social') {
let connectButton = document.querySelectorAll('button.text-text-linkBase');
console.log('Galxe自动化社交设置脚本启动');
for (let connectButtonIndex of connectButton) {
let connectButtonText = connectButtonIndex.innerText;
//console.log('Galxe自动化社交设置脚本 == 发现按钮',connectButtonText);
if (connectButtonText.indexOf('Connect Twitter') >= 0) {
console.log('Galxe自动化社交设置脚本 == 连接推特准备');
setTimeout(() => {
connectButtonIndex.click();
}, 2000);
break;
} else if (connectButtonText.indexOf('Connect Discord') >= 0) {
console.log('Galxe自动化社交设置脚本 == 连接DC准备');
setTimeout(() => {
connectButtonIndex.click();
}, 2000);
break;
}
}
console.log('Galxe自动化社交设置脚本结束');
} else if (currentURL == 'https://app.galxe.com/TwitterConnect') {
let tweetButtonList = document.querySelectorAll('button.text-foreground');
console.log('Galxe自动化社交设置推特脚本启动');
for (let tweetButtonIndex of tweetButtonList) {
let tweetButtonText = tweetButtonIndex.innerText;
//console.log('Galxe自动化社交设置推特脚本 == 发现按钮',tweetButtonText);
if (tweetButtonText.indexOf('Tweet') >= 0) {
console.log('Galxe自动化社交设置推特脚本 == 点击准备');
setTimeout(() => {
tweetButtonIndex.click();
}, 2000);
await delay(3000);
let retweetURL = await window.getFirstTweet();
if (retweetURL !== null) {
console.log('Galxe自动化社交设置推特脚本 == 推特URL',retweetURL);
let inputList = document.querySelectorAll('input');
inputList[0].value = retweetURL;
var event = new Event('input', { bubbles: true });
inputList[0].dispatchEvent(event);
await delay(500);
let buttonList = document.querySelectorAll('button');
for (let buttonIndex of buttonList) {
let buttonText = buttonIndex.innerText;
if (buttonText.startsWith('Verify')) {
buttonIndex.click();
break;
}
}
} else {
console.log('Galxe自动化社交设置推特脚本 == 找不到发布推特URL');
}
}
}
console.log('Galxe自动化社交设置推特脚本结束');
} else if (currentURL.startsWith('https://app.galxe.com/quest/')) {
await delay(5000);
console.log('Galxe自动化任务交互脚本启动');
let taskButtonList = document.querySelectorAll('div[type="button"]');
for (let taskButtonIndex of taskButtonList) {
let taskButtonText = taskButtonIndex.innerText.toLowerCase();
console.log('Galxe 任务名称' + taskButtonText);
// 任务已完成就退出
if (taskButtonIndex.querySelectorAll('div.text-success').length > 0) {
console.log('Galxe自动化任务交互脚本(已完成) == ',taskButtonText);
continue;
}
// 推特系列任务
if (taskButtonText.indexOf('twitter') >= 0 || taskButtonText.indexOf('tweet') >= 0) {
console.log('Galxe自动化任务交互脚本(开始) == 推特交互',taskButtonText);
// 2024/9/4
taskButtonIndex.click();
await delay(1000);
}
// DC系列任务
if (taskButtonText.indexOf('discord') >= 0) {
console.log('Galxe自动化任务交互脚本(开始) == DC交互',taskButtonText);
taskButtonIndex.click();
await delay(1000);
// 有概率是假验证,反正先点一遍
window.focus();
}
// 查看官网
else if (taskButtonText.indexOf('visit') >= 0) {
console.log('Galxe自动化任务交互脚本(开始) == 查看官网',taskButtonText);
taskButtonIndex.click();
await delay(500);
// 银河弹窗二次确认
let continueButtonList = document.querySelectorAll('div.cursor-pointer.text-black');
continueButtonList[0].click();
}
// 查看视频
else if (taskButtonText.indexOf('watch') >= 0) {
console.log('Galxe自动化任务交互脚本(开始) == 查看视频',taskButtonText);
taskButtonIndex.click();
await delay(3000);
let closeButton = findButtonElementByText('Close');
closeButton.close();
}
// 关注银河频道
else if (taskButtonText.indexOf('space user') >= 0) {
console.log('Galxe自动化任务交互脚本(开始) == 关注银河频道',taskButtonText);
let currentURL = window.location.href;
let projectRootURL = currentURL.substring(0,currentURL.lastIndexOf("/"));
let popup = window.open(
projectRootURL,
"_blank"
);
}
}
console.log('Galxe自动化任务交互脚本关注频道启动');
let followButton = findButtonElementByIncludeText('Follow');
if (followButton) { // 只有出现的项目主页里面
console.log('Galxe自动化任务交互脚本关注频道中');
followButton.click();
await delay(3000);
window.close();
} else { // 出现在任务页里面
await checkAllTaskState();
}
// 一直判断是否可以Claim
setInterval(() => {
checkClaim();
}, 2000);
}
}
(function() {
'use strict';
let timerID = setInterval(async () => {
let userLink = document.querySelector('button>a').href;
if (userLink) {
if (userLink.startsWith('https://app.galxe.com/id/') || userLink.startsWith('https://app.galxe.com/quest/')) { // 2024/12/14
let lastPath = userLink.split('/');
if (lastPath[lastPath.length - 1] !== "undefined") { // 2024/9/9 当账号加载完成之后,链接URL就会更新
mainLogic();
clearInterval(timerID);
}
}
}
}, 1000);
// window.addEventListener('load',mainLogic);
// ^ 2024/9/9 旧版启动代码,但是银河是Load之后异步加载的,高配置机器执行没有问题
// 但是低配置云主机有问题,未成功加载用户信息就去点任务会弹出连接钱包,实际上已经
// 连接上了.所以需要判断加载完成账号才可以操作
})();