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
| let domain = "69yun69.com"; let user = "你的邮箱"; let pass = "你的密码";
let 签到结果;
export default {
async fetch(request, env, ctx) {
await initializeVariables(env); const url = new URL(request.url);
try {
if (url.pathname == `/${pass}`) { await retryCheckin(); }
} catch (error) {
签到结果 = `❌ 执行失败\n${error.message}`;
}
return new Response(签到结果, { status: 200, headers: { "Content-Type": "text/plain;charset=UTF-8" } }); },
async scheduled(event, env, ctx) {
console.log("Cron job started");
ctx.waitUntil((async () => {
try {
await initializeVariables(env);
await retryCheckin();
console.log("Cron job finished");
} catch (error) {
console.error(error);
签到结果 = `❌ 定时任务失败\n${error.message}`;
}
})());
} };
async function initializeVariables(env) {
domain = env.JC || env.DOMAIN || domain; user = env.ZH || env.USER || user; pass = env.MM || env.PASS || pass;
if (!domain.includes("//")) domain = `https://${domain}`;
签到结果 = `地址: ${domain.substring(0,9)}****${domain.slice(-5)}\n` + `账号: ${user.substring(0,1)}****${user.slice(-5)}\n` + `密码: *******\n\n`; }
async function retryCheckin() {
const maxRetry = 3;
for (let i = 1; i <= maxRetry; i++) {
try {
console.log(`签到尝试 ${i}/${maxRetry}`);
await checkin();
return;
} catch (error) {
console.log(`尝试 ${i} 失败:`, error.message);
if (i === maxRetry) {
throw error;
}
await sleep(3000);
}
} }
async function checkin() {
console.log("===== 开始签到 =====");
const loginResponse = await fetch(`${domain}/auth/login`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "User-Agent": "Mozilla/5.0", "X-Requested-With": "XMLHttpRequest", "Origin": domain, "Referer": `${domain}/auth/login`, "Accept": "application/json, text/javascript, */*; q=0.01" },
body: `email=${encodeURIComponent(user)}&passwd=${encodeURIComponent(pass)}&remember_me=on&code=`,
cf: { cacheTtl: 0, cacheEverything: false }
});
const loginText = await loginResponse.text();
let loginJson;
try {
loginJson = JSON.parse(loginText);
} catch {
throw new Error("登录返回异常");
}
if (!loginJson || loginJson.ret !== 1) {
throw new Error("登录失败");
}
const rawCookies = loginResponse.headers.get("set-cookie");
if (!rawCookies) {
throw new Error("未获取Cookie");
}
const cookies = rawCookies .split(/,(?=\s*\w+=)/) .map(c => c.split(";")[0]) .join("; ");
const checkinResponse = await fetch(`${domain}/user/checkin`, {
method: "POST",
headers: { "Cookie": cookies, "User-Agent": "Mozilla/5.0", "X-Requested-With": "XMLHttpRequest", "Referer": `${domain}/user`, "Origin": domain, "Accept": "application/json, text/javascript, */*; q=0.01" },
cf: { cacheTtl: 0, cacheEverything: false }
});
const text = await checkinResponse.text();
console.log("Checkin response:", text);
let json;
try {
json = JSON.parse(text);
} catch {
throw new Error("签到返回异常");
}
if (!json.msg) {
throw new Error("服务器未返回签到信息");
}
if ( json.msg.includes("已经") || json.msg.includes("重复") || json.msg === "签到执行完成" ) { 签到结果 = `⚠️ 今日已经签到\n${json.msg}`; return; }
签到结果 = `🎉 签到成功\n${json.msg}`;
console.log("签到成功");
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
|