1 Star 0 Fork 0

TABball/ZJU Heath Report Extension in VSCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
DK.js 3.01 KB
一键复制 编辑 原始数据 按行查看 历史
TABball 提交于 2022-01-14 14:17 . version 1.0
const vscode = require("vscode");
const request = require("request");
var DKData = require("./data.js");
function DK(response, my_jar, headers) {
return new Promise((resolve) => {
if (response.body.search("hasFlag: '1'") != -1) {
vscode.window.showInformationMessage('今日已打卡,不需要再次打卡');
resolve();
} else {
// 今天还没打卡
if (response.body.match(/getdqtlqk/g).length != 15 ||
response.body.match(/</g).length != 1251 ||
response.body.match(/active/g).length != 72) {
vscode.window.showErrorMessage("表单已修改,请自行填报或通知开发者");
resolve();
}
var data = DKData.configure;
var area = vscode.workspace.getConfiguration("zjuhealthreport").get("area");
var province = area.split(" ")[0];
var city = area.split(" ")[1];
var id = response.body.match(/"id":"?(\d*)"?,/g)[0];
var uid = response.body.match(/"uid":"?(\d*)"?,/g)[0];
var date = response.body.match(/"date":"?(\d*)"?,/g)[0];
var created = response.body.match(/"created":"?(\d*)"?,/g)[0];
// 修改数据
data["area"] = area;
data["province"] = province;
data["city"] = city;
data["uid"] = uid;
data["id"] = id;
data["date"] = date;
data['created'] = created;
// 填报数据
var data2 = {
'error': '{"type":"error","message":"Get geolocation time out.Get ipLocation failed.","info":"FAILED","status":0}'
}
// progress.report({ increment: 40, message: "正在发送打卡数据" });
vscode.window.showInformationMessage("正在发送打卡数据");
setTimeout(() => {
request({
url: 'https://healthreport.zju.edu.cn/ncov/wap/default/save-geo-error',
method: 'POST',
headers: headers,
jar: my_jar,
form: data2
}, (error, response) => {
setTimeout(() => {
request({
url: 'https://healthreport.zju.edu.cn/ncov/wap/default/save',
method: 'POST',
headers: headers,
jar: my_jar,
form: data
}, (error, response) => {
if (response.body.search('"e":0') != -1) {
vscode.window.showInformationMessage("打卡成功");
} else {
vscode.window.showErrorMessage("打卡失败");
}
resolve();
})
}, 3000)
})
}, 3000)
}
})
}
exports.DK = DK;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tabball/zju-heath-report-extension-in-vscode.git
git@gitee.com:tabball/zju-heath-report-extension-in-vscode.git
tabball
zju-heath-report-extension-in-vscode
ZJU Heath Report Extension in VSCode
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385