This commit is contained in:
Qiuyelin 2022-09-06 13:25:06 +08:00
parent 3116a0ddaa
commit 146c453436
4 changed files with 55 additions and 16 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
build
dist
*.spec

View File

@ -2,10 +2,34 @@
安全微伴自动刷课助手
[原项目](https://github.com/Coaixy/weiban-tool)作者已停止维护,我在源项目基础上增加多账号的支持
# 使用方法
在main.py中填入tenantCodeuserIdx_tokenuserProjectId四个参数
以`UTF-8`的编码方式创建`config.json`文件。其内容格式如下:
可以通过f12的网络栏获取
> `config.json`
>
> ```json
> [
> {"token":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","userId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","tenantCode":"00000001","userProjectId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},
> {"token":"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy","userId":"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy","tenantCode":"00000002","userProjectId":"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"},
> {"token":"zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz","userId":"zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz","tenantCode":"00000003","userProjectId":"zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"},
> {#第4个账号信息#},
> {#第5个账号信息#},
> ...
> {#第n个账号信息#}
> ]
> ```
由于安全微伴有调试检测,将显示模式切换为手机模式即可
### 说明
1. 首先,<a href="javascript:(function(){data=JSON.parse(localStorage.user);prompt('',JSON.stringify({token:data['token'],userId:data['userId'], tenantCode:data['tenantCode'], userProjectId: data['preUserProjectId']}));})();"><img src="https://img.shields.io/badge/%E8%AF%B7%E5%B0%86%E8%BF%99%E5%BC%A0%E5%9B%BE%E7%89%87%E6%8B%96%E5%85%A5%E6%94%B6%E8%97%8F%E5%A4%B9-informational?style=for-the-badge" /></a>
2. 登录[安全微伴 (mycourse.cn)](http://weiban.mycourse.cn/#/login),在登录后的页面上运行刚才添加进收藏夹的脚本
3. 复制弹窗内的内容,**按照格式**添加到`config.json`。(格式不对会报错)
[![1662441411827.png](http://png.eot.ooo/i/2022/09/06/6316d7c7f3567.png)](http://png.eot.ooo/i/2022/09/06/6316d7c7f3567.png)
4. 运行`main.exe`。

4
config.json Normal file
View File

@ -0,0 +1,4 @@
[
{"token":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","userId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","tenantCode":"00000001","userProjectId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},
{"token":"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy","userId":"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy","tenantCode":"00000002","userProjectId":"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"}
]

33
main.py
View File

@ -1,17 +1,24 @@
# @Author : Coaixy
# @repo : https://www.github.com/coaixy/weiban-tool
# @Author : Qiuyelin
# @repo : https://github.com/pooneyy/weiban-tool
import Utils
import time
import json
# tenantCode UserId x-token userProjectId
tenantCode = 0
userId = ""
x_token = ""
userProjectId = ""
main = Utils.main(tenantCode, userId, x_token, userProjectId)
main.init()
finishIdList = main.getFinishIdList()
for i in main.getCourse():
main.start(i)
time.sleep(20)
main.finish(finishIdList[i])
try:
with open("config.json", "r+", encoding='utf8') as file:
usersConfig = json.load(file)
for user in usersConfig:
tenantCode = user['tenantCode']
userId = user['userId']
x_token = user['token']
userProjectId = user['userProjectId']
main = Utils.main(tenantCode, userId, x_token, userProjectId)
main.init()
finishIdList = main.getFinishIdList()
for i in main.getCourse():
main.start(i)
time.sleep(20)
main.finish(finishIdList[i])
except FileNotFoundError:print('未找到 config.json !')