Greasy Fork is available in English.

QingJiaoHelper

青骄第二课堂小助手: 2024 知识竞赛 | 跳过视频 | 自动完成所有课程 | 领取每日学分 | 课程自动填充答案

< 脚本QingJiaoHelper的反馈

评价:好评 - 脚本运行良好

§
发表于:2023-12-06
编辑于:2023-12-06

不能自动答题,这是什么问题?

FoliageOwO作者
§
发表于:2023-12-06

看报错应该是你没登录账号,或者是token失效了。的确有确实登上了账号但报错未登录的情况,试试重新登录账号然后再答题。

§
发表于:2023-12-06

账号是登录的

§
发表于:2023-12-14

async function requestAPI(api, params, data) {
const method = api.method;
const origin = "https://www.2-class.com";
let url = `${origin}/api${api.api}`;

// Replace URL placeholders with actual values
for (const key in params) {
url = url.replaceAll("${" + key + "}", params[key]);
}

// Retrieve browser cookies
const cookies = document.cookie;

if (method === "GET") {
return await axios({
method: "GET",
url,
withCredentials: true, // Include cookies in the request
headers: {
Cookie: cookies, // Pass the cookies in the headers
},
}).then((response) => {
const rdata = response.data;
console.debug(`[${method}] ${url}`, data, rdata);

if (rdata.success === false || rdata.data === null) {
const errorMessage = rdata.errorMsg;
const errorCode = rdata.errorCode;
console.error(`API 返回错误 [${errorCode}]:${errorMessage},请刷新页面重试!`);
return null;
} else {
return rdata;
}
}).catch((reason) => {
showMessage(`请求 API 失败(${reason.code}):${reason.message}\n请将控制台中的具体报错提交!`, "red");
console.error(`请求失败(${reason.status}/${reason.code})→${reason.message}→`, reason.toJSON(), reason.response, reason.stack);
});
} else {
return await axios({
method: "POST",
url,
withCredentials: true, // Include cookies in the request
headers: {
"Content-Type": "application/json;charset=UTF-8",
Cookie: cookies, // Pass the cookies in the headers
},
data,
}).then((response) => {
const rdata = response.data;
console.debug(`[${method}] ${url}`, data, rdata);

if (rdata.success === false || rdata.data === null) {
const errorMessage = rdata.errorMsg;
const errorCode = rdata.errorCode;
console.error(`API 返回错误 [${errorCode}]:${errorMessage},请刷新页面重试!`);
return null;
} else {
return rdata;
}
});
}
}把60行的函数改成这个,这脚本默认请求不带cookie

发表回复

登录以发表回复。