Skip to content

Instantly share code, notes, and snippets.

@Murlors
Last active January 7, 2026 15:11
Show Gist options
  • Select an option

  • Save Murlors/f98cb9bf6f9135d3496a0a30892628cc to your computer and use it in GitHub Desktop.

Select an option

Save Murlors/f98cb9bf6f9135d3496a0a30892628cc to your computer and use it in GitHub Desktop.
PJSK Token Capture Script
/**
* PJSK Token Capture Script
* Auto-generated by SnowyBot Backend
*/
const UPLOAD_URL = "https://getsekaigacha.exmeaning.com/api/sync";
const headers = $request.headers;
function getHeader(key) {
const k = Object.keys(headers).find(
(h) => h.toLowerCase() === key.toLowerCase()
);
return k ? headers[k] : null;
}
const token = getHeader("X-User-Token") || getHeader("x-web-token");
const roleId = getHeader("X-Role-ID") || getHeader("x-role-id");
if (token && roleId) {
console.log("[PJSK] Token captured, uploading...");
const payload = {
token: token,
role_id: roleId,
};
console.log("payload:" + JSON.stringify(payload));
$task
.fetch({
url: UPLOAD_URL,
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
})
.then((response) => {
console.log("[PJSK] Upload response received", JSON.stringify(response));
let data = response.body;
console.log("data:" + JSON.stringify(data));
const { error, body } = response;
if (error) {
$notification.post("PJSK抽卡数据已上传", "数据处理中", "by Snowybot");
} else {
// 解析服务器返回的 json 看看是否成功
try {
const res = JSON.parse(body);
if (res.success) {
if (res.message !== "skipped (throttled)") {
$notification.post(
"PJSK抽卡数据上传成功",
"数据已上传",
"by Snowybot"
);
}
// 如果是防抖跳过,静默处理,不弹窗
} else {
$notification.post(
"PJSK抽卡数据上传失败",
"服务端错误",
res.message || "未知错误"
);
}
} catch (e) {
$notification.post(
"PJSK抽卡数据上传成功",
"数据已发送",
"by Snowybot"
);
}
}
});
}
$done({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment