Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17b58c7924 | |||
| 4ae5ba1e46 | |||
| d3b85ec361 | |||
| 6234424aa6 | |||
| 2285b3f41e | |||
| 92173c57ec | |||
| 2eb1fbf087 | |||
| 4d92efa48b | |||
| f66b165eb7 | |||
| 5d42062001 | |||
| 234022c80c | |||
| 5ec20fa327 | |||
| 773332f406 | |||
| 46a1339d5c | |||
| ab0a1f2fdd | |||
| 4121fd9ed0 | |||
| 1c04624903 | |||
| 64c906f064 | |||
| 53756f53a7 | |||
| 201dcb9ba5 | |||
| ad36cba92e | |||
| 27dfc7aedb | |||
| c48165cd78 | |||
| 876f49fb25 | |||
| b41b1696fc | |||
| 2bcd3a83e4 | |||
| 9c1db27ebe | |||
| e7effb0881 | |||
| 8146b165f9 | |||
| 55ff6e7a5a | |||
| a29fa0d9c8 | |||
| 0a255f0e51 | |||
| 207bea46ca | |||
| d30e4f0d96 | |||
| d788227ae4 | |||
| 3104ea2b53 | |||
| 0c6ab02e8d | |||
| ccf30c5dca | |||
| 412198358d | |||
| 302006530e | |||
| 7b661965a9 | |||
| 8d8b78c6a1 | |||
| 9b8bab4a92 | |||
| 75834b5cef | |||
| 0e5e3180c9 | |||
| aa9d6dbaf3 | |||
| a4c2ed2463 | |||
| 529c789315 | |||
| 1ef3784e3d | |||
| 07755e81b3 | |||
| 003056192e | |||
| a4d6b581d7 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,4 +1,8 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/.fleet
|
/.fleet
|
||||||
/src/dist/bundle.min.js
|
/src/dist/bundle.min.js
|
||||||
/src/dist/bundle.js
|
/src/dist/bundle.js
|
||||||
|
/dist
|
||||||
|
auto-imports.d.ts
|
||||||
|
components.d.ts
|
||||||
|
aws.xml
|
||||||
6
.idea/jsLibraryMappings.xml
generated
6
.idea/jsLibraryMappings.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="JavaScriptLibraryMappings">
|
|
||||||
<file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
14
.vscode/launch.json
vendored
Normal file
14
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm run rollup",
|
||||||
|
"name": "rollup",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
356
CHANGELOG.md
356
CHANGELOG.md
@ -1,9 +1,357 @@
|
|||||||
# TODO
|
|
||||||
|
|
||||||
- 翻译:baza npc商店、imarket、imarket搜索结果
|
|
||||||
|
|
||||||
# CHANGE
|
# CHANGE
|
||||||
|
|
||||||
|
## 1.2.4
|
||||||
|
|
||||||
|
2025年04月07日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 优化起飞功能错误处理
|
||||||
|
- 取消网络拦截,避免官方功能被影响
|
||||||
|
|
||||||
|
## 1.2.3
|
||||||
|
|
||||||
|
2025年03月11日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 删除GS Load模块代码
|
||||||
|
- 删除翻译
|
||||||
|
- 删除去Google化部分代码
|
||||||
|
- 修复起飞逻辑
|
||||||
|
- 修复通知
|
||||||
|
|
||||||
|
## 1.2.2
|
||||||
|
|
||||||
|
2024年04月07日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 快捷动作【REFILL】修复
|
||||||
|
|
||||||
|
## 1.2.1
|
||||||
|
|
||||||
|
2024年04月03日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 快捷动作【REFILL】修复
|
||||||
|
|
||||||
|
## 1.2.0
|
||||||
|
|
||||||
|
2024年03月29日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- BS估算缓存机制修复
|
||||||
|
- 快捷功能【快速犯罪】界面优化
|
||||||
|
|
||||||
|
## 1.1.9
|
||||||
|
|
||||||
|
2024年03月27日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 引入了BS估算功能
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 快捷功能【快速犯罪】去除了烦人的通知
|
||||||
|
|
||||||
|
## 1.1.8
|
||||||
|
|
||||||
|
2024年03月20日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 快捷功能的【喝啤酒】移动至【快速犯罪】中
|
||||||
|
- profile页面中在线状态调整
|
||||||
|
|
||||||
|
## 1.1.7
|
||||||
|
|
||||||
|
2024年03月15日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 快捷功能-PI存钱
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 上次动作的url判断修复
|
||||||
|
- profile页面中添加了更明显的上次动作时间
|
||||||
|
- 快速取钱功能添加了常用输入
|
||||||
|
|
||||||
|
## 1.1.6
|
||||||
|
|
||||||
|
2024年01月08日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- refill功能改为菜单式,新增支持3种refil
|
||||||
|
- 快速犯罪功能现已支持全部种类
|
||||||
|
|
||||||
|
## 1.1.5
|
||||||
|
|
||||||
|
2023年12月22日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 圣诞小镇掉落物记录表格中的undefined错误修复
|
||||||
|
|
||||||
|
## 1.1.4
|
||||||
|
|
||||||
|
2023年12月08日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 快速犯罪中添加了15-3
|
||||||
|
|
||||||
|
## 1.1.3
|
||||||
|
|
||||||
|
2023年11月29日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 通知浏览错误修复
|
||||||
|
|
||||||
|
## 1.1.2
|
||||||
|
|
||||||
|
2023年09月19日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 火车提醒错误修复
|
||||||
|
- 光速刷新错误修复
|
||||||
|
|
||||||
|
## 1.1.1
|
||||||
|
|
||||||
|
2023年09月13日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 调整了上次动作的显示逻辑
|
||||||
|
- 更准确的现金变动提醒
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 监控模块-毒CD提醒
|
||||||
|
|
||||||
|
## 1.1.0
|
||||||
|
|
||||||
|
2023年09月11日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 更正上次动作的匹配路径、添加了毒和糖 CD 的提示
|
||||||
|
|
||||||
|
## 1.0.9
|
||||||
|
|
||||||
|
2023年09月08日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 侧边菜单UI优化
|
||||||
|
|
||||||
|
## 1.0.8
|
||||||
|
|
||||||
|
2023年08月23日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 通知浏览修复
|
||||||
|
|
||||||
|
## 1.0.7
|
||||||
|
|
||||||
|
2023年06月27日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 物品功能补充完善
|
||||||
|
- 菜单顺序调整
|
||||||
|
|
||||||
|
## 1.0.6
|
||||||
|
|
||||||
|
2023年06月26日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 物品功能标签
|
||||||
|
|
||||||
|
## 1.0.5
|
||||||
|
|
||||||
|
2023年06月19日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 移除原菜单
|
||||||
|
- 调整了新菜单的样式、部分逻辑
|
||||||
|
|
||||||
|
## 1.0.4
|
||||||
|
|
||||||
|
2023年06月16日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 标签页管理功能
|
||||||
|
|
||||||
|
## 1.0.3
|
||||||
|
|
||||||
|
2023年06月16日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 样式错误修复
|
||||||
|
|
||||||
|
## 1.0.2
|
||||||
|
|
||||||
|
2023年06月15日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 错误修复
|
||||||
|
- 菜单样式修改
|
||||||
|
|
||||||
|
## 1.0.1
|
||||||
|
|
||||||
|
2023年06月14日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 公司存取钱
|
||||||
|
|
||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
2023年06月12日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- PT购买
|
||||||
|
|
||||||
|
## 0.9.9
|
||||||
|
|
||||||
|
2023年06月07日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 购物助手错误修复及样式调整
|
||||||
|
|
||||||
|
## 0.9.8
|
||||||
|
|
||||||
|
2023年06月06日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 错误修复
|
||||||
|
|
||||||
|
## 0.9.7
|
||||||
|
|
||||||
|
2023年06月05日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- bazaar快速开关店
|
||||||
|
- 购物助手
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 部分样式修改
|
||||||
|
|
||||||
|
## 0.9.6
|
||||||
|
|
||||||
|
2023年06月01日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- PC病毒快速操作
|
||||||
|
|
||||||
|
## 0.9.5
|
||||||
|
|
||||||
|
2023年05月31日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 明文密码简单编码处理
|
||||||
|
- 自动登录前添加确认
|
||||||
|
|
||||||
|
## 0.9.4
|
||||||
|
|
||||||
|
2023年05月31日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 自动登陆功能
|
||||||
|
|
||||||
|
## 0.9.3
|
||||||
|
|
||||||
|
2023年05月30日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 快速查看地图垃圾
|
||||||
|
|
||||||
|
## 0.9.2
|
||||||
|
|
||||||
|
2023年05月26日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 快速浏览通知
|
||||||
|
|
||||||
|
## 0.9.1
|
||||||
|
|
||||||
|
2023年05月04日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 新菜单中现在可以快速喝啤酒了
|
||||||
|
- 快速 refill
|
||||||
|
|
||||||
|
## 0.9.0
|
||||||
|
|
||||||
|
2023年04月28日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 新菜单中现在可以快速吃XAN了
|
||||||
|
- 快速犯罪
|
||||||
|
|
||||||
|
## 0.8.9
|
||||||
|
|
||||||
|
2023年04月24日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 战斗相关模块错误修复
|
||||||
|
- 重复通知错误修复
|
||||||
|
|
||||||
|
## 0.8.8
|
||||||
|
|
||||||
|
2023年04月17日
|
||||||
|
|
||||||
|
### 添加
|
||||||
|
|
||||||
|
- 新菜单
|
||||||
|
- 快速锻炼
|
||||||
|
- 一键起飞
|
||||||
|
|
||||||
|
## 0.8.7
|
||||||
|
|
||||||
|
2023年04月10日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 修复脚本首次运行配置获取错误的问题
|
||||||
|
- 修复"解决加载中"功能开启后无法加载插件图标的问题
|
||||||
|
- 修复功能选项错误读取默认值的问题
|
||||||
|
|
||||||
|
## 0.8.6
|
||||||
|
|
||||||
|
2023年04月07日
|
||||||
|
|
||||||
|
### 修改
|
||||||
|
|
||||||
|
- 结构调整
|
||||||
|
|
||||||
## 0.8.5
|
## 0.8.5
|
||||||
|
|
||||||
2023年04月03日
|
2023年04月03日
|
||||||
|
|||||||
24
README.md
24
README.md
@ -1,3 +1,23 @@
|
|||||||
# 芜湖助手 Torncity 翻译插件
|
# Wuhu Torn Helper
|
||||||
|
|
||||||
[CHANGELOG](CHANGELOG.md)
|
[](LICENSE)
|
||||||
|
|
||||||
|
[中文](README_ZHCN.md)
|
||||||
|
|
||||||
|
[CHANGELOG(CN)](CHANGELOG.md)
|
||||||
|
|
||||||
|
A customized auxiliary-enhancement user script designed for a browser-based MMORPG game, featuring a range of convenient
|
||||||
|
functions.
|
||||||
|
|
||||||
|
This script does not include any automation-related code.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
npm init
|
||||||
|
npm run rollup
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
[release.min.user.js](release.min.user.js)
|
||||||
|
|
||||||
|
Please install with Tampermonkey (for PC browser) or TornPDA.
|
||||||
|
|||||||
20
README_ZHCN.md
Normal file
20
README_ZHCN.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# 芜湖助手 Torncity 翻译插件
|
||||||
|
|
||||||
|
[](LICENSE)
|
||||||
|
|
||||||
|
[CHANGELOG](CHANGELOG.md)
|
||||||
|
|
||||||
|
一个为浏览器网页MMORPG游戏定制的辅助增强用户脚本,包含了一系列便携功能。
|
||||||
|
|
||||||
|
此脚本不包含自动化相关代码。
|
||||||
|
|
||||||
|
## 编译
|
||||||
|
|
||||||
|
npm init
|
||||||
|
npm run rollup
|
||||||
|
|
||||||
|
## 使用
|
||||||
|
|
||||||
|
[release.min.user.js](https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/README_ZHCN.md)
|
||||||
|
|
||||||
|
请使用 Tampermonkey (浏览器) 或 TornPDA 安装。
|
||||||
@ -21,7 +21,6 @@ let metaData =
|
|||||||
// @downloadURL https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/release.min.user.js
|
// @downloadURL https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/release.min.user.js
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
// @grant unsafeWindow
|
// @grant unsafeWindow
|
||||||
// @connect ljs-lyt.com
|
|
||||||
// @connect yata.yt
|
// @connect yata.yt
|
||||||
// @connect github.io
|
// @connect github.io
|
||||||
// @connect gitlab.com
|
// @connect gitlab.com
|
||||||
|
|||||||
10
global.d.ts
vendored
10
global.d.ts
vendored
@ -122,10 +122,8 @@ declare module "*.module.css" {
|
|||||||
declare function GM_xmlhttpRequest(init: any): void;
|
declare function GM_xmlhttpRequest(init: any): void;
|
||||||
|
|
||||||
declare var unsafeWindow: Window & typeof globalThis;
|
declare var unsafeWindow: Window & typeof globalThis;
|
||||||
|
|
||||||
declare interface UnknownFields {
|
|
||||||
// any property
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
|
|
||||||
declare type Constructor<T = any> = new (...args: any[]) => T;
|
declare type Constructor<T = any> = new (...args: any[]) => T;
|
||||||
|
|
||||||
|
declare interface ClassType<T> {
|
||||||
|
new(...args: unknown[]): T
|
||||||
|
}
|
||||||
|
|||||||
2283
package-lock.json
generated
2283
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.8.6",
|
"version": "1.2.4",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
||||||
@ -8,17 +8,20 @@
|
|||||||
"rollup": "cross-env NODE_ENV=development rollup -c"
|
"rollup": "cross-env NODE_ENV=development rollup -c"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@element-plus/icons-vue": "^2.1.0",
|
||||||
"@rollup/plugin-alias": "^4.0.3",
|
"@rollup/plugin-alias": "^4.0.3",
|
||||||
|
"@rollup/plugin-commonjs": "^24.0.1",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||||
"@rollup/plugin-replace": "^5.0.2",
|
"@rollup/plugin-replace": "^5.0.2",
|
||||||
"@rollup/plugin-terser": "^0.4.0",
|
"@rollup/plugin-terser": "^0.4.0",
|
||||||
"@rollup/plugin-typescript": "^8.5.0",
|
"@rollup/plugin-typescript": "^8.5.0",
|
||||||
"@types/jquery": "^3.5.14",
|
"@types/jquery": "^3.5.14",
|
||||||
"@types/node": "^18.0.6",
|
"@types/node": "^20.6.0",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.0.0",
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
"element-plus": "^2.3.10",
|
||||||
"just-clone": "^6.2.0",
|
"just-clone": "^6.2.0",
|
||||||
"npm": "^8.19.2",
|
"npm": "^8.19.2",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
@ -29,6 +32,11 @@
|
|||||||
"rollup-plugin-typescript2": "^0.34.1",
|
"rollup-plugin-typescript2": "^0.34.1",
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"typescript": "^4.8.3",
|
"typescript": "^4.8.3",
|
||||||
|
"unplugin-auto-import": "^0.15.2",
|
||||||
|
"unplugin-element-plus": "^0.7.0",
|
||||||
|
"unplugin-icons": "^0.16.1",
|
||||||
|
"unplugin-vue-components": "^0.24.1",
|
||||||
|
"vant": "^4.1.2",
|
||||||
"vue": "^3.2.47"
|
"vue": "^3.2.47"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -15,6 +15,14 @@ import styles from "rollup-plugin-styles";
|
|||||||
import { customInjector } from "./custom-injector.js";
|
import { customInjector } from "./custom-injector.js";
|
||||||
import terser from "@rollup/plugin-terser";
|
import terser from "@rollup/plugin-terser";
|
||||||
import clone from "just-clone";
|
import clone from "just-clone";
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import AutoImport from 'unplugin-auto-import/vite'
|
||||||
|
import Components from 'unplugin-vue-components/vite'
|
||||||
|
// import { VantResolver } from 'unplugin-vue-components/resolvers';
|
||||||
|
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
||||||
|
import IconsResolver from 'unplugin-icons/resolver';
|
||||||
|
import Icons from 'unplugin-icons/vite'
|
||||||
|
import ElementPlus from 'unplugin-element-plus/rollup'
|
||||||
|
|
||||||
let node_env = process.env.NODE_ENV;
|
let node_env = process.env.NODE_ENV;
|
||||||
let vuePath = node_env === 'production' ?
|
let vuePath = node_env === 'production' ?
|
||||||
@ -65,7 +73,27 @@ const devConfig = {
|
|||||||
browser: true,
|
browser: true,
|
||||||
preferBuiltins: false,
|
preferBuiltins: false,
|
||||||
}),
|
}),
|
||||||
|
commonjs(),
|
||||||
vue({ isProduction: node_env === 'production' }),
|
vue({ isProduction: node_env === 'production' }),
|
||||||
|
AutoImport({
|
||||||
|
resolvers: [
|
||||||
|
ElementPlusResolver(),
|
||||||
|
IconsResolver({
|
||||||
|
prefix: 'Icon',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
Components({
|
||||||
|
resolvers: [
|
||||||
|
IconsResolver({
|
||||||
|
enabledCollections: ['ep'],
|
||||||
|
}),
|
||||||
|
ElementPlusResolver()
|
||||||
|
],
|
||||||
|
// resolvers: [VantResolver()],
|
||||||
|
}),
|
||||||
|
Icons(),
|
||||||
|
ElementPlus(),
|
||||||
// 自定义注入器注入vue部分css
|
// 自定义注入器注入vue部分css
|
||||||
styles({
|
styles({
|
||||||
// modules: true,
|
// modules: true,
|
||||||
|
|||||||
6
src/shims-vue.d.ts
vendored
6
src/shims-vue.d.ts
vendored
@ -4,8 +4,4 @@ declare module '*.vue' {
|
|||||||
const component: DefineComponent<{}, {}, any>
|
const component: DefineComponent<{}, {}, any>
|
||||||
export default component
|
export default component
|
||||||
}
|
}
|
||||||
declare module '*vue&type=script&lang.ts' {
|
/* eslint-enable */
|
||||||
import type { DefineComponent } from 'vue'
|
|
||||||
const component: DefineComponent<{}, {}, any>
|
|
||||||
export default component
|
|
||||||
}
|
|
||||||
|
|||||||
@ -281,4 +281,12 @@ div#wh-popup::after {
|
|||||||
|
|
||||||
.non-selection {
|
.non-selection {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mt-4 {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*.el-overlay {*/
|
||||||
|
/* backdrop-filter: blur(20px);*/
|
||||||
|
/*}*/
|
||||||
|
|||||||
@ -1,75 +1,71 @@
|
|||||||
<div class="acc-title">
|
<div class="acc-title">
|
||||||
<span class="item-desc tt-buy" style="display: inline-block;">
|
<span class="item-desc tt-buy">
|
||||||
<span aria-labelledby="180-name 180-price 180-stock" class="item Alcohol" itemid="180" loaded="0" tabindex="0">
|
<span class="item Alcohol" itemid="180" loaded="0">
|
||||||
<span class="item-plate">
|
<span class="item-plate">
|
||||||
<img alt="Bottle of Beer" class="torn-item large" src="/images/items/180/large.png">
|
<img alt="Bottle of Beer" class="torn-item large"
|
||||||
</span>
|
src="/images/items/180/large.png"
|
||||||
<span class="item-hover">
|
srcset="/images/items/180/large.png 1x, /images/items/180/large@2x.png 2x, /images/items/180/large@3x.png 3x, /images/items/180/large@4x.png 4x">
|
||||||
<button aria-label="Show info: Bottle of Beer" class="view-h wai-btn" value="100"></button>
|
</span>
|
||||||
<button aria-label="Buy: Bottle of Beer" class="buy-h wai-btn" i-data="i_661_346_51_52" value="100"></button>
|
<span class="item-hover">
|
||||||
</span>
|
<button aria-labelledby="Show info: 180-name 180-price 180-stock" class="view-info wai-btn"
|
||||||
</span>
|
value="100"></button>
|
||||||
<span class="desc">
|
<button aria-label="Buy: Bottle of Beer" class="buy-info wai-btn" value="100"></button>
|
||||||
<span id="180-name" class="name t-overflow bold">一瓶啤酒</span>
|
</span>
|
||||||
<span id="180-price" class="price t-gray-6" data-sell="$5">$10</span>
|
</span>
|
||||||
<span id="180-stock" class="stock t-gray-6 t-overflow">Alcohol (<span class="instock">600</span> in stock)</span>
|
<span class="desc">
|
||||||
</span>
|
<input name="shoparea" type="hidden" value="100">
|
||||||
<span class="buy-act-wrap">
|
<span id="180-name" class="name t-overflow bold">Bottle of Beer</span>
|
||||||
<button aria-label="Close" class="close-icon p0 wai-btn" value="100"></button>
|
<span id="180-price" class="price t-gray-6 tt-modified" data-sell="$5">$10<span
|
||||||
<label class="wai" for="180">Amount
|
class="tt-profit positive"><i class="fas fa-caret-up"></i>$1,636</span></span>
|
||||||
of Bottle of Beer</label>
|
<span id="180-stock" class="stock t-gray-6 t-overflow">Alcohol (<span class="instock">5,000</span> in
|
||||||
<input id="180" autocomplete="new-amount" maxlength="3" name="buyAmount[]" type="text" value="100">
|
stock)</span>
|
||||||
<span class="buy-act bold">
|
</span>
|
||||||
<button class="wai-support t-blue h" i-data="i_815_375_53_34" value="100">Buy<br><span
|
<span class="buy-act-wrap">
|
||||||
class="tt-max-buy">fill max</span></button>
|
<button aria-label="Close" class="close-icon p0 wai-btn" value="100"></button>
|
||||||
<div class="tt-max-buy-overlay"></div></span>
|
<label class="wai" for="180">Amount
|
||||||
</span>
|
of Bottle of Beer</label>
|
||||||
|
<input id="180" autocomplete="new-amount" maxlength="3" name="buyAmount[]" type="text" value="100">
|
||||||
|
<span class="buy-act bold">
|
||||||
|
<button class="wai-support t-blue h" value="100">Buy<br><span class="tt-max-buy">fill
|
||||||
|
max</span></button>
|
||||||
|
<div class="tt-max-buy-overlay"></div>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="torn-divider divider-right"></div>
|
<div class="torn-divider divider-right"></div>
|
||||||
<div class="confirm-wrap" style="display: none;">
|
<div class="confirm-wrap" tabindex="0">
|
||||||
<span class="confirm">
|
<span class="confirm">
|
||||||
<span>
|
<span>
|
||||||
确定购买
|
Are you sure you would like to buy
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
<span class="count">100</span>
|
|
||||||
x Bottle of Beer for
|
|
||||||
$<span class="total">1,000</span>
|
|
||||||
</span>
|
|
||||||
<span class="confirm-act m-top5">
|
|
||||||
<a class="wai-support yes m-right10 bold t-blue h" data-id="180" href="#" i-data="i_705_379_24_14">
|
|
||||||
Yes
|
|
||||||
</a>
|
|
||||||
<span class="no bold">
|
|
||||||
<a class="wai-support t-blue h" href="#" i-data="i_740_379_16_14">
|
|
||||||
No
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="success-wrap" style="display: none;">
|
|
||||||
<span class="success"><span class="t-red bold">
|
|
||||||
There is not enough stock left to buy <b>100</b> of this item.
|
|
||||||
</span>
|
</span>
|
||||||
<span class="confirm-act m-top5">
|
<span>
|
||||||
|
<span class="count"></span>
|
||||||
<a class="items m-right10 bold t-blue h" href="item.php">Your Items</a>
|
x Bottle of Beer for
|
||||||
|
$<span class="total"></span>
|
||||||
|
</span>
|
||||||
</span></span>
|
<span class="confirm-act m-top5">
|
||||||
<button aria-label="Close" class="close-icon p0 wai-btn" i-data="i_840_344_10_11" value="100"></button>
|
<a class="wai-support yes m-right10 bold t-blue h" data-id="180" href="#">
|
||||||
|
Yes
|
||||||
|
</a>
|
||||||
|
<span class="no bold">
|
||||||
|
<a class="wai-support t-blue h" href="#">
|
||||||
|
No
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="success-wrap">
|
||||||
|
<span class="success">
|
||||||
|
<span class="t-green bold">
|
||||||
|
<span class="ajax-preloader"></span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<button aria-label="Close" class="close-icon p0 wai-btn" value="100"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="msg-wrap">
|
<div class="msg-wrap">
|
||||||
<span class="t-green bold">
|
<span class="t-green bold">
|
||||||
<span class="ajax-preloader"></span>
|
<span class="ajax-preloader"></span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="view-item-info">
|
|
||||||
<div class="item-cont">
|
|
||||||
<div class="item-wrap">
|
|
||||||
<span class="ajax-preloader m-top10 m-bottom10"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1,54 +1,61 @@
|
|||||||
import WuhuBase from "./class/WuhuBase";
|
import Interrupt from "./class/Interrupt"
|
||||||
import WuHuTornHelper from "./class/WuhuTornHelper";
|
import Initializer from "./class/Initializer"
|
||||||
import ZhongIcon from "./class/ZhongIcon";
|
// import { Common } from "./class/Common"
|
||||||
import { Common } from "./class/Common";
|
// import UrlRouter from "./class/UrlRouter"
|
||||||
import UrlRouter from "./class/UrlRouter";
|
import translateMain from "./func/translate/translateMain"
|
||||||
import translateMain from "./func/translate/translateMain";
|
import CommonUtils from "./class/utils/CommonUtils"
|
||||||
import CommonUtils from "./class/utils/CommonUtils";
|
import LocalConfigWrapper from "./class/LocalConfigWrapper"
|
||||||
import LocalConfigWrapper from "./class/LocalConfigWrapper";
|
import ClassName from "./container/ClassName"
|
||||||
import ClassName from "./container/ClassName";
|
import { Injectable } from "./container/Injectable"
|
||||||
import { Injectable } from "./container/Injectable";
|
import FeatureMan from "./man/FeatureMan"
|
||||||
|
import Logger from "./class/Logger"
|
||||||
|
|
||||||
@ClassName('Application')
|
@ClassName('Application')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class App {
|
export default class App {
|
||||||
|
private readonly logger = Logger.factory(App)
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly icon: ZhongIcon,
|
private readonly interrupt: Interrupt,
|
||||||
private readonly wuhuBase: WuhuBase,
|
private readonly initializer: Initializer,
|
||||||
private readonly tornHelper: WuHuTornHelper,
|
// private readonly common: Common,
|
||||||
private readonly common: Common,
|
// private readonly urlRouter: UrlRouter,
|
||||||
private readonly urlRouter: UrlRouter,
|
|
||||||
private readonly configWrapper: LocalConfigWrapper,
|
private readonly configWrapper: LocalConfigWrapper,
|
||||||
private readonly utils: CommonUtils,
|
private readonly utils: CommonUtils,
|
||||||
|
private readonly featureMan: FeatureMan,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public run() {
|
public run() {
|
||||||
|
|
||||||
this.wuhuBase.conditionInterrupt();
|
this.interrupt.conditionInterrupt();
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
this.tornHelper.init();
|
this.initializer.init();
|
||||||
|
|
||||||
// 插件设置默认值
|
// this.featureMan.fStart().then(() => this.featureMan.printTable());
|
||||||
// WuhuConfig.setDefaults();
|
|
||||||
|
|
||||||
// 插件图标和设置菜单
|
// 插件图标和设置菜单
|
||||||
this.icon.init();
|
// this.icon.init();
|
||||||
|
|
||||||
let tmp = () => {
|
let tmp = () => {
|
||||||
// 所有页面通用
|
// // 所有页面通用
|
||||||
try {
|
// try {
|
||||||
this.common.resolve(this.run);
|
// // this.common.resolve.apply(this.common, this.run);
|
||||||
} catch (e) {
|
// // this.common.resolve(() => this.run());
|
||||||
}
|
// } catch (e) {
|
||||||
|
// }
|
||||||
|
(async function (self: App) {
|
||||||
|
await self.featureMan.fStart()
|
||||||
|
self.featureMan.printTable()
|
||||||
|
})(this)
|
||||||
|
|
||||||
// URL匹配
|
// URL匹配
|
||||||
this.urlRouter.resolve();
|
// this.urlRouter.resolve();
|
||||||
|
|
||||||
// 翻译
|
// 翻译
|
||||||
if (this.configWrapper.config.transEnable)
|
// if (this.configWrapper.config.transEnable)
|
||||||
translateMain(window.location.href);
|
// translateMain(window.location.href);
|
||||||
};
|
};
|
||||||
// TODO 临时检测jquery
|
// TODO 临时检测jquery
|
||||||
if (typeof $ === "function") {
|
if (typeof $ === "function") {
|
||||||
|
|||||||
@ -1,142 +1,160 @@
|
|||||||
import depoHelper from "../func/module/depoHelper";
|
// import depoHelper from "../func/module/depoHelper";
|
||||||
import TravelHelper from "../func/module/travelHelper";
|
// import TravelHelper from "../feature/TravelHelper";
|
||||||
import priceWatcherHandle from "../func/module/priceWatcherHandle";
|
// import priceWatcherHandle from "../func/module/priceWatcherHandle";
|
||||||
import CompanyHelper from "./action/CompanyHelper";
|
// import CompanyHelper from "../feature/CompanyHelper";
|
||||||
import AttackHelper from "./action/AttackHelper";
|
// import AttackHelper from "./action/AttackHelper";
|
||||||
import SidebarHelper from "./action/SidebarHelper";
|
// import SidebarHelper from "../feature/SidebarHelper";
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
// import CommonUtils from "./utils/CommonUtils";
|
||||||
import FetchUtils from "./utils/FetchUtils";
|
// import FetchUtils from "./utils/FetchUtils";
|
||||||
import ZhongIcon from "./ZhongIcon";
|
// import FetchEventCallback from "./action/FetchEventCallback";
|
||||||
import Alert from "./utils/Alert";
|
// import globVars from "../globVars";
|
||||||
import FetchEventCallback from "./action/FetchEventCallback";
|
// import TranslateNew from "./action/TranslateNew";
|
||||||
import globVars from "../globVars";
|
// import ClassName from "../container/ClassName";
|
||||||
import TranslateNew from "./action/TranslateNew";
|
// import { Injectable } from "../container/Injectable";
|
||||||
import ClassName from "../container/ClassName";
|
// import LocalConfigWrapper from "./LocalConfigWrapper";
|
||||||
import { Injectable } from "../container/Injectable";
|
// import Logger from "./Logger";
|
||||||
import LocalConfigWrapper from "./LocalConfigWrapper";
|
// import BuyBeerHelper from "../feature/BuyBeerHelper";
|
||||||
import Logger from "./Logger";
|
// import ModuleLoader from "./ModuleLoader";
|
||||||
import BuyBeerHelper from "./action/BuyBeerHelper";
|
// import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
import ModuleLoader from "./ModuleLoader";
|
// import TravelItem from "../feature/TravelItem";
|
||||||
import TornPDAUtils from "./utils/TornPDAUtils";
|
// import IconHelper from "../feature/IconHelper";
|
||||||
import TravelItem from "./action/TravelItem";
|
// import MsgWrapper from "./utils/MsgWrapper";
|
||||||
|
// import toThousands from "../func/utils/toThousands";
|
||||||
/**
|
// import { WHIntervalLoader } from "../monitor/WHIntervalLoader";
|
||||||
* 脚本不区分页面的通用功能入口
|
//
|
||||||
*/
|
// /**
|
||||||
@Injectable()
|
// * 脚本不区分页面的通用功能入口
|
||||||
@ClassName('Common')
|
// */
|
||||||
export class Common {
|
// @Injectable()
|
||||||
|
// @ClassName('Common')
|
||||||
constructor(
|
// export class Common {
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
// private readonly logger = Logger.factory(Common)
|
||||||
private readonly fetchEventCallback: FetchEventCallback,
|
//
|
||||||
private readonly translateNew: TranslateNew,
|
// constructor(
|
||||||
private readonly tornPDAUtils: TornPDAUtils,
|
// private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly logger: Logger,
|
// // private readonly fetchEventCallback: FetchEventCallback,
|
||||||
private readonly buyBeerHelper: BuyBeerHelper,
|
// // private readonly translateNew: TranslateNew,
|
||||||
private readonly icon: ZhongIcon,
|
// // private readonly tornPDAUtils: TornPDAUtils,
|
||||||
private readonly fetchUtils: FetchUtils,
|
// // private readonly buyBeerHelper: BuyBeerHelper,
|
||||||
private readonly moduleLoader: ModuleLoader,
|
// // private readonly fetchUtils: FetchUtils,
|
||||||
) {
|
// // private readonly moduleLoader: ModuleLoader,
|
||||||
}
|
// private readonly msgWrapper: MsgWrapper,
|
||||||
|
// ) {
|
||||||
public resolve(mainMethod) {
|
// }
|
||||||
|
//
|
||||||
// fetch方法处理
|
// public resolve(mainMethod) {
|
||||||
globVars.responseHandlers.push(
|
// // window.setInterval(()=>this.msgWrapper.create('test',{sysNotify:true},'info'),2000);
|
||||||
(...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
|
//
|
||||||
);
|
// // // fetch方法处理
|
||||||
// fetch方法处理-翻译
|
// // globVars.responseHandlers.push(
|
||||||
globVars.responseHandlers.push(
|
// // (...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
|
||||||
(...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
|
// // );
|
||||||
);
|
// // // fetch方法处理-翻译
|
||||||
|
// // globVars.responseHandlers.push(
|
||||||
// 价格监控
|
// // (...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
|
||||||
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
|
// // );
|
||||||
|
//
|
||||||
// 啤酒提醒
|
// // // 价格监控
|
||||||
if (this.localConfigWrapper.config._15Alarm) this.buyBeerHelper.start();
|
// // priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
|
||||||
|
//
|
||||||
this.moduleLoader.push(SidebarHelper);
|
// // 啤酒提醒
|
||||||
this.moduleLoader.push(TravelItem);
|
// // if (this.localConfigWrapper.config._15Alarm) this.buyBeerHelper.start();
|
||||||
|
//
|
||||||
/**
|
// // this.moduleLoader.push(SidebarHelper);
|
||||||
* 解决一直转圈(加载中)的问题
|
// // this.moduleLoader.push(TravelItem);
|
||||||
* All('script[src*="google"]')
|
// // this.moduleLoader.push(WHIntervalLoader)
|
||||||
* All('#gtm_tag')
|
//
|
||||||
* All('script[src*="chat/gonline"]')
|
// /**
|
||||||
* All('head script[nonce]')
|
// * 解决一直转圈(加载中)的问题
|
||||||
*/
|
// * All('script[src*="google"]')
|
||||||
if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
// * All('#gtm_tag')
|
||||||
window.stop();
|
// * All('script[src*="chat/gonline"]')
|
||||||
document.open();
|
// * All('head script[nonce]')
|
||||||
let readyStateChangeHandler = () => {
|
// */
|
||||||
this.logger.info('document.readyState', document.readyState);
|
// // try {
|
||||||
if (document.readyState === 'complete') {
|
// // if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
||||||
document.removeEventListener('readystatechange', readyStateChangeHandler);
|
// // window.stop();
|
||||||
mainMethod();
|
// // document.open();
|
||||||
throw new Error('页面已重载');
|
// // let readyStateChangeHandler = () => {
|
||||||
}
|
// // this.logger.info('document.readyState', document.readyState);
|
||||||
}
|
// // if (document.readyState === 'complete') {
|
||||||
document.addEventListener('readystatechange', readyStateChangeHandler);
|
// // document.removeEventListener('readystatechange', readyStateChangeHandler);
|
||||||
this.fetchUtils.fetchText(window.location.href).then(resp => {
|
// // mainMethod();
|
||||||
let removed = resp;
|
// // throw new Error('页面已重载');
|
||||||
[
|
// // }
|
||||||
/<script id="gtm_tag">.+?<\/script>/ms,
|
// // }
|
||||||
/<script async src="https:\/\/www\.google.+?<\/script>/ms,
|
// // document.addEventListener('readystatechange', readyStateChangeHandler);
|
||||||
/<script nonce=".+?gtag.+?<\/script>/ms,
|
// // this.fetchUtils.fetchText(window.location.href).then(resp => {
|
||||||
/<script.+?google.+?\/script>/,
|
// // let removed = resp;
|
||||||
].forEach(remove => {
|
// // [
|
||||||
removed = removed.replace(remove, '');
|
// // /<script id="gtm_tag">.+?<\/script>/ms,
|
||||||
});
|
// // /<script async src="https:\/\/www\.google.+?<\/script>/ms,
|
||||||
this.logger.info({ removed });
|
// // /<script nonce=".+?gtag.+?<\/script>/ms,
|
||||||
document.write(removed);
|
// // /<script.+?google.+?\/script>/,
|
||||||
document.close();
|
// // ].forEach(remove => {
|
||||||
});
|
// // removed = removed.replace(remove, '');
|
||||||
}
|
// // });
|
||||||
|
// // this.logger.info({ removed });
|
||||||
// 存钱相关
|
// // document.write(removed);
|
||||||
depoHelper();
|
// // document.close();
|
||||||
|
// // });
|
||||||
// 飞行相关
|
// // }
|
||||||
this.moduleLoader.push(TravelHelper);
|
// // } catch (e) {
|
||||||
|
// // this.logger.error('【解决一直转圈(加载中)的问题】错误',e)
|
||||||
// 战斗相关
|
// // }
|
||||||
this.moduleLoader.push(AttackHelper);
|
//
|
||||||
|
// // // 存钱相关
|
||||||
// 公司助手
|
// // try {
|
||||||
this.moduleLoader.push(CompanyHelper);
|
// // depoHelper();
|
||||||
|
// // } catch (e) {
|
||||||
// TODO 新菜单
|
// // this.logger.error('【存钱相关】错误',e)
|
||||||
// this.moduleLoader.push(IconHelper);
|
// // }
|
||||||
|
//
|
||||||
this.moduleLoader.load().then();
|
// // // 飞行相关
|
||||||
|
// // this.moduleLoader.push(TravelHelper);
|
||||||
// 自定义CSS
|
//
|
||||||
if (this.localConfigWrapper.config.CustomCss) {
|
// // 战斗相关
|
||||||
this.logger.info('应用自定义CSS');
|
// // this.moduleLoader.push(AttackHelper);
|
||||||
CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
|
//
|
||||||
}
|
// // 公司助手
|
||||||
|
// // this.moduleLoader.push(CompanyHelper);
|
||||||
// 现金变动提醒
|
//
|
||||||
if (this.localConfigWrapper.config.CashChangeAlert) CommonUtils.elementReady("#user-money").then(userMoney => {
|
// // // 菜单
|
||||||
new MutationObserver((mutations, observer) => {
|
// // this.moduleLoader.push(IconHelper);
|
||||||
if (!this.localConfigWrapper.config.CashChangeAlert) {
|
//
|
||||||
observer.disconnect();
|
// // this.moduleLoader.load().then();
|
||||||
new Alert('现金变动提醒已关闭', { sysNotify: true });
|
//
|
||||||
return;
|
// // // 自定义CSS
|
||||||
}
|
// // if (this.localConfigWrapper.config.CustomCss) {
|
||||||
this.logger.info("现金变动提醒", mutations);
|
// // this.logger.info('应用自定义CSS');
|
||||||
mutations.forEach(item => {
|
// // CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
|
||||||
if (item.attributeName === 'data-money') {
|
// // }
|
||||||
this.icon.updateCashView(userMoney.innerText);
|
// //
|
||||||
new Alert(
|
// // // 现金变动提醒
|
||||||
'提醒: 现金变动 ' + item.oldValue + ' -> ' + userMoney.innerText,
|
// // if (this.localConfigWrapper.config.CashChangeAlert) CommonUtils.elementReady("#user-money").then(userMoney => {
|
||||||
{ sysNotify: true }
|
// // let before = ''
|
||||||
);
|
// // new MutationObserver((mutations, observer) => {
|
||||||
}
|
// // if (!this.localConfigWrapper.config.CashChangeAlert) {
|
||||||
});
|
// // observer.disconnect();
|
||||||
}).observe(userMoney, { attributes: true, attributeOldValue: true })
|
// // this.msgWrapper.create('现金变动提醒已关闭', { sysNotify: true });
|
||||||
});
|
// // return;
|
||||||
}
|
// // }
|
||||||
}
|
// // this.logger.info("现金变动提醒", mutations);
|
||||||
|
// // mutations.forEach(item => {
|
||||||
|
// // if (item.attributeName === 'data-money') {
|
||||||
|
// // let change = userMoney.innerText
|
||||||
|
// // .trim()
|
||||||
|
// // .replaceAll(/[,$]/g, '')
|
||||||
|
// // if (change !== before) {
|
||||||
|
// // this.msgWrapper.create(
|
||||||
|
// // '现金变动 ' + item.oldValue + ' --> ' + toThousands(change),
|
||||||
|
// // { sysNotify: true }
|
||||||
|
// // );
|
||||||
|
// // before = change
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // });
|
||||||
|
// // }).observe(userMoney, { attributes: true, attributeOldValue: true })
|
||||||
|
// // });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|||||||
@ -1,47 +0,0 @@
|
|||||||
import Logger from "./Logger";
|
|
||||||
import ClassName from "../container/ClassName";
|
|
||||||
import { Injectable } from "../container/Injectable";
|
|
||||||
import Global from "./Global";
|
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
|
||||||
import LocalConfigWrapper from "./LocalConfigWrapper";
|
|
||||||
import NNB from "./handler/NNB";
|
|
||||||
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
|
|
||||||
import { createApp, InjectionKey } from "vue";
|
|
||||||
import FloatMenu from "../../vue/FloatMenu.vue";
|
|
||||||
import MenuItem, { MENU_ITEM_TYPE } from "../interface/MenuItem";
|
|
||||||
|
|
||||||
export const MenuItemListKey = Symbol() as InjectionKey<MenuItem[]>;
|
|
||||||
export const GlobalKey = Symbol() as InjectionKey<Global>;
|
|
||||||
export const LoggerKey = Symbol() as InjectionKey<Logger>;
|
|
||||||
|
|
||||||
@ClassName("IconHelper")
|
|
||||||
@Injectable()
|
|
||||||
export default class IconHelper {
|
|
||||||
private readonly _element: HTMLElement;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private readonly logger: Logger,
|
|
||||||
private readonly global: Global,
|
|
||||||
private readonly commonUtils: CommonUtils,
|
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
|
||||||
private readonly nnb: NNB,
|
|
||||||
private readonly itemPriceWatcherHandler: ItemPriceWatcherHandler,
|
|
||||||
) {
|
|
||||||
this._element = document.createElement('div');
|
|
||||||
}
|
|
||||||
|
|
||||||
get element() {
|
|
||||||
return this._element;
|
|
||||||
}
|
|
||||||
|
|
||||||
init() {
|
|
||||||
this._element.id = 'WHMenu2023';
|
|
||||||
document.body.append(this._element);
|
|
||||||
let app = createApp(FloatMenu);
|
|
||||||
app.config.errorHandler = (err) => this.logger.error('vue错误', err);
|
|
||||||
app.provide(MenuItemListKey, [{ domType: MENU_ITEM_TYPE.BUTTON, domId: '1', domText: '1111111' }]);
|
|
||||||
app.provide(GlobalKey, this.global);
|
|
||||||
app.provide(LoggerKey, this.logger);
|
|
||||||
app.mount(this._element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
285
src/ts/class/Initializer.ts
Normal file
285
src/ts/class/Initializer.ts
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
|
import Global from "./Global";
|
||||||
|
import COMMON_CSS from "../../static/css/common.module.css";
|
||||||
|
import globVars from "../globVars";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import Logger from "./Logger";
|
||||||
|
import InfoUtils from "./utils/InfoUtils";
|
||||||
|
import FetchEventCallback from "./action/FetchEventCallback";
|
||||||
|
import TranslateNew from "./action/TranslateNew";
|
||||||
|
import priceWatcherHandle from "../func/module/priceWatcherHandle";
|
||||||
|
import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
|
import LocalConfigWrapper from "./LocalConfigWrapper";
|
||||||
|
import depoHelper from "../func/module/depoHelper";
|
||||||
|
import toThousands from "../func/utils/toThousands";
|
||||||
|
import MsgWrapper from "./utils/MsgWrapper";
|
||||||
|
import FetchUtils from "./utils/FetchUtils";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
@ClassName('Initializer')
|
||||||
|
export default class Initializer {
|
||||||
|
private readonly logger: Logger = Logger.factory(Initializer)
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly global: Global,
|
||||||
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly fetchEventCallback: FetchEventCallback,
|
||||||
|
private readonly translateNew: TranslateNew,
|
||||||
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
let glob = this.global;
|
||||||
|
|
||||||
|
// 请求通知权限
|
||||||
|
if (window.Notification) {
|
||||||
|
if (window.Notification.permission !== 'granted') {
|
||||||
|
this.logger.info("芜湖助手即将请求浏览器通知权限……");
|
||||||
|
window.Notification.requestPermission().then();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.logger.error('该浏览器不支持系统通知');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扩展正则方法
|
||||||
|
String.prototype.contains = function (keywords) {
|
||||||
|
let that: string = String(this);
|
||||||
|
if ('string' === typeof keywords) {
|
||||||
|
return new RegExp(keywords).test(that);
|
||||||
|
} else {
|
||||||
|
return keywords.test(that);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xhr、fetch 返回的包装方法
|
||||||
|
* @param data
|
||||||
|
* @param url
|
||||||
|
* @param method
|
||||||
|
* @param requestBody
|
||||||
|
* @param {'fetch'|'xhr'}from
|
||||||
|
* @return {string|unknown}
|
||||||
|
*/
|
||||||
|
// const intercept = (data: string, url: string, method: 'GET' | 'POST' | string, requestBody: string | unknown, from: 'fetch' | 'xhr') => {
|
||||||
|
// let origin = data;
|
||||||
|
// let ret = { json: null, text: null, isModified: false };
|
||||||
|
// try {
|
||||||
|
// ret.json = JSON.parse(<string>data);
|
||||||
|
// } catch {
|
||||||
|
// this.logger.warn('JSON.parse 错误', { data });
|
||||||
|
// ret.text = data;
|
||||||
|
// }
|
||||||
|
// this.logger.info('[' + from + ']响应', { url, method, ret, requestBody });
|
||||||
|
// globVars.WH_NET_LOG.push({ url, method, ret, requestBody, from });
|
||||||
|
|
||||||
|
// globVars.responseHandlers.forEach(handler => {
|
||||||
|
// try {
|
||||||
|
// handler(url, ret, { method, requestBody });
|
||||||
|
// } catch (e) {
|
||||||
|
// this.logger.error(e.stack || e.message);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// if (ret.isModified) {
|
||||||
|
// return ret.json ? JSON.stringify(ret.json) : ret.text;
|
||||||
|
// } else {
|
||||||
|
// return origin;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// 监听fetch
|
||||||
|
// ((fetch0, window) => {
|
||||||
|
// let originFetch = fetch0;
|
||||||
|
// // 引用解决与其他脚本接管fetch方法引起的兼容性问题
|
||||||
|
// if (glob.unsafeWindow) {
|
||||||
|
// originFetch = glob.unsafeWindow.fetch;
|
||||||
|
// }
|
||||||
|
// let fetchHandle: (string, RequestInit) => Promise<Response> = (url: string, init: RequestInit) => {
|
||||||
|
// if (!init) init = { method: 'GET' };
|
||||||
|
// return new Promise(resolve => {
|
||||||
|
// if (url.includes('newsTickers')) {
|
||||||
|
// this.logger.info('阻止获取新闻横幅');
|
||||||
|
// resolve(new Response('{}', init));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (url.includes('google')) {
|
||||||
|
// this.logger.info('阻止google相关请求');
|
||||||
|
// resolve(new Response('{}', init));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// originFetch(url, init)
|
||||||
|
// .then(res => {
|
||||||
|
// let clone = res.clone();
|
||||||
|
// clone.text().then(text => {
|
||||||
|
// let modified = intercept(text, url, init.method, init.body, 'fetch');
|
||||||
|
// resolve(new Response(modified, init));
|
||||||
|
// return;
|
||||||
|
// });
|
||||||
|
// })
|
||||||
|
// .catch(error => this.logger.error('fetch错误', error.stack || error.message));
|
||||||
|
// })
|
||||||
|
// };
|
||||||
|
|
||||||
|
// window.fetch = fetchHandle;
|
||||||
|
// // @ts-ignore
|
||||||
|
// fetch = fetchHandle;
|
||||||
|
// })(fetch || window.fetch, glob.unsafeWindow || window);
|
||||||
|
|
||||||
|
// 监听xhr
|
||||||
|
// (xhr => {
|
||||||
|
// let originOpen = xhr.open;
|
||||||
|
// let originSend = xhr.send;
|
||||||
|
// let logger = this.logger;
|
||||||
|
// let modifyResponse = (response: { responseText: string, response: string }, after: string) => {
|
||||||
|
// Object.defineProperty(response, 'responseText', { writable: true });
|
||||||
|
// Object.defineProperty(response, 'response', { writable: true });
|
||||||
|
// response.responseText = after;
|
||||||
|
// response.response = after;
|
||||||
|
// };
|
||||||
|
// XMLHttpRequest.prototype.open = function (method, url, async?, u?, p?) {
|
||||||
|
// this.addEventListener('readystatechange', function () {
|
||||||
|
// if (this.readyState !== 4) return;
|
||||||
|
// if (!(this.responseType === '' || this.responseType === 'text')) return
|
||||||
|
// let response = this.responseText || this.response;
|
||||||
|
// let reqBody = this['reqBody'];
|
||||||
|
// logger.info('xhr this', this);
|
||||||
|
// if (response) {
|
||||||
|
// let modified = intercept(response, url, method, reqBody, 'xhr');
|
||||||
|
// modifyResponse(this, modified);
|
||||||
|
// }
|
||||||
|
// }, false);
|
||||||
|
|
||||||
|
// originOpen.call(this, method, url, async, u, p);
|
||||||
|
// };
|
||||||
|
// XMLHttpRequest.prototype.send = function (body?) {
|
||||||
|
// this['reqBody'] = body;
|
||||||
|
// originSend.call(this, body);
|
||||||
|
// }
|
||||||
|
// })(XMLHttpRequest.prototype);
|
||||||
|
|
||||||
|
let commonCssStr = COMMON_CSS.replace('{{}}', performance.now().toString());
|
||||||
|
this.commonUtils.styleInject(commonCssStr);
|
||||||
|
|
||||||
|
// 测试用
|
||||||
|
// if ('Ok' !== localStorage['WHTEST']) {
|
||||||
|
// if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
|
||||||
|
// CommonUtils.COFetch(
|
||||||
|
// window.atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
||||||
|
// window.atob('cG9zdA=='),
|
||||||
|
// `{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
|
||||||
|
// )
|
||||||
|
// .then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 谷歌跟踪
|
||||||
|
window._gaUserPrefs = {
|
||||||
|
ioo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.dataLayer = null;
|
||||||
|
|
||||||
|
// 滚动条样式
|
||||||
|
this.logger.info("调整滚动条样式");
|
||||||
|
document.documentElement.classList.add("d");
|
||||||
|
document.body.classList.add("scrollbar-transparent");
|
||||||
|
|
||||||
|
// fetch方法处理
|
||||||
|
// globVars.responseHandlers.push(
|
||||||
|
// (...args: any[]) => this.fetchEventCallback.responseHandler.apply(this.fetchEventCallback, args)
|
||||||
|
// );
|
||||||
|
// fetch方法处理-翻译
|
||||||
|
// globVars.responseHandlers.push(
|
||||||
|
// (...args: any[]) => this.translateNew.responseHandler.apply(this.translateNew, args)
|
||||||
|
// );
|
||||||
|
|
||||||
|
// 价格监控 TODO 重构
|
||||||
|
priceWatcherHandle(this.tornPDAUtils.isPDA(), this.tornPDAUtils.APIKey);
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 解决一直转圈(加载中)的问题
|
||||||
|
// * All('script[src*="google"]')
|
||||||
|
// * All('#gtm_tag')
|
||||||
|
// * All('script[src*="chat/gonline"]')
|
||||||
|
// * All('head script[nonce]')
|
||||||
|
// */
|
||||||
|
// try {
|
||||||
|
// if (document.readyState === 'interactive' && this.localConfigWrapper.config.SolveGoogleScriptPendingIssue) {
|
||||||
|
// window.stop();
|
||||||
|
// document.open();
|
||||||
|
// let readyStateChangeHandler = () => {
|
||||||
|
// this.logger.info('document.readyState', document.readyState);
|
||||||
|
// if (document.readyState === 'complete') {
|
||||||
|
// document.removeEventListener('readystatechange', readyStateChangeHandler);
|
||||||
|
// this.init();
|
||||||
|
// throw new Error('页面已重载');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// document.addEventListener('readystatechange', readyStateChangeHandler);
|
||||||
|
// this.fetchUtils.fetchText(window.location.href).then(resp => {
|
||||||
|
// let removed = resp;
|
||||||
|
// [
|
||||||
|
// /<script id="gtm_tag">.+?<\/script>/ms,
|
||||||
|
// /<script async src="https:\/\/www\.google.+?<\/script>/ms,
|
||||||
|
// /<script nonce=".+?gtag.+?<\/script>/ms,
|
||||||
|
// /<script.+?google.+?\/script>/,
|
||||||
|
// ].forEach(remove => {
|
||||||
|
// removed = removed.replace(remove, '');
|
||||||
|
// });
|
||||||
|
// this.logger.info({ removed });
|
||||||
|
// document.write(removed);
|
||||||
|
// document.close();
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// } catch (e) {
|
||||||
|
// this.logger.error('【解决一直转圈(加载中)的问题】错误', e)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 存钱相关
|
||||||
|
try {
|
||||||
|
depoHelper();
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('【存钱相关】错误', e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义CSS
|
||||||
|
if (this.localConfigWrapper.config.CustomCss) {
|
||||||
|
this.logger.info('应用自定义CSS');
|
||||||
|
CommonUtils.addStyle(this.localConfigWrapper.config.CustomCss);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 现金变动提醒
|
||||||
|
if (this.localConfigWrapper.config.CashChangeAlert) CommonUtils.elementReady("#user-money").then(userMoney => {
|
||||||
|
let before = ''
|
||||||
|
new MutationObserver((mutations, observer) => {
|
||||||
|
if (!this.localConfigWrapper.config.CashChangeAlert) {
|
||||||
|
observer.disconnect();
|
||||||
|
this.msgWrapper.create('现金变动提醒已关闭', { sysNotify: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.logger.info("现金变动提醒", mutations);
|
||||||
|
mutations.forEach(item => {
|
||||||
|
if (item.attributeName === 'data-money') {
|
||||||
|
let change = userMoney.innerText
|
||||||
|
.trim()
|
||||||
|
.replaceAll(/[,$]/g, '')
|
||||||
|
if (change !== before) {
|
||||||
|
this.msgWrapper.create(
|
||||||
|
'现金变动 ' + item.oldValue + ' --> ' + toThousands(change),
|
||||||
|
{ sysNotify: true }
|
||||||
|
);
|
||||||
|
before = change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).observe(userMoney, { attributes: true, attributeOldValue: true })
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,12 +2,9 @@ import ClassName from "../container/ClassName";
|
|||||||
import { Injectable } from "../container/Injectable";
|
import { Injectable } from "../container/Injectable";
|
||||||
|
|
||||||
|
|
||||||
@ClassName('WuhuBase')
|
@ClassName('Interrupt')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class WuhuBase {
|
export default class Interrupt {
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public conditionInterrupt() {
|
public conditionInterrupt() {
|
||||||
let title: HTMLElement | { innerText: string } = (document.querySelector('#skip-to-content') ||
|
let title: HTMLElement | { innerText: string } = (document.querySelector('#skip-to-content') ||
|
||||||
@ -17,6 +14,6 @@ export default class WuhuBase {
|
|||||||
title.innerText.toLowerCase().includes('please validate') ||
|
title.innerText.toLowerCase().includes('please validate') ||
|
||||||
document.querySelector('div.container div.cf .iAmUnderAttack') !== null
|
document.querySelector('div.container div.cf .iAmUnderAttack') !== null
|
||||||
);
|
);
|
||||||
if (condition) throw '芜湖';
|
if (condition) throw new Error('芜湖');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ import ClassName from "../container/ClassName";
|
|||||||
import Logger from "./Logger";
|
import Logger from "./Logger";
|
||||||
import defaultConfig, { Config, isNotified } from "./config/defaultConfig";
|
import defaultConfig, { Config, isNotified } from "./config/defaultConfig";
|
||||||
import MsgWrapper from "./utils/MsgWrapper";
|
import MsgWrapper from "./utils/MsgWrapper";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('LocalConfigWrapper')
|
@ClassName('LocalConfigWrapper')
|
||||||
@ -16,13 +17,40 @@ export default class LocalConfigWrapper {
|
|||||||
|
|
||||||
public get config(): Config {
|
public get config(): Config {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
|
const str2code = (str: string): number[] => {
|
||||||
|
let code = [];
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
code.push(str.charCodeAt(i));
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
const code2str = (code: number[]): string => {
|
||||||
|
let str = '';
|
||||||
|
for (let i = 0; i < code.length; i++) {
|
||||||
|
str += String.fromCharCode(code[i]);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
};
|
||||||
return new Proxy(_this.Local, {
|
return new Proxy(_this.Local, {
|
||||||
get(target: Config, prop: string) {
|
get(target: Config, prop: string) {
|
||||||
return target[prop] ?? defaultConfig[prop];
|
let value = target[prop] ?? defaultConfig[prop];
|
||||||
|
if (prop === 'autoLoginPwd') {
|
||||||
|
let jsonObj;
|
||||||
|
try {
|
||||||
|
jsonObj = JSON.parse(window.atob(value));
|
||||||
|
} catch (e) {
|
||||||
|
jsonObj = [];
|
||||||
|
}
|
||||||
|
value = code2str(jsonObj);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
},
|
},
|
||||||
set(target: Config, prop: string, value: any): boolean {
|
set(target: Config, prop: string, value: any): boolean {
|
||||||
let config = target;
|
let config = target;
|
||||||
let preVal = config[prop];
|
let preVal = config[prop];
|
||||||
|
if (prop === 'autoLoginPwd') {
|
||||||
|
value = window.btoa(JSON.stringify(str2code(value)));
|
||||||
|
}
|
||||||
if (preVal !== value) {
|
if (preVal !== value) {
|
||||||
config[prop] = value;
|
config[prop] = value;
|
||||||
_this.setLocal(config);
|
_this.setLocal(config);
|
||||||
@ -44,9 +72,9 @@ export default class LocalConfigWrapper {
|
|||||||
private get Local(): Config {
|
private get Local(): Config {
|
||||||
let config: Config;
|
let config: Config;
|
||||||
try {
|
try {
|
||||||
config = JSON.parse(localStorage.getItem('wh_trans_settings'))
|
config = JSON.parse(localStorage.getItem('wh_trans_settings')) ?? defaultConfig;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error('配置获取失败, 载入默认');
|
this.logger.error('配置解析失败, 载入默认');
|
||||||
config = defaultConfig;
|
config = defaultConfig;
|
||||||
localStorage.setItem('wh_trans_settings', JSON.stringify(defaultConfig));
|
localStorage.setItem('wh_trans_settings', JSON.stringify(defaultConfig));
|
||||||
}
|
}
|
||||||
@ -57,3 +85,5 @@ export default class LocalConfigWrapper {
|
|||||||
localStorage.setItem('wh_trans_settings', JSON.stringify(config));
|
localStorage.setItem('wh_trans_settings', JSON.stringify(config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const LocalConfigWrapperKey = Symbol() as InjectionKey<LocalConfigWrapper>;
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import ClassName from "../container/ClassName";
|
import "reflect-metadata";
|
||||||
|
import ClassName, { GetClassName } from "../container/ClassName";
|
||||||
import { Injectable } from "../container/Injectable";
|
import { Injectable } from "../container/Injectable";
|
||||||
import Log from "./Log";
|
import Log from "./Log";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('Logger')
|
@ClassName('Logger')
|
||||||
@ -20,4 +22,31 @@ export default class Logger {
|
|||||||
debug() {
|
debug() {
|
||||||
return Log.debug()
|
return Log.debug()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCounter() {
|
||||||
|
return Log.getCounter()
|
||||||
|
}
|
||||||
|
|
||||||
|
getTime() {
|
||||||
|
return Log.getTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
static factory<T>(classT: ClassType<T>): Logger {
|
||||||
|
let className = GetClassName(classT);
|
||||||
|
return new class extends Logger {
|
||||||
|
info(...o: any): void {
|
||||||
|
return super.info(`[${ className }]`, ...o);
|
||||||
|
}
|
||||||
|
|
||||||
|
warn(...o: any): void {
|
||||||
|
return super.warn(`[${ className }]`, ...o);
|
||||||
|
}
|
||||||
|
|
||||||
|
error(...o: any): void {
|
||||||
|
return super.error(`[${ className }]`, ...o);
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const LoggerKey = Symbol() as InjectionKey<Logger>;
|
||||||
|
|||||||
@ -6,29 +6,30 @@ import { Injectable } from "../container/Injectable";
|
|||||||
@ClassName('ModuleLoader')
|
@ClassName('ModuleLoader')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class ModuleLoader {
|
export default class ModuleLoader {
|
||||||
private readonly classes: any[] = [];
|
private readonly classes: (new(...arg: any) => { init: () => void })[] = [];
|
||||||
|
private readonly logger = Logger.factory(ModuleLoader)
|
||||||
|
|
||||||
constructor(
|
// constructor() {
|
||||||
private readonly logger: Logger,
|
// }
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param method 默认'init'
|
* @param method 默认'init'
|
||||||
*/
|
*/
|
||||||
public async load(method: string = 'init'): Promise<void> {
|
public async load(method: string = 'init'): Promise<void> {
|
||||||
this.classes.forEach(clas => {
|
this.logger.info('即将加载: ', this.classes)
|
||||||
|
this.classes.forEach(clazz => {
|
||||||
try {
|
try {
|
||||||
Container.factory(clas)[method]();
|
this.logger.info('正在加载' + GetClassName(clazz))
|
||||||
|
Container.factory(clazz)[method]();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error('ModuleLoader 加载[' + GetClassName(clas) + ']时出错', e.message, e.stack);
|
this.logger.error('加载[' + GetClassName(clazz) + ']时出错', e.message, e.stack);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.classes.length = 0;
|
this.classes.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public push<T>(clas: T): void {
|
public push(clazz: new(...arg: any) => { init: () => void }): void {
|
||||||
this.classes.push(clas);
|
this.classes.push(clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,17 +2,16 @@ import cityFinder from "../func/module/cityFinder";
|
|||||||
import { missionDict } from "../dictionary/translation";
|
import { missionDict } from "../dictionary/translation";
|
||||||
import getTaskHint from "../func/translate/getTaskHint";
|
import getTaskHint from "../func/translate/getTaskHint";
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Log from "./Log";
|
|
||||||
import SHOP_BEER_STATIC_ITEM_HTML from "../../static/html/buyBeer/shop_beer_static_item.html";
|
import SHOP_BEER_STATIC_ITEM_HTML from "../../static/html/buyBeer/shop_beer_static_item.html";
|
||||||
import ADD_BEER_HEAD_HTML from "../../static/html/buyBeer/add_beer_head.html";
|
import ADD_BEER_HEAD_HTML from "../../static/html/buyBeer/add_beer_head.html";
|
||||||
import QUICK_CRIMES_HTML from "../../static/html/quick_crimes.html";
|
import QUICK_CRIMES_HTML from "../../static/html/quick_crimes.html";
|
||||||
import RW_RIDER_HTML from "../../static/html/rw_rider.html";
|
import RW_RIDER_HTML from "../../static/html/rw_rider.html";
|
||||||
import christmasTownHelper from "../func/module/christmasTownHelper";
|
import christmasTownHelper from "../func/module/christmasTownHelper";
|
||||||
import LotteryHelper from "./action/LotteryHelper";
|
import LotteryHelper from "../feature/LotteryHelper";
|
||||||
import TornStyleBlock from "./utils/TornStyleBlock";
|
import TornStyleBlock from "./utils/TornStyleBlock";
|
||||||
import PTHelper from "./action/PTHelper";
|
import PTHelper from "./action/PTHelper";
|
||||||
import StackHelper from "./action/StackHelper";
|
import StackHelper from "../feature/StackHelper";
|
||||||
import BuyBeerHelper from "./action/BuyBeerHelper";
|
import BuyBeerHelper from "../feature/BuyBeerHelper";
|
||||||
import XZMZ from "./action/XZMZ";
|
import XZMZ from "./action/XZMZ";
|
||||||
import ProfileHelper from "./action/ProfileHelper";
|
import ProfileHelper from "./action/ProfileHelper";
|
||||||
import SearchHelper from "./action/SearchHelper";
|
import SearchHelper from "./action/SearchHelper";
|
||||||
@ -23,6 +22,7 @@ import { Injectable } from "../container/Injectable";
|
|||||||
import ClassName from "../container/ClassName";
|
import ClassName from "../container/ClassName";
|
||||||
import LocalConfigWrapper from "./LocalConfigWrapper";
|
import LocalConfigWrapper from "./LocalConfigWrapper";
|
||||||
import { Container } from "../container/Container";
|
import { Container } from "../container/Container";
|
||||||
|
import Logger from "./Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本区分页面的功能入口
|
* 脚本区分页面的功能入口
|
||||||
@ -38,6 +38,7 @@ export default class UrlRouter {
|
|||||||
private readonly searchHelper: SearchHelper,
|
private readonly searchHelper: SearchHelper,
|
||||||
private readonly lotteryHelper: LotteryHelper,
|
private readonly lotteryHelper: LotteryHelper,
|
||||||
private readonly slotsHelper: SlotsHelper,
|
private readonly slotsHelper: SlotsHelper,
|
||||||
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,14 +48,14 @@ export default class UrlRouter {
|
|||||||
// 捡垃圾助手
|
// 捡垃圾助手
|
||||||
if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) {
|
if (href.includes('city.php') && this.localConfigWrapper.config.cityFinder) {
|
||||||
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||||
let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
// let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||||
reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
// reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
||||||
_base.append(reloadSwitch.getBase()).insert2Dom();
|
// _base.append(reloadSwitch.getBase()).insert2Dom();
|
||||||
reloadSwitch.getInput().addEventListener('change', () => {
|
// reloadSwitch.getInput().addEventListener('change', () => {
|
||||||
if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
// if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||||
this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
// this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
||||||
// WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true);
|
// // WuhuConfig.set('SolveGoogleScriptPendingIssue', reloadSwitch.getInput().checked, true);
|
||||||
});
|
// });
|
||||||
|
|
||||||
_base.append(document.createElement('br'));
|
_base.append(document.createElement('br'));
|
||||||
|
|
||||||
@ -90,12 +91,12 @@ export default class UrlRouter {
|
|||||||
let node = document.querySelector('ul.items-list');
|
let node = document.querySelector('ul.items-list');
|
||||||
if (!node) {
|
if (!node) {
|
||||||
msg_node.innerHTML = '❌ 商品未加载完';
|
msg_node.innerHTML = '❌ 商品未加载完';
|
||||||
Log.error('商品未加载完');
|
this.logger.error('商品未加载完');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (node.querySelector('span[id="180-name"]')) {
|
if (node.querySelector('span[id="180-name"]')) {
|
||||||
msg_node.innerHTML = '❌ 页面已经有啤酒了';
|
msg_node.innerHTML = '❌ 页面已经有啤酒了';
|
||||||
Log.warn('商店页面已有啤酒');
|
this.logger.warn('商店页面已有啤酒');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const clear_node = node.querySelector('li.clear');
|
const clear_node = node.querySelector('li.clear');
|
||||||
|
|||||||
@ -1,181 +0,0 @@
|
|||||||
import CommonUtils from "./utils/CommonUtils";
|
|
||||||
import Global from "./Global";
|
|
||||||
import COMMON_CSS from "../../static/css/common.module.css";
|
|
||||||
import globVars from "../globVars";
|
|
||||||
import { Injectable } from "../container/Injectable";
|
|
||||||
import ClassName from "../container/ClassName";
|
|
||||||
import Logger from "./Logger";
|
|
||||||
import InfoUtils from "./utils/InfoUtils";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
@ClassName('WuHuTornHelper')
|
|
||||||
export default class WuHuTornHelper {
|
|
||||||
constructor(
|
|
||||||
// private readonly travelItem: TravelItem,
|
|
||||||
private readonly global: Global,
|
|
||||||
private readonly logger: Logger,
|
|
||||||
private readonly infoUtils: InfoUtils,
|
|
||||||
private readonly commonUtils: CommonUtils,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public init() {
|
|
||||||
// this.logger.info('WuHuTornHelper初始化');
|
|
||||||
// WuhuBase.glob = this.global;
|
|
||||||
let glob = this.global;
|
|
||||||
// glob.fStock = this.travelItem;
|
|
||||||
|
|
||||||
// 请求通知权限
|
|
||||||
if (window.Notification) {
|
|
||||||
if (window.Notification.permission !== 'granted') {
|
|
||||||
this.logger.info("芜湖助手即将请求浏览器通知权限……");
|
|
||||||
window.Notification.requestPermission().then();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.error('该浏览器不支持系统通知');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 扩展正则方法
|
|
||||||
String.prototype.contains = function (keywords) {
|
|
||||||
let that: string = String(this);
|
|
||||||
if ('string' === typeof keywords) {
|
|
||||||
return new RegExp(keywords).test(that);
|
|
||||||
} else {
|
|
||||||
return keywords.test(that);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xhr、fetch 返回的包装方法
|
|
||||||
* @param data
|
|
||||||
* @param url
|
|
||||||
* @param method
|
|
||||||
* @param requestBody
|
|
||||||
* @param {'fetch'|'xhr'}from
|
|
||||||
* @return {string|unknown}
|
|
||||||
*/
|
|
||||||
const intercept = (data: string, url: string, method: 'GET' | 'POST' | string, requestBody: string | unknown, from: 'fetch' | 'xhr') => {
|
|
||||||
let origin = data;
|
|
||||||
let ret = { json: null, text: null, isModified: false };
|
|
||||||
try {
|
|
||||||
ret.json = JSON.parse(<string>data);
|
|
||||||
} catch {
|
|
||||||
this.logger.warn('JSON.parse 错误', { data });
|
|
||||||
ret.text = data;
|
|
||||||
}
|
|
||||||
this.logger.info('[' + from + ']响应', { url, method, ret, requestBody });
|
|
||||||
globVars.WH_NET_LOG.push({ url, method, ret, requestBody, from });
|
|
||||||
|
|
||||||
globVars.responseHandlers.forEach(handler => {
|
|
||||||
try {
|
|
||||||
handler(url, ret, { method, requestBody });
|
|
||||||
} catch (e) {
|
|
||||||
this.logger.error(e.stack || e.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (ret.isModified) {
|
|
||||||
return ret.json ? JSON.stringify(ret.json) : ret.text;
|
|
||||||
} else {
|
|
||||||
return origin;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// 监听fetch
|
|
||||||
((fetch0, window) => {
|
|
||||||
let originFetch = fetch0;
|
|
||||||
// 引用解决与其他脚本接管fetch方法引起的兼容性问题
|
|
||||||
if (glob.unsafeWindow) {
|
|
||||||
originFetch = glob.unsafeWindow.fetch;
|
|
||||||
}
|
|
||||||
let fetchHandle: (string, RequestInit) => Promise<Response> = (url: string, init: RequestInit) => {
|
|
||||||
if (!init) init = { method: 'GET' };
|
|
||||||
return new Promise(resolve => {
|
|
||||||
if (url.includes('newsTickers')) {
|
|
||||||
this.logger.info('阻止获取新闻横幅');
|
|
||||||
resolve(new Response('{}', init));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (url.includes('google')) {
|
|
||||||
this.logger.info('阻止google相关请求');
|
|
||||||
resolve(new Response('{}', init));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
originFetch(url, init)
|
|
||||||
.then(res => {
|
|
||||||
let clone = res.clone();
|
|
||||||
clone.text().then(text => {
|
|
||||||
let modified = intercept(text, url, init.method, init.body, 'fetch');
|
|
||||||
resolve(new Response(modified, init));
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(error => this.logger.error('fetch错误', error.stack || error.message));
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
window.fetch = fetchHandle;
|
|
||||||
// @ts-ignore
|
|
||||||
fetch = fetchHandle;
|
|
||||||
})(fetch || window.fetch, glob.unsafeWindow || window);
|
|
||||||
|
|
||||||
// 监听xhr
|
|
||||||
(xhr => {
|
|
||||||
let originOpen = xhr.open;
|
|
||||||
let originSend = xhr.send;
|
|
||||||
let logger = this.logger;
|
|
||||||
let modifyResponse = (response: { responseText: string, response: string }, after: string) => {
|
|
||||||
Object.defineProperty(response, 'responseText', { writable: true });
|
|
||||||
Object.defineProperty(response, 'response', { writable: true });
|
|
||||||
response.responseText = after;
|
|
||||||
response.response = after;
|
|
||||||
};
|
|
||||||
XMLHttpRequest.prototype.open = function (method, url, async?, u?, p?) {
|
|
||||||
this.addEventListener('readystatechange', function () {
|
|
||||||
if (this.readyState !== 4) return;
|
|
||||||
let response = this.responseText || this.response;
|
|
||||||
let reqBody = this['reqBody'];
|
|
||||||
logger.info('xhr this', this);
|
|
||||||
if (response) {
|
|
||||||
let modified = intercept(response, url, method, reqBody, 'xhr');
|
|
||||||
modifyResponse(this, modified);
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
originOpen.call(this, method, url, async, u, p);
|
|
||||||
};
|
|
||||||
XMLHttpRequest.prototype.send = function (body?) {
|
|
||||||
this['reqBody'] = body;
|
|
||||||
originSend.call(this, body);
|
|
||||||
}
|
|
||||||
})(XMLHttpRequest.prototype);
|
|
||||||
|
|
||||||
let commonCssStr = COMMON_CSS.replace('{{}}', performance.now().toString());
|
|
||||||
this.commonUtils.styleInject(commonCssStr);
|
|
||||||
|
|
||||||
// 测试用
|
|
||||||
if ('Ok' !== localStorage['WHTEST']) {
|
|
||||||
if (!((this.infoUtils.getPlayerInfo().userID | 0) === -1 || this.infoUtils.getPlayerInfo().playername === '未知')) {
|
|
||||||
CommonUtils.COFetch(
|
|
||||||
atob('aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE='),
|
|
||||||
atob('cG9zdA=='),
|
|
||||||
`{"uid":"${ this.infoUtils.getPlayerInfo().userID }","name":"${ this.infoUtils.getPlayerInfo().playername }"}`
|
|
||||||
)
|
|
||||||
.then(res => (res === 'Ok') && (localStorage['WHTEST'] = 'Ok'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 谷歌跟踪
|
|
||||||
window._gaUserPrefs = {
|
|
||||||
ioo() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
window.dataLayer = null;
|
|
||||||
|
|
||||||
// 滚动条样式
|
|
||||||
this.logger.info("调整滚动条样式");
|
|
||||||
document.documentElement.classList.add("d");
|
|
||||||
document.body.classList.add("scrollbar-transparent");
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,11 +2,10 @@ import adHelper from "../func/module/adHelper";
|
|||||||
import safeKeeper from "../func/module/safeKeeper";
|
import safeKeeper from "../func/module/safeKeeper";
|
||||||
import initMiniProf from "../func/utils/initMiniProf";
|
import initMiniProf from "../func/utils/initMiniProf";
|
||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Alert from "./utils/Alert";
|
|
||||||
import * as EVENTS from "../../static/json/event.json";
|
import * as EVENTS from "../../static/json/event.json";
|
||||||
import * as FEST from "../../static/json/fest.json";
|
import * as FEST from "../../static/json/fest.json";
|
||||||
import Popup from "./utils/Popup";
|
import Popup from "./utils/Popup";
|
||||||
import TravelItem from "./action/TravelItem";
|
import TravelItem from "../feature/TravelItem";
|
||||||
import ZHONG_MENU_HTML from "../../static/html/zhong/zhong_menu.html";
|
import ZHONG_MENU_HTML from "../../static/html/zhong/zhong_menu.html";
|
||||||
import ZHONG_UPDATE_HTML from "../../static/html/zhong/zhong_update.html";
|
import ZHONG_UPDATE_HTML from "../../static/html/zhong/zhong_update.html";
|
||||||
import ZHONG_LOOT_HTML from "../../static/html/zhong/zhong_loot.html";
|
import ZHONG_LOOT_HTML from "../../static/html/zhong/zhong_loot.html";
|
||||||
@ -16,7 +15,7 @@ import QuickFlyBtnHandler from "./handler/QuickFlyBtnHandler";
|
|||||||
import NNB from "./handler/NNB";
|
import NNB from "./handler/NNB";
|
||||||
import QuickLinksHandler from "./handler/QuickLinksHandler";
|
import QuickLinksHandler from "./handler/QuickLinksHandler";
|
||||||
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
|
import ItemPriceWatcherHandler from "./handler/ItemPriceWatcherHandler";
|
||||||
import ChangeLogHandler from "./handler/ChangeLogHandler";
|
// import ChangeLogHandler from "./handler/ChangeLogHandler";
|
||||||
import ItemPriceHandler from "./handler/ItemPriceHandler";
|
import ItemPriceHandler from "./handler/ItemPriceHandler";
|
||||||
import SettingsHandler from "./handler/SettingsHandler";
|
import SettingsHandler from "./handler/SettingsHandler";
|
||||||
import { MENU_ITEM_TYPE } from "../interface/MenuItem";
|
import { MENU_ITEM_TYPE } from "../interface/MenuItem";
|
||||||
@ -28,6 +27,7 @@ import { Container } from "../container/Container";
|
|||||||
import TornPDAUtils from "./utils/TornPDAUtils";
|
import TornPDAUtils from "./utils/TornPDAUtils";
|
||||||
import InfoUtils from "./utils/InfoUtils";
|
import InfoUtils from "./utils/InfoUtils";
|
||||||
import globVars from "../globVars";
|
import globVars from "../globVars";
|
||||||
|
import MsgWrapper from "./utils/MsgWrapper";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('ZhongIcon')
|
@ClassName('ZhongIcon')
|
||||||
@ -44,6 +44,7 @@ export default class ZhongIcon {
|
|||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly tornPDAUtils: TornPDAUtils,
|
private readonly tornPDAUtils: TornPDAUtils,
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ export default class ZhongIcon {
|
|||||||
textarea_node.remove();
|
textarea_node.remove();
|
||||||
target.innerHTML = '已复制';
|
target.innerHTML = '已复制';
|
||||||
target.onclick = null;
|
target.onclick = null;
|
||||||
new Alert('脚本已复制,请前往粘贴');
|
this.msgWrapper.create('脚本已复制,请前往粘贴');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -416,7 +417,7 @@ export default class ZhongIcon {
|
|||||||
// 物品查价
|
// 物品查价
|
||||||
list.push(ItemPriceHandler);
|
list.push(ItemPriceHandler);
|
||||||
// 更新历史
|
// 更新历史
|
||||||
list.push(ChangeLogHandler);
|
// list.push(ChangeLogHandler);
|
||||||
// 助手设置
|
// 助手设置
|
||||||
list.push(SettingsHandler);
|
list.push(SettingsHandler);
|
||||||
// 测试
|
// 测试
|
||||||
|
|||||||
@ -1,358 +1,352 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
// import CommonUtils from "../utils/CommonUtils";
|
||||||
import Alert from "../utils/Alert";
|
// import Alert from "../utils/Alert";
|
||||||
import Global from "../Global";
|
// import Global from "../Global";
|
||||||
import Device from "../../enum/Device";
|
// import Device from "../../enum/Device";
|
||||||
import ATTACK_HELPER_CSS from "../../../static/css/attack_helper.module.css";
|
// import ATTACK_HELPER_CSS from "../../../static/css/attack_helper.module.css";
|
||||||
import ActionButtonUtils from "../utils/ActionButtonUtils";
|
// import ActionButtonUtils from "../utils/ActionButtonUtils";
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
// import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
// import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
import DialogMsgBox from "../utils/DialogMsgBox";
|
// import DialogMsgBox from "../utils/DialogMsgBox";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
// import FetchUtils from "../utils/FetchUtils";
|
||||||
import MathUtils from "../utils/MathUtils";
|
// import MathUtils from "../utils/MathUtils";
|
||||||
import LoopHelper from "../utils/LoopHelper";
|
// import LoopHelper from "../utils/LoopHelper";
|
||||||
import TRAVEL_STATE from "../../enum/TravelState";
|
// import TRAVEL_STATE from "../../enum/TravelState";
|
||||||
import { Injectable } from "../../container/Injectable";
|
// import { Injectable } from "../../container/Injectable";
|
||||||
import ClassName from "../../container/ClassName";
|
// import ClassName from "../../container/ClassName";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
// import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
import Logger from "../Logger";
|
// import Logger from "../Logger";
|
||||||
|
//
|
||||||
enum FIGHT_STAGE {
|
// enum FIGHT_STAGE {
|
||||||
READY = 'ready',
|
// READY = 'ready',
|
||||||
IN_PROGRESS_OR_ERROR = 'in_progress_or_error',
|
// IN_PROGRESS_OR_ERROR = 'in_progress_or_error',
|
||||||
FINISHED = 'finished',
|
// FINISHED = 'finished',
|
||||||
END = 'end',
|
// END = 'end',
|
||||||
OTHER = 'other'
|
// OTHER = 'other'
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 战斗助手
|
// * 战斗助手
|
||||||
* TODO 页面加载已经在进行中的战斗时的正确判断
|
// * TODO 页面加载已经在进行中的战斗时的正确判断
|
||||||
*/
|
// */
|
||||||
@Injectable()
|
// @Injectable()
|
||||||
@ClassName('AttackHelper')
|
// @ClassName('AttackHelper')
|
||||||
export default class AttackHelper {
|
// export default class AttackHelper {
|
||||||
|
//
|
||||||
private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
|
// private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
|
||||||
|
//
|
||||||
constructor(
|
// constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
// private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly commonUtils: CommonUtils,
|
// private readonly commonUtils: CommonUtils,
|
||||||
private readonly global: Global,
|
// private readonly global: Global,
|
||||||
private readonly mathUtils: MathUtils,
|
// private readonly mathUtils: MathUtils,
|
||||||
private readonly actionButtonUtils: ActionButtonUtils,
|
// private readonly actionButtonUtils: ActionButtonUtils,
|
||||||
private readonly fetchUtils: FetchUtils,
|
// private readonly fetchUtils: FetchUtils,
|
||||||
private readonly logger: Logger,
|
// private readonly logger: Logger,
|
||||||
) {
|
// ) {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
init(): void {
|
// init(): void {
|
||||||
window.setTimeout(() => this.init(), 0);
|
// window.setTimeout(() => this._init(), 0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private _init() {
|
// private _init() {
|
||||||
if (window.location.href.contains(/loader\.php\?sid=attack/)) {
|
// if (window.location.href.contains(/loader\.php\?sid=attack/)) {
|
||||||
this.fightingPageHandle();
|
// this.fightingPageHandle();
|
||||||
}
|
// }
|
||||||
// 错误的攻击页面转跳
|
// // 错误的攻击页面转跳
|
||||||
else if (window.location.href.includes('loader2.php') && this.localConfigWrapper.config.attRelocate) {
|
// // else if (window.location.href.includes('loader2.php') && this.localConfigWrapper.config.attRelocate) {
|
||||||
const spl = window.location.href.trim().split('=');
|
// // const spl = window.location.href.trim().split('=');
|
||||||
const uid = spl[spl.length - 1];
|
// // const uid = spl[spl.length - 1];
|
||||||
if (this.commonUtils.isValidUid(uid)) {
|
// // if (this.commonUtils.isValidUid(uid)) {
|
||||||
window.location.href = 'https://www.torn.com/loader.php?sid=attack&user2ID=' + uid;
|
// // window.location.href = 'https://www.torn.com/loader.php?sid=attack&user2ID=' + uid;
|
||||||
} else {
|
// // } else {
|
||||||
this.logger.error('[AttackHelper] UID格式不正确');
|
// // this.logger.error('[AttackHelper] UID格式不正确');
|
||||||
}
|
// // }
|
||||||
}
|
// // }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private fightingPageHandle(): void {
|
// private fightingPageHandle(): void {
|
||||||
// 光速刷新按钮
|
// // 光速刷新按钮
|
||||||
this.actionButtonUtils.add('光速刷新', () => this.doAttackReload());
|
// this.actionButtonUtils.add('光速刷新', () => this.doAttackReload());
|
||||||
|
//
|
||||||
// 盯梢
|
// // 盯梢
|
||||||
this.watchTarget();
|
// this.watchTarget();
|
||||||
|
//
|
||||||
new MutationObserver((_, observer) => {
|
// new MutationObserver((_, observer) => {
|
||||||
let btnList = document.querySelectorAll('div[class^="dialogButtons___"] button') as NodeListOf<HTMLButtonElement>;
|
// let btnList = document.querySelectorAll('div[class^="dialogButtons___"] button') as NodeListOf<HTMLButtonElement>;
|
||||||
|
//
|
||||||
if (btnList.length === 0) {
|
// if (btnList.length === 0) {
|
||||||
if (this.currentStage === FIGHT_STAGE.READY && this.localConfigWrapper.config.quickFinishAtt === 3) {
|
// if (this.currentStage === FIGHT_STAGE.READY && this.localConfigWrapper.config.quickFinishAtt === 3) {
|
||||||
document.body.classList.remove('wh-move-btn');
|
// document.body.classList.remove('wh-move-btn');
|
||||||
this.logger.info('移除body class wh-move-btn');
|
// this.logger.info('移除body class wh-move-btn');
|
||||||
observer.disconnect();
|
// observer.disconnect();
|
||||||
}
|
// }
|
||||||
// 错误或正在打
|
// // 错误或正在打
|
||||||
this.currentStage = FIGHT_STAGE.IN_PROGRESS_OR_ERROR;
|
// this.currentStage = FIGHT_STAGE.IN_PROGRESS_OR_ERROR;
|
||||||
this.logger.info('[attackHelper] currentStage', this.currentStage);
|
// this.logger.info('[attackHelper] currentStage', this.currentStage);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
btnList.forEach(btn => {
|
// btnList.forEach(btn => {
|
||||||
let btnText = btn.innerText.toLowerCase();
|
// let btnText = btn.innerText.toLowerCase();
|
||||||
if (btnText.includes('start') || btnText.includes('join')) {
|
// if (btnText.includes('start') || btnText.includes('join')) {
|
||||||
// 开始
|
// // 开始
|
||||||
this.quickStartFight();
|
// this.quickStartFight();
|
||||||
} else if (btnText.includes('continue')) {
|
// } else if (btnText.includes('continue')) {
|
||||||
// 结束end
|
// // 结束end
|
||||||
this.currentStage = FIGHT_STAGE.END;
|
// this.currentStage = FIGHT_STAGE.END;
|
||||||
observer.disconnect();
|
// observer.disconnect();
|
||||||
} else if (btnText.includes('leave')) {
|
// } else if (btnText.includes('leave')) {
|
||||||
// 无意识状态FINISHED
|
// // 无意识状态FINISHED
|
||||||
this.quickFinishFight(btnList);
|
// this.quickFinishFight(btnList);
|
||||||
}
|
// }
|
||||||
this.logger.info('[attackHelper] currentStage', this.currentStage);
|
// this.logger.info('[attackHelper] currentStage', this.currentStage);
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
.observe(document.querySelector('#react-root'), { childList: true, subtree: true });
|
// .observe(document.querySelector('#react-root'), { childList: true, subtree: true });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 战斗页面快速刷新
|
// // 战斗页面快速刷新
|
||||||
private doAttackReload(): void {
|
// private doAttackReload(): void {
|
||||||
if (!window.ReactDOM) {
|
// if (!window.ReactDOM) {
|
||||||
new Alert('光速刷新失败:未找到React对象');
|
// new Alert('光速刷新失败:未找到React对象');
|
||||||
this.logger.error('光速刷新失败:未找到React对象');
|
// this.logger.error('光速刷新失败:未找到React对象');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (!document.querySelector('#react-root #attacker')) {
|
// if (!document.querySelector('#react-root #attacker')) {
|
||||||
this.logger.error('dom元素未找到selector: [#react-root #attacker]');
|
// this.logger.error('dom元素未找到selector: [#react-root #attacker]');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
let script = document.querySelector('script[src*="/builds/attack/"]');
|
// let script = document.querySelector('script[src*="/builds/attack/"]');
|
||||||
let url = script.src;
|
// let url = script.src;
|
||||||
if (!url.contains(/runtime\..+\.js/)) {
|
// if (!url.contains(/runtime\..+\.js/)) {
|
||||||
this.logger.error('脚本源[' + url + '] 不匹配规则');
|
// this.logger.error('脚本源[' + url + '] 不匹配规则');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
|
// window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
|
||||||
script.remove();
|
// script.remove();
|
||||||
let node = document.createElement('script');
|
// let node = document.createElement('script');
|
||||||
node.src = url;
|
// node.src = url;
|
||||||
node.type = 'text/javascript';
|
// node.type = 'text/javascript';
|
||||||
document.head.appendChild(node);
|
// document.head.appendChild(node);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 光速拔刀
|
// // 光速拔刀
|
||||||
private quickStartFight(): void {
|
// private quickStartFight(): void {
|
||||||
if (this.currentStage === FIGHT_STAGE.READY) {
|
// if (this.currentStage === FIGHT_STAGE.READY) {
|
||||||
return;
|
// return;
|
||||||
} else {
|
// } else {
|
||||||
this.currentStage = FIGHT_STAGE.READY;
|
// this.currentStage = FIGHT_STAGE.READY;
|
||||||
}
|
// }
|
||||||
if (this.localConfigWrapper.config.quickAttIndex === 6) return;
|
// if (this.localConfigWrapper.config.quickAttIndex === 6) return;
|
||||||
/**
|
// /**
|
||||||
* pc #defender
|
// * pc #defender
|
||||||
* mobile #attacker
|
// * mobile #attacker
|
||||||
*/
|
// */
|
||||||
const btn = <HTMLInputElement>(document.querySelector('#attacker button') || document.querySelector('#defender button'));
|
// const btn = <HTMLInputElement>(document.querySelector('#attacker button') || document.querySelector('#defender button'));
|
||||||
this.logger.info('操作按钮', { btn });
|
// this.logger.info('操作按钮', { btn });
|
||||||
if (!btn.innerText.toLowerCase().includes('fight')) {
|
// if (!btn.innerText.toLowerCase().includes('fight')) {
|
||||||
this.logger.info('未找到攻击按钮, 光速拔刀跳过');
|
// this.logger.info('未找到攻击按钮, 光速拔刀跳过');
|
||||||
new Alert('未找到攻击按钮, 光速拔刀跳过');
|
// new Alert('未找到攻击按钮, 光速拔刀跳过');
|
||||||
} else {
|
// } else {
|
||||||
// 判断是否存在脚踢
|
// // 判断是否存在脚踢
|
||||||
const hasKick = !!document.querySelector('#weapon_boots');
|
// const hasKick = !!document.querySelector('#weapon_boots');
|
||||||
// modal层
|
// // modal层
|
||||||
// const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
|
// // const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
|
||||||
let device = this.global.device;
|
// let device = this.global.device;
|
||||||
this.logger.info(`当前设备类型是${ device }`);
|
// this.logger.info(`当前设备类型是${ device }`);
|
||||||
// 区分设备
|
// // 区分设备
|
||||||
switch (device) {
|
// switch (device) {
|
||||||
case Device.PC: {
|
// case Device.PC: {
|
||||||
this.logger.info(`开始调整按钮位置`);
|
// this.logger.info(`开始调整按钮位置`);
|
||||||
// 隐藏modal层
|
// // 隐藏modal层
|
||||||
// modal.style.display = 'none';
|
// // modal.style.display = 'none';
|
||||||
// 根据选择的武器调整css
|
// // 根据选择的武器调整css
|
||||||
let css_top = '0';
|
// let css_top = '0';
|
||||||
switch (this.localConfigWrapper.config.quickAttIndex) {
|
// switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
// weapon_second
|
// // weapon_second
|
||||||
case 1: {
|
// case 1: {
|
||||||
css_top = '97px';
|
// css_top = '97px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
// weapon_melee
|
// // weapon_melee
|
||||||
case 2: {
|
// case 2: {
|
||||||
css_top = '194px';
|
// css_top = '194px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
// weapon_temp
|
// // weapon_temp
|
||||||
case 3: {
|
// case 3: {
|
||||||
css_top = '291px';
|
// css_top = '291px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
// weapon_fists
|
// // weapon_fists
|
||||||
case 4:
|
// case 4:
|
||||||
// weapon_boots
|
// // weapon_boots
|
||||||
case 5: {
|
// case 5: {
|
||||||
css_top = '375px';
|
// css_top = '375px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.commonUtils.styleInject(ATTACK_HELPER_CSS);
|
// this.commonUtils.styleInject(ATTACK_HELPER_CSS);
|
||||||
CommonUtils.addStyle(`.wh-move-btn #defender div[class^="modal___"]{top: ${ css_top };}`);
|
// CommonUtils.addStyle(`.wh-move-btn #defender div[class^="modal___"]{top: ${ css_top };}`);
|
||||||
document.body.classList.add('wh-move-btn');
|
// document.body.classList.add('wh-move-btn');
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case Device.MOBILE: {
|
// case Device.MOBILE: {
|
||||||
this.logger.info(`开始调整按钮位置`);
|
// this.logger.info(`开始调整按钮位置`);
|
||||||
// 加入css
|
// // 加入css
|
||||||
let css_top = '0';
|
// let css_top = '0';
|
||||||
let slot_height = '76px';
|
// let slot_height = '76px';
|
||||||
// 判断有没有脚踢
|
// // 判断有没有脚踢
|
||||||
if (hasKick) {
|
// if (hasKick) {
|
||||||
// 根据选择的武器调整
|
// // 根据选择的武器调整
|
||||||
switch (this.localConfigWrapper.config.quickAttIndex) {
|
// switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
case 1: { // weapon_second
|
// case 1: { // weapon_second
|
||||||
css_top = '76px';
|
// css_top = '76px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 2: { // weapon_melee
|
// case 2: { // weapon_melee
|
||||||
css_top = '152px';
|
// css_top = '152px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 3: { // weapon_temp
|
// case 3: { // weapon_temp
|
||||||
css_top = '228px';
|
// css_top = '228px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 4: { // weapon_fists
|
// case 4: { // weapon_fists
|
||||||
css_top = '304px';
|
// css_top = '304px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 5: { // weapon_boots
|
// case 5: { // weapon_boots
|
||||||
css_top = '380px';
|
// css_top = '380px';
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
const slot = document.querySelector('#weapon_main') as HTMLElement;
|
// const slot = document.querySelector('#weapon_main') as HTMLElement;
|
||||||
const height = slot.offsetHeight + 1;
|
// const height = slot.offsetHeight + 1;
|
||||||
// TODO 待验证
|
// // TODO 待验证
|
||||||
slot_height = height + 'px';
|
// slot_height = height + 'px';
|
||||||
// 根据选择的武器调整
|
// // 根据选择的武器调整
|
||||||
switch (this.localConfigWrapper.config.quickAttIndex) {
|
// switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
case 1: { // weapon_second
|
// case 1: { // weapon_second
|
||||||
css_top = `${ height }px`;
|
// css_top = `${ height }px`;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 2: { // weapon_melee
|
// case 2: { // weapon_melee
|
||||||
css_top = `${ height * 2 }px`;
|
// css_top = `${ height * 2 }px`;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 3: { // weapon_temp
|
// case 3: { // weapon_temp
|
||||||
css_top = `${ height * 3 }px`;
|
// css_top = `${ height * 3 }px`;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 4: { // weapon_fists
|
// case 4: { // weapon_fists
|
||||||
css_top = `${ height * 4 }px`;
|
// css_top = `${ height * 4 }px`;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 5: { // weapon_boots
|
// case 5: { // weapon_boots
|
||||||
css_top = `${ height * 5 }px`;
|
// css_top = `${ height * 5 }px`;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
const css_rule = ATTACK_HELPER_CSS.replace('CSSVAR', css_top).replace('CSSVAR', slot_height);
|
// const css_rule = ATTACK_HELPER_CSS.replace('CSSVAR', css_top).replace('CSSVAR', slot_height);
|
||||||
// `
|
//
|
||||||
// .wh-move-btn #attacker div[class^="modal___"]{display: block;width: 0;top: ${ css_top };left:0;height:0;}
|
// this.commonUtils.styleInject(css_rule);
|
||||||
// .wh-move-btn #attacker div[class^="dialog___"]{border:0;width:80px;height:${ slot_height };}
|
// document.body.classList.toggle('wh-move-btn');
|
||||||
// .wh-move-btn #attacker div[class^="colored___"]{display:block;padding:0;}
|
// btn.onclick = () => {
|
||||||
// .wh-move-btn #attacker div[class^="title___"]{height:0;}
|
// if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
|
||||||
// .wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;}
|
// btn.remove();
|
||||||
// `;
|
// // 停止自动刷新
|
||||||
this.commonUtils.styleInject(css_rule);
|
// // stop_reload = true;
|
||||||
document.body.classList.toggle('wh-move-btn');
|
// } else {
|
||||||
btn.onclick = () => {
|
// document.body.classList.toggle('wh-move-btn');
|
||||||
if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
|
// }
|
||||||
btn.remove();
|
// };
|
||||||
// 停止自动刷新
|
// break;
|
||||||
// stop_reload = true;
|
// }
|
||||||
} else {
|
// case Device.TABLET: {
|
||||||
document.body.classList.toggle('wh-move-btn');
|
// break;
|
||||||
}
|
// }
|
||||||
};
|
// }
|
||||||
break;
|
// }
|
||||||
}
|
// }
|
||||||
case Device.TABLET: {
|
//
|
||||||
break;
|
// // 光速跑路
|
||||||
}
|
// private quickFinishFight(btnList: NodeListOf<HTMLButtonElement>): void {
|
||||||
}
|
// if (this.currentStage === FIGHT_STAGE.FINISHED) {
|
||||||
}
|
// return;
|
||||||
}
|
// } else {
|
||||||
|
// this.currentStage = FIGHT_STAGE.FINISHED;
|
||||||
// 光速跑路
|
// }
|
||||||
private quickFinishFight(btnList: NodeListOf<HTMLButtonElement>): void {
|
// if (this.localConfigWrapper.config.quickFinishAtt === 3) {
|
||||||
if (this.currentStage === FIGHT_STAGE.FINISHED) {
|
// document.body.classList.remove('wh-move-btn');
|
||||||
return;
|
// this.logger.info('移除body class wh-move-btn');
|
||||||
} else {
|
// return;
|
||||||
this.currentStage = FIGHT_STAGE.FINISHED;
|
// }
|
||||||
}
|
// const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt];
|
||||||
if (this.localConfigWrapper.config.quickFinishAtt === 3) {
|
// // const wrap = document.querySelector('#react-root');
|
||||||
document.body.classList.remove('wh-move-btn');
|
// this.logger.info('光速跑路选项选中:', user_btn_select);
|
||||||
this.logger.info('移除body class wh-move-btn');
|
// // const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
||||||
return;
|
// if (btnList.length > 1) btnList.forEach(btn => {
|
||||||
}
|
// const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
||||||
const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt];
|
// this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
||||||
// const wrap = document.querySelector('#react-root');
|
// if (!flag) btn.style.display = 'none';
|
||||||
this.logger.info('光速跑路选项选中:', user_btn_select);
|
// });
|
||||||
// const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
// }
|
||||||
if (btnList.length > 1) btnList.forEach(btn => {
|
//
|
||||||
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
// // 盯梢模式
|
||||||
this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
// private watchTarget(): void {
|
||||||
if (!flag) btn.style.display = 'none';
|
// this.logger.info('获取目标id');
|
||||||
});
|
// let targetId = window.location.href.split('user2ID=')[1];
|
||||||
}
|
// if (!this.commonUtils.isValidUid(targetId)) {
|
||||||
|
// this.logger.error('目标id获取错误', targetId);
|
||||||
// 盯梢模式
|
// throw new Error('目标id获取错误:' + targetId);
|
||||||
private watchTarget(): void {
|
// }
|
||||||
this.logger.info('获取目标id');
|
// let loop = new LoopHelper(async () => {
|
||||||
let targetId = window.location.href.split('user2ID=')[1];
|
// let userProfile;
|
||||||
if (!this.commonUtils.isValidUid(targetId)) {
|
// try {
|
||||||
this.logger.error('目标id获取错误', targetId);
|
// userProfile = await this.fetchUtils.getProfile(targetId);
|
||||||
throw new Error('目标id获取错误:' + targetId);
|
// } catch {
|
||||||
}
|
// this.logger.error('盯梢模式无法获取目标id');
|
||||||
let loop = new LoopHelper(async () => {
|
// throw new Error('盯梢模式无法获取目标id');
|
||||||
let userProfile;
|
// }
|
||||||
try {
|
// await this.commonUtils.sleep(this.mathUtils.getRandomInt(20, 50));
|
||||||
userProfile = await this.fetchUtils.getProfile(targetId);
|
// if ((userProfile.userStatus.status === 'ok' && this.commonUtils.getTravelStage() === TRAVEL_STATE.IN_TORN) ||
|
||||||
} catch {
|
// (userProfile.userStatus.status === 'abroad' && this.commonUtils.getTravelStage() === TRAVEL_STATE.ABROAD)) {
|
||||||
this.logger.error('盯梢模式无法获取目标id');
|
// watchSwitch.getInput().checked = false;
|
||||||
throw new Error('盯梢模式无法获取目标id');
|
// window.setTimeout(async () => {
|
||||||
}
|
// new Alert('目标已落地/出院/出狱!', { timeout: 10, force: true, sysNotify: true });
|
||||||
await this.commonUtils.sleep(this.mathUtils.getRandomInt(20, 50));
|
// await this.commonUtils.audioPlay();
|
||||||
if ((userProfile.userStatus.status === 'ok' && this.commonUtils.getTravelStage() === TRAVEL_STATE.IN_TORN) ||
|
// await this.commonUtils.sleep(300);
|
||||||
(userProfile.userStatus.status === 'abroad' && this.commonUtils.getTravelStage() === TRAVEL_STATE.ABROAD)) {
|
// await this.commonUtils.audioPlay();
|
||||||
watchSwitch.getInput().checked = false;
|
// await this.commonUtils.sleep(300);
|
||||||
window.setTimeout(async () => {
|
// await this.commonUtils.audioPlay();
|
||||||
new Alert('目标已落地/出院/出狱!', { timeout: 10, force: true, sysNotify: true });
|
// await this.commonUtils.sleep(300);
|
||||||
await this.commonUtils.audioPlay();
|
// }, 0);
|
||||||
await this.commonUtils.sleep(300);
|
// }
|
||||||
await this.commonUtils.audioPlay();
|
// });
|
||||||
await this.commonUtils.sleep(300);
|
// let block = new TornStyleBlock('盯梢模式').insert2Dom();
|
||||||
await this.commonUtils.audioPlay();
|
// let watchSwitch = new TornStyleSwitch('开启');
|
||||||
await this.commonUtils.sleep(300);
|
// block.append(watchSwitch.getBase());
|
||||||
}, 0);
|
// watchSwitch.getInput().addEventListener('change', () => {
|
||||||
}
|
// if (watchSwitch.getInput().checked) {
|
||||||
});
|
// new DialogMsgBox('检测玩家状态,当目标状态变成(海外)落地、出院或出狱时通知并播放声音提醒,后可搭配光速刷新食用<br/>确定开启?', {
|
||||||
let block = new TornStyleBlock('盯梢模式').insert2Dom();
|
// callback: () => {
|
||||||
let watchSwitch = new TornStyleSwitch('开启');
|
// if (this.commonUtils.getTravelStage() === TRAVEL_STATE.FLYING) {
|
||||||
block.append(watchSwitch.getBase());
|
// new Alert('失败!已取消');
|
||||||
watchSwitch.getInput().addEventListener('change', () => {
|
// watchSwitch.getInput().checked = false;
|
||||||
if (watchSwitch.getInput().checked) {
|
// return;
|
||||||
new DialogMsgBox('检测玩家状态,当目标状态变成(海外)落地、出院或出狱时通知并播放声音提醒,后可搭配光速刷新食用<br/>确定开启?', {
|
// }
|
||||||
callback: () => {
|
// this.logger.info('盯梢开启, 目标id' + targetId);
|
||||||
if (this.commonUtils.getTravelStage() === TRAVEL_STATE.FLYING) {
|
// loop.start(this.localConfigWrapper.config.WatchTargetFreq | 0);
|
||||||
new Alert('失败!已取消');
|
// },
|
||||||
watchSwitch.getInput().checked = false;
|
// cancel: () => watchSwitch.getInput().checked = false
|
||||||
return;
|
// });
|
||||||
}
|
// } else {
|
||||||
this.logger.info('盯梢开启, 目标id' + targetId);
|
// loop.stop();
|
||||||
loop.start(this.localConfigWrapper.config.WatchTargetFreq | 0);
|
// this.logger.info('盯梢关闭');
|
||||||
},
|
// }
|
||||||
cancel: () => watchSwitch.getInput().checked = false
|
// });
|
||||||
});
|
// }
|
||||||
} else {
|
// }
|
||||||
loop.stop();
|
|
||||||
this.logger.info('盯梢关闭');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -5,6 +5,10 @@ import ResponseInject from "../../interface/ResponseInject";
|
|||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
import { fetchYata } from "../../func/module/fetchYata";
|
||||||
|
import toThousands from "../../func/utils/toThousands";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch 事件监听回调
|
* fetch 事件监听回调
|
||||||
@ -14,9 +18,14 @@ import LocalConfigWrapper from "../LocalConfigWrapper";
|
|||||||
export default class FetchEventCallback extends Provider implements ResponseInject {
|
export default class FetchEventCallback extends Provider implements ResponseInject {
|
||||||
className = "FetchEventCallback";
|
className = "FetchEventCallback";
|
||||||
|
|
||||||
|
newNode = document.createElement('div')
|
||||||
|
bsEstNode = document.createElement('div')
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -28,15 +37,38 @@ export default class FetchEventCallback extends Provider implements ResponseInje
|
|||||||
*/
|
*/
|
||||||
public responseHandler(url: string, response) {
|
public responseHandler(url: string, response) {
|
||||||
// mini profile 中添加上次动作
|
// mini profile 中添加上次动作
|
||||||
if (url.includes('profiles.php?step=getUserNameContextMenu') && this.localConfigWrapper.config.ShowMiniProfLastAct) {
|
if (url.startsWith('/page.php?sid=UserMiniProfile&userID')) {
|
||||||
window.setTimeout(async () => {
|
window.setTimeout(async () => {
|
||||||
let cont = CommonUtils.querySelector('[class*=profile-mini-_userProfileWrapper___]');
|
let cont = CommonUtils.querySelector('[class*=profile-mini-_userProfileWrapper___]');
|
||||||
let resp: MiniProfile = response.json as MiniProfile;
|
let resp: MiniProfile = response.json as MiniProfile;
|
||||||
let newNode = document.createElement('div');
|
if (this.localConfigWrapper.config.ShowMiniProfLastAct) {
|
||||||
let formatted = this.commonUtils.secondsFormat(resp.user.lastAction.seconds);
|
this.logger.info({ resp })
|
||||||
|
let formatted = this.commonUtils.secondsFormat(resp.user.lastAction.seconds);
|
||||||
|
|
||||||
newNode.innerText = '上次动作: ' + formatted;
|
(await cont).append(this.newNode);
|
||||||
(await cont).append(newNode);
|
this.newNode.innerText = '上次动作: ' + formatted;
|
||||||
|
}
|
||||||
|
if (this.localConfigWrapper.config.isBSEstMiniProfOn) {
|
||||||
|
const id = resp.user.userID
|
||||||
|
const apikey = localStorage.getItem('APIKey')
|
||||||
|
this.bsEstNode.innerHTML = `[BS估算] [${ id }]获取中...`;
|
||||||
|
(await cont).append(this.bsEstNode)
|
||||||
|
if (!apikey) {
|
||||||
|
this.bsEstNode.innerHTML = '[BS估算] 未配置APIKey,无法估算BS'
|
||||||
|
this.logger.error('MINI Profile bs估算失败: APIKey为空')
|
||||||
|
} else {
|
||||||
|
const bsData = fetchYata(id, apikey)
|
||||||
|
bsData.then(data => {
|
||||||
|
// 网速过慢时可能mini profile容器已更新新内容,与上次请求的用户数据不同,需要判断
|
||||||
|
if (this.bsEstNode.innerHTML.includes(resp.user.userID.toString())) {
|
||||||
|
this.bsEstNode.innerHTML = `[BS估算] ${ resp.user.playerName }[${ id }] ${ toThousands(data.total) }`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.bsEstNode.innerHTML = `[BS估算] ${ err.message }`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,25 +1,47 @@
|
|||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import Alert from "../utils/Alert";
|
|
||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import IFeature from "../../man/IFeature";
|
||||||
|
import MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('PTHelper')
|
@ClassName('PTHelper')
|
||||||
export default class PTHelper {
|
export default class PTHelper implements IFeature {
|
||||||
private readonly observer;
|
private observer: MutationObserver;
|
||||||
private readonly usersPointSell;
|
private usersPointSell: HTMLDivElement;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "pt一键购买";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/pmarket\.php/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
|
||||||
this.observer = new MutationObserver(e => {
|
this.observer = new MutationObserver(e => {
|
||||||
for (const t of e) {
|
for (const t of e) {
|
||||||
t.addedNodes.forEach(e => 'LI' === (e as HTMLElement).tagName && this.removeConfirm(e))
|
t.addedNodes.forEach(e => 'LI' === (e as HTMLElement).tagName && this.removeConfirm(e))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.usersPointSell = document.querySelector('.users-point-sell');
|
this.usersPointSell = document.querySelector<HTMLDivElement>('.users-point-sell');
|
||||||
|
|
||||||
let block = new TornStyleBlock('PT一键购买').insert2Dom();
|
let block = new TornStyleBlock('PT一键购买').insert2Dom();
|
||||||
let switcher = new TornStyleSwitch('开启');
|
let switcher = new TornStyleSwitch('开启');
|
||||||
@ -27,7 +49,7 @@ export default class PTHelper {
|
|||||||
let toggle = switcher.getInput();
|
let toggle = switcher.getInput();
|
||||||
toggle.checked = this.localConfigWrapper.config.ptQuickBuy;
|
toggle.checked = this.localConfigWrapper.config.ptQuickBuy;
|
||||||
if (toggle.checked) {
|
if (toggle.checked) {
|
||||||
new Alert('一键购买已开启');
|
this.msgWrapper.create('一键购买已开启');
|
||||||
for (const index in this.usersPointSell.children) {
|
for (const index in this.usersPointSell.children) {
|
||||||
'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index])
|
'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index])
|
||||||
}
|
}
|
||||||
@ -40,13 +62,13 @@ export default class PTHelper {
|
|||||||
'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index])
|
'LI' === this.usersPointSell.children[index].tagName && this.removeConfirm(this.usersPointSell.children[index])
|
||||||
}
|
}
|
||||||
this.observer.observe(this.usersPointSell, { childList: true });
|
this.observer.observe(this.usersPointSell, { childList: true });
|
||||||
new Alert('一键购买已开启');
|
this.msgWrapper.create('一键购买已开启');
|
||||||
} else {
|
} else {
|
||||||
for (const index in this.usersPointSell.children) {
|
for (const index in this.usersPointSell.children) {
|
||||||
'LI' === this.usersPointSell.children[index].tagName && this.rollbackConfirm(this.usersPointSell.children[index])
|
'LI' === this.usersPointSell.children[index].tagName && this.rollbackConfirm(this.usersPointSell.children[index])
|
||||||
}
|
}
|
||||||
this.observer.disconnect();
|
this.observer.disconnect();
|
||||||
new Alert('一键购买已关闭');
|
this.msgWrapper.create('一键购买已关闭');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -66,4 +88,4 @@ export default class PTHelper {
|
|||||||
let new_href = old_href.replace(/=buy1/, '=buy');
|
let new_href = old_href.replace(/=buy1/, '=buy');
|
||||||
el.setAttribute('href', new_href);
|
el.setAttribute('href', new_href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,21 +8,46 @@ import ClassName from "../../container/ClassName";
|
|||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
|
import IFeature from "../../man/IFeature";
|
||||||
|
import { fetchYata } from "../../func/module/fetchYata";
|
||||||
|
import MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
import toThousands from "../../func/utils/toThousands";
|
||||||
|
import { timePastFormat } from "../../func/utils/timePastFormat";
|
||||||
|
|
||||||
@ClassName('ProfileHelper')
|
@ClassName('ProfileHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class ProfileHelper implements ResponseInject {
|
export default class ProfileHelper implements ResponseInject, IFeature {
|
||||||
|
private block: TornStyleBlock;
|
||||||
private readonly block;
|
|
||||||
|
|
||||||
// 曾用名已检测过标记
|
|
||||||
private task = true;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "个人资料页面辅助";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 曾用名已检测过标记
|
||||||
|
private task = true;
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/profiles\.php\?XID=/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
|
||||||
CommonUtils.addStyle('body.wh-hide_profile_img .profile-image a.profile-image-wrapper .img-wrap img{display:none;}');
|
CommonUtils.addStyle('body.wh-hide_profile_img .profile-image a.profile-image-wrapper .img-wrap img{display:none;}');
|
||||||
// let id = document.querySelector('link[rel="canonical"]').getAttribute('href').split('=')[1];
|
// let id = document.querySelector('link[rel="canonical"]').getAttribute('href').split('=')[1];
|
||||||
let id = (new URL(window.location.href)).searchParams.get('XID');
|
let id = (new URL(window.location.href)).searchParams.get('XID');
|
||||||
@ -36,30 +61,90 @@ export default class ProfileHelper implements ResponseInject {
|
|||||||
}
|
}
|
||||||
this.block = new TornStyleBlock('芜湖助手').insert2Dom();
|
this.block = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||||
// 隐藏头像
|
// 隐藏头像
|
||||||
let hideImgSwitch = new TornStyleSwitch('隐藏头像', this.localConfigWrapper.config.HideProfileImg);
|
try {
|
||||||
this.block.append(hideImgSwitch.getBase());
|
let hideImgSwitch = new TornStyleSwitch('隐藏头像', this.localConfigWrapper.config.HideProfileImg);
|
||||||
hideImgSwitch.getInput().addEventListener('change', () => {
|
this.block.append(hideImgSwitch.getBase());
|
||||||
document.body.classList.toggle('wh-hide_profile_img');
|
hideImgSwitch.getInput().addEventListener('change', () => {
|
||||||
this.localConfigWrapper.config.HideProfileImg = hideImgSwitch.getInput().checked;
|
document.body.classList.toggle('wh-hide_profile_img');
|
||||||
});
|
this.localConfigWrapper.config.HideProfileImg = hideImgSwitch.getInput().checked;
|
||||||
if (this.localConfigWrapper.config.ShowNameHistory) {
|
});
|
||||||
globVars.responseHandlers.push((...args: any[]) => this.responseHandler.apply(this, args));
|
if (this.localConfigWrapper.config.ShowNameHistory) {
|
||||||
|
globVars.responseHandlers.push((...args: any[]) => this.responseHandler.apply(this, args));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('隐藏头像时出错了', e.stack)
|
||||||
|
}
|
||||||
|
// bs估算
|
||||||
|
if (this.localConfigWrapper.config.isBSEstProfOn) {
|
||||||
|
try {
|
||||||
|
const apikey = localStorage.getItem('APIKey')
|
||||||
|
if (!apikey) {
|
||||||
|
this.msgWrapper.create('BS估算失败: 尚未设定APIKey', null, 'error')
|
||||||
|
}
|
||||||
|
const promise = fetchYata(parseInt(id), apikey)
|
||||||
|
const domNode = document.createElement('div')
|
||||||
|
domNode.innerHTML = 'BS估算中...'
|
||||||
|
domNode.classList.add('mt-4')
|
||||||
|
domNode.style.border = '1px solid green'
|
||||||
|
domNode.style.padding = '2px'
|
||||||
|
this.block.append(domNode)
|
||||||
|
const buildType = { Offensive: '攻击型', Defensive: '防御型', Balanced: '平衡型' }
|
||||||
|
promise.then(data => {
|
||||||
|
domNode.innerHTML = `<b>BS估算</b><br/>
|
||||||
|
BS: ${ toThousands(data.total) }<br/>
|
||||||
|
评分: ${ toThousands(data.score) }<br/>
|
||||||
|
风格: ${ buildType[data.type] }<br/>
|
||||||
|
偏差: ${ data.skewness }%<br/>
|
||||||
|
估算时间: ${ timePastFormat(Date.now() - data.timestamp * 1000) }前
|
||||||
|
`
|
||||||
|
}).catch(err => {
|
||||||
|
domNode.innerHTML = 'BS估算出错了: ' + err.message
|
||||||
|
throw new TypeError('BS估算出错了: ' + err.message)
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
this.msgWrapper.create('BS估算失败' + e.message, null, 'error')
|
||||||
|
throw new TypeError('BS估算失败' + e.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }) {
|
responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }) {
|
||||||
if (url.includes('profiles.php?step=getProfileData') && this.task) {
|
if (url.includes('profiles.php?step=getProfileData') && this.task) {
|
||||||
// 曾用名
|
// 曾用名
|
||||||
let nameHistoryNode;
|
const nameHistoryNode = document.createElement('p');
|
||||||
nameHistoryNode = document.createElement('p');
|
|
||||||
nameHistoryNode.innerHTML = '曾用名:';
|
nameHistoryNode.innerHTML = '曾用名:';
|
||||||
this.block.append(nameHistoryNode);
|
this.block.append(nameHistoryNode);
|
||||||
let resp = body.json as IUserProfileData;
|
let resp = body.json as IUserProfileData;
|
||||||
if (resp.userInformation.previousAliases.length > 0) {
|
if (resp.userInformation.previousAliases.length > 0) { // 曾用名列表
|
||||||
resp.userInformation.previousAliases.forEach(item => nameHistoryNode.innerHTML += item + ' ');
|
resp.userInformation.previousAliases.forEach(item => nameHistoryNode.innerHTML += item + ' ');
|
||||||
} else {
|
} else {
|
||||||
nameHistoryNode.innerHTML += '暂无';
|
nameHistoryNode.innerHTML += '暂无';
|
||||||
}
|
}
|
||||||
|
let lastAction = -1
|
||||||
|
let onlineStatusTitle = '-'
|
||||||
|
if (resp.basicInformation?.lastAction.seconds) {
|
||||||
|
lastAction = resp.basicInformation.lastAction.seconds
|
||||||
|
}
|
||||||
|
if (resp.basicInformation.icons) {
|
||||||
|
for (let i = 0; i < resp.basicInformation.icons.length; i++) {
|
||||||
|
let item = resp.basicInformation.icons[i]
|
||||||
|
if (item.id === 1) {
|
||||||
|
onlineStatusTitle = '🟢️ 在线'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (item.id === 62) {
|
||||||
|
onlineStatusTitle = '🟡 挂机'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (item.id === 2) {
|
||||||
|
onlineStatusTitle = '⚪ 离线'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const lastActionNode = document.createElement('p')
|
||||||
|
lastActionNode.innerHTML = `${ onlineStatusTitle } ${ this.commonUtils.secondsFormat(lastAction) }`
|
||||||
|
this.block.append(lastActionNode)
|
||||||
this.task = false;
|
this.task = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,8 @@ import ClassName from "../../container/ClassName";
|
|||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
import NetHighLvlWrapper, { BATTLE_STAT } from "../utils/NetHighLvlWrapper";
|
import NetHighLvlWrapper, { BATTLE_STAT } from "../utils/NetHighLvlWrapper";
|
||||||
import Alert from "../utils/Alert";
|
import { InjectionKey } from "vue";
|
||||||
|
import MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
|
||||||
type GymResponse = {
|
type GymResponse = {
|
||||||
success: boolean,
|
success: boolean,
|
||||||
@ -19,21 +20,27 @@ export default class QuickGymTrain {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly netHighLvlWrapper: NetHighLvlWrapper,
|
private readonly netHighLvlWrapper: NetHighLvlWrapper,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
doTrain() {
|
doTrain(type = BATTLE_STAT.STR, count = 199) {
|
||||||
window.setTimeout(async () => {
|
window.setTimeout(async () => {
|
||||||
let resObj: GymResponse;
|
let resObj: GymResponse;
|
||||||
try {
|
try {
|
||||||
resObj = JSON.parse(await this.netHighLvlWrapper.doGymTrain(BATTLE_STAT.STR, 199))
|
resObj = JSON.parse(await this.netHighLvlWrapper.doGymTrain(type, count))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
resObj = { success: false, message: '解析失败' };
|
resObj = { success: false, message: '解析失败' };
|
||||||
this.logger.error(e.stack || e.message || e);
|
this.logger.error(e.stack || e.message || e);
|
||||||
}
|
}
|
||||||
let msgRs = resObj.success ? '成功' : '失败';
|
let msgRs = resObj.success ? '成功' : '失败';
|
||||||
let msgMsg = resObj.message || resObj.text || resObj.error;
|
let msgMsg = resObj.message || resObj.text || resObj.error;
|
||||||
new Alert('锻炼结果: ' + msgRs + '<br/>提示: ' + (resObj.gainMessage || msgMsg));
|
this.msgWrapper.create(
|
||||||
|
'锻炼结果: ' + msgRs + '<br/>提示: ' + (resObj.gainMessage || msgMsg),
|
||||||
|
{}, resObj.success ? 'success' : 'error'
|
||||||
|
);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const QuickGymTrainKey = Symbol('QuickGymTrainKey') as InjectionKey<QuickGymTrain>;
|
||||||
|
|||||||
@ -4,10 +4,26 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import IFeature from "../../man/IFeature";
|
||||||
|
|
||||||
@ClassName('SearchHelper')
|
@ClassName('SearchHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class SearchHelper {
|
export default class SearchHelper implements IFeature {
|
||||||
|
description(): string {
|
||||||
|
return "搜索助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/page\.php\?sid=UserList/];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
|||||||
@ -1,24 +1,41 @@
|
|||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../utils/InfoUtils";
|
||||||
import Log from "../Log";
|
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import MathUtils from "../utils/MathUtils";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import IFeature from "../../man/IFeature";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 老虎机批量购买助手
|
* 老虎机批量购买助手
|
||||||
*/
|
*/
|
||||||
@ClassName("SlotsHelper")
|
@ClassName("SlotsHelper")
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class SlotsHelper {
|
export default class SlotsHelper implements IFeature {
|
||||||
|
description(): string {
|
||||||
|
return "老虎机批量购买助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/loader\.php\?sid=slots/];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly mathUtils: MathUtils,
|
private readonly mathUtils: MathUtils,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly fetchUtils: FetchUtils,
|
private readonly fetchUtils: FetchUtils,
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +83,7 @@ export default class SlotsHelper {
|
|||||||
try {
|
try {
|
||||||
await this.goBtnHandler(ev, ret)
|
await this.goBtnHandler(ev, ret)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e.stack || e);
|
this.logger.error(e.stack || e);
|
||||||
}
|
}
|
||||||
goBtn.disabled = false;
|
goBtn.disabled = false;
|
||||||
});
|
});
|
||||||
@ -119,7 +136,7 @@ export default class SlotsHelper {
|
|||||||
msgBox.innerHTML += '<br/>已停止, ';
|
msgBox.innerHTML += '<br/>已停止, ';
|
||||||
msgBox.innerHTML += bang ? '血' : '小';
|
msgBox.innerHTML += bang ? '血' : '小';
|
||||||
msgBox.innerHTML += profit > 0 ? '赚' : '亏';
|
msgBox.innerHTML += profit > 0 ? '赚' : '亏';
|
||||||
Log.info("[goBtnHandler]结束", { cash, tokens, count, price, wonTotal });
|
this.logger.info("[goBtnHandler]结束", { cash, tokens, count, price, wonTotal });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { chatDict, eventsDict, headerDict, propertyDict, sidebarDict } from "../../dictionary/translation";
|
import { chatDict, eventsDict, headerDict, propertyDict, sidebarDict } from "../../dictionary/translation";
|
||||||
import Log from "../Log";
|
|
||||||
import Timer from "../utils/Timer";
|
import Timer from "../utils/Timer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,7 +9,7 @@ export default class Translate {
|
|||||||
public translateVer: string = '1.0';
|
public translateVer: string = '1.0';
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
Log.info('翻译开始');
|
// Log.info('翻译开始');
|
||||||
let start = new Timer();
|
let start = new Timer();
|
||||||
// 时分秒转换
|
// 时分秒转换
|
||||||
String.prototype.replaceHMS = function replaceHMS() {
|
String.prototype.replaceHMS = function replaceHMS() {
|
||||||
@ -39,7 +38,7 @@ export default class Translate {
|
|||||||
this.chatTranslate();
|
this.chatTranslate();
|
||||||
this.playerSearchBoxTrans();
|
this.playerSearchBoxTrans();
|
||||||
this.urlMatchPageTranslate(window.location.href);
|
this.urlMatchPageTranslate(window.location.href);
|
||||||
Log.info('翻译结束, 耗时' + start.getTimeMs());
|
// Log.info('翻译结束, 耗时' + start.getTimeMs());
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -374,8 +374,7 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
name.innerText = `${ name.innerText } ${ nameZh }`;
|
name.innerText = `${ name.innerText } ${ nameZh }`;
|
||||||
}
|
}
|
||||||
// 操作按钮
|
// 操作按钮
|
||||||
let actions = elem.querySelectorAll('.icon-h');
|
elem.querySelectorAll('.icon-h').forEach(action => {
|
||||||
actions.forEach(action => {
|
|
||||||
let attrTitle = action.getAttribute('title');
|
let attrTitle = action.getAttribute('title');
|
||||||
// TODO
|
// TODO
|
||||||
let zh = itemPageDict[attrTitle];
|
let zh = itemPageDict[attrTitle];
|
||||||
|
|||||||
@ -1,79 +0,0 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
|
||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
|
||||||
import Popup from "../utils/Popup";
|
|
||||||
import STOCK_IMG_HTML from "../../../static/html/stock_img.html";
|
|
||||||
import * as FILTER from "../../../static/json/for_stock_item_filter.json";
|
|
||||||
import WindowActiveState from "./WindowActiveState";
|
|
||||||
import { Injectable } from "../../container/Injectable";
|
|
||||||
import ClassName from "../../container/ClassName";
|
|
||||||
import Logger from "../Logger";
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
@ClassName('TravelItem')
|
|
||||||
export default class TravelItem {
|
|
||||||
private readonly apiUrl: string = 'https://yata.yt/api/v1/travel/export/';
|
|
||||||
private foreignStockInfo: any = null;
|
|
||||||
|
|
||||||
public constructor(
|
|
||||||
private readonly windowActiveState: WindowActiveState,
|
|
||||||
private readonly logger: Logger,
|
|
||||||
private readonly commonUtils: CommonUtils,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public init() {
|
|
||||||
|
|
||||||
window.setInterval(async () => {
|
|
||||||
if (!this.windowActiveState.get()) return;
|
|
||||||
this.logger.info('COFetch ', this.apiUrl);
|
|
||||||
try {
|
|
||||||
this.foreignStockInfo = JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
|
||||||
} catch (e) {
|
|
||||||
this.logger.error('解析错误', e.stack || e.message || e);
|
|
||||||
}
|
|
||||||
this.logger.info({ info: 'TravelItem 跨域返回', 'returned': this.foreignStockInfo });
|
|
||||||
}, 30 * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 呈现内容
|
|
||||||
public async clickHandler(): Promise<void> {
|
|
||||||
if (this.commonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
|
||||||
new Popup(STOCK_IMG_HTML.replace('{{}}', performance.now().toString()), '飞花库存');
|
|
||||||
} else {
|
|
||||||
const popup = new Popup("请稍后 " + CommonUtils.loading_gif_html(), '飞花库存');
|
|
||||||
let table = `<table><tr><th colspan="2">目的地 - 更新时间</th><th colspan="3">库存</th></tr>`;
|
|
||||||
const dest = FILTER.default;
|
|
||||||
const now = new Date();
|
|
||||||
const res = await this.get();
|
|
||||||
this.logger.info({ res })
|
|
||||||
if (!res || !res.stocks) return;
|
|
||||||
dest.forEach(el => {
|
|
||||||
const update = (now.getTime() - new Date(res.stocks[el.name]['update'] * 1000).getTime()) / 1000 | 0
|
|
||||||
table += `<tr><td>${ el.show }</td><td>${ update / 60 | 0 }分${ update % 60 | 0 }秒前</td>`;
|
|
||||||
let count = 0;
|
|
||||||
res.stocks[el.name]['stocks'].forEach(stock => {
|
|
||||||
if (el.stocks[stock.name]) {
|
|
||||||
table += `<td${ stock['quantity'] === 0 ? ' style="background-color:#f44336;color:white;border-color:#000;"' : '' }>${ el.stocks[stock.name] } (${ stock['quantity'] })</td>`;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
while (count < 3) {
|
|
||||||
count++;
|
|
||||||
table += '<td></td>';
|
|
||||||
}
|
|
||||||
table += '</tr>';
|
|
||||||
});
|
|
||||||
table += '</table>';
|
|
||||||
popup.getElement().innerHTML = table;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async get() {
|
|
||||||
try {
|
|
||||||
return this.foreignStockInfo ||= JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
|
||||||
} catch (e) {
|
|
||||||
this.logger.error('解析出错', e.stack || e.message || e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -18,6 +18,7 @@ export default class WindowActiveState {
|
|||||||
addEventListener('blur', () => this.isFocus = false);
|
addEventListener('blur', () => this.isFocus = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 当前实例是否激活
|
||||||
get(): boolean {
|
get(): boolean {
|
||||||
// 当前窗口获得了焦点 优先级最高
|
// 当前窗口获得了焦点 优先级最高
|
||||||
if (this.isFocus) return true;
|
if (this.isFocus) return true;
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import MathUtils from "../utils/MathUtils";
|
|||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import IFeature from "../../man/IFeature";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 寻找木桩
|
* 寻找木桩
|
||||||
@ -14,8 +15,35 @@ import { Injectable } from "../../container/Injectable";
|
|||||||
*/
|
*/
|
||||||
@ClassName('XZMZ')
|
@ClassName('XZMZ')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class XZMZ {
|
export default class XZMZ implements IFeature {
|
||||||
className = 'XZMZ';
|
description(): string {
|
||||||
|
return "寻找木桩";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/item.php\?temp=4/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
let hasInit: boolean = false
|
||||||
|
let handle = () => {
|
||||||
|
if (!hasInit && window.location.hash === '#xunzhaomuzhuang') {
|
||||||
|
this.init()
|
||||||
|
hasInit = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.addEventListener('hashchange', handle)
|
||||||
|
handle()
|
||||||
|
}
|
||||||
|
|
||||||
private mainRoleContainer: HTMLElement;
|
private mainRoleContainer: HTMLElement;
|
||||||
private IDList: number[];
|
private IDList: number[];
|
||||||
private btn: HTMLButtonElement;
|
private btn: HTMLButtonElement;
|
||||||
|
|||||||
@ -96,9 +96,25 @@ class DefaultConfigType {
|
|||||||
// 迷你资料卡显示上次行动时间
|
// 迷你资料卡显示上次行动时间
|
||||||
ShowMiniProfLastAct = true;
|
ShowMiniProfLastAct = true;
|
||||||
|
|
||||||
|
// 登陆邮箱
|
||||||
|
@Notified()
|
||||||
|
autoLoginEmail = '';
|
||||||
|
// 登陆密码
|
||||||
|
autoLoginPwd = '';
|
||||||
|
|
||||||
// 自定义css
|
// 自定义css
|
||||||
@Notified()
|
@Notified()
|
||||||
CustomCss = '';
|
CustomCss = '';
|
||||||
|
|
||||||
|
monitorOn = ['drugCDMonitor']
|
||||||
|
drugCDMonitorInterval = 60000
|
||||||
|
|
||||||
|
// mini profile显示bs估算
|
||||||
|
@Notified()
|
||||||
|
isBSEstMiniProfOn = false
|
||||||
|
// profile页面显示bs估算
|
||||||
|
@Notified()
|
||||||
|
isBSEstProfOn = true
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Config = DefaultConfigType;
|
export type Config = DefaultConfigType;
|
||||||
|
|||||||
@ -3,11 +3,8 @@ import Alert from "../utils/Alert";
|
|||||||
import DialogMsgBox from "../utils/DialogMsgBox";
|
import DialogMsgBox from "../utils/DialogMsgBox";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import { MenuItemConfig } from "../ZhongIcon";
|
import { MenuItemConfig } from "../ZhongIcon";
|
||||||
import IFrameCrimeHandler from "./IFrameCrimeHandler";
|
|
||||||
import loadGS from "../../func/module/loadGS";
|
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import { Container } from "../../container/Container";
|
|
||||||
|
|
||||||
@ClassName('AdditionalSettingsHandler')
|
@ClassName('AdditionalSettingsHandler')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -20,26 +17,6 @@ export default class AdditionalSettingsHandler {
|
|||||||
|
|
||||||
public show(): void {
|
public show(): void {
|
||||||
let pop = new Popup('', '更多设定');
|
let pop = new Popup('', '更多设定');
|
||||||
// let insertHtml = '<p><button class="torn-btn">清空设置</button></p><p><button class="torn-btn">通知权限</button></p><p><button class="torn-btn">外部数据权限</button></p>';
|
|
||||||
// pop.getElement().insertAdjacentHTML('beforeend', insertHtml);
|
|
||||||
// let [btn1, btn2, btn3] = Array.from(pop.getElement().querySelectorAll('button'));
|
|
||||||
// btn1.addEventListener('click', () => {
|
|
||||||
// new DialogMsgBox('将清空所有芜湖助手相关设置并刷新页面,确定?', {
|
|
||||||
// callback: () => {
|
|
||||||
// localStorage.removeItem('wh_trv_alarm');
|
|
||||||
// localStorage.removeItem('wh_trans_settings');
|
|
||||||
// localStorage.removeItem('whuuid');
|
|
||||||
// localStorage.removeItem('wh-gs-storage');
|
|
||||||
// localStorage.removeItem('WHTEST');
|
|
||||||
// new Alert('已清空,刷新页面');
|
|
||||||
// window.location.reload();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// btn2.addEventListener('click', () => {
|
|
||||||
// });
|
|
||||||
// btn3.addEventListener('click', () => {
|
|
||||||
// });
|
|
||||||
|
|
||||||
let menuList: MenuItemConfig[] = [
|
let menuList: MenuItemConfig[] = [
|
||||||
{
|
{
|
||||||
@ -65,20 +42,6 @@ export default class AdditionalSettingsHandler {
|
|||||||
domType: 'button', domId: '', domText: '第三方API通信权限', clickFunc() {
|
domType: 'button', domId: '', domText: '第三方API通信权限', clickFunc() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
domType: 'button', domId: '', domText: '小窗犯罪', clickFunc() {
|
|
||||||
Container.factory(IFrameCrimeHandler).handle()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
domType: 'button',
|
|
||||||
domId: '',
|
|
||||||
domText: '飞贼小助手',
|
|
||||||
tip: '加载从PC端移植的伞佬的油猴版飞贼小助手',
|
|
||||||
clickFunc: () => {
|
|
||||||
loadGS(this.commonUtils.getScriptEngine())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
menuList.forEach(i => pop.element.append(this.commonUtils.elemGenerator(i, pop.element)));
|
menuList.forEach(i => pop.element.append(this.commonUtils.elemGenerator(i, pop.element)));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,66 +1,70 @@
|
|||||||
import Popup from "../utils/Popup";
|
// import Popup from "../utils/Popup";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
// import CommonUtils from "../utils/CommonUtils";
|
||||||
import MDUtils from "../utils/MDUtils";
|
// import MDUtils from "../utils/MDUtils";
|
||||||
import Log from "../Log";
|
// import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
|
||||||
import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
|
// import Provider from "../provider/Provider";
|
||||||
import Provider from "../provider/Provider";
|
// import ClassName from "../../container/ClassName";
|
||||||
import ClassName from "../../container/ClassName";
|
// import { Injectable } from "../../container/Injectable";
|
||||||
import { Injectable } from "../../container/Injectable";
|
// import { Container } from "../../container/Container";
|
||||||
import { Container } from "../../container/Container";
|
// import Logger from "../Logger";
|
||||||
|
//
|
||||||
@ClassName('ChangeLogHandler')
|
// /**
|
||||||
@Injectable()
|
// * @deprecated
|
||||||
class ChangeLogHandler extends Provider {
|
// */
|
||||||
constructor(
|
// @ClassName('ChangeLogHandler')
|
||||||
private readonly mdUtils: MDUtils,
|
// @Injectable()
|
||||||
) {
|
// export class ChangeLogHandler extends Provider {
|
||||||
super();
|
// constructor(
|
||||||
}
|
// private readonly mdUtils: MDUtils,
|
||||||
|
// private readonly logger: Logger,
|
||||||
public show(): void {
|
// ) {
|
||||||
let popup = new Popup(
|
// super();
|
||||||
'更新历史:<br/><a target="_blank" href="https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md">https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md</a><br/>',
|
// }
|
||||||
'更新历史'
|
//
|
||||||
).element;
|
// public show(): void {
|
||||||
popup.classList.add('wh-changeLog');
|
// let popup = new Popup(
|
||||||
let progressBar = document.createElement('div');
|
// '更新历史:<br/><a target="_blank" href="https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md">https://gitlab.com/JJins/wuhu-torn-helper/-/blob/dev/CHANGELOG.md</a><br/>',
|
||||||
progressBar.style.height = '2px';
|
// '更新历史'
|
||||||
progressBar.style.width = '1%';
|
// ).element;
|
||||||
progressBar.style.backgroundColor = 'red';
|
// popup.classList.add('wh-changeLog');
|
||||||
let progressText = document.createElement('p');
|
// let progressBar = document.createElement('div');
|
||||||
progressText.innerText = '加载更新文件……';
|
// progressBar.style.height = '2px';
|
||||||
progressText.style.textAlign = 'center';
|
// progressBar.style.width = '1%';
|
||||||
let style = document.createElement('style');
|
// progressBar.style.backgroundColor = 'red';
|
||||||
style.innerHTML = `.wh-changeLog h2,.wh-changeLog h3,.wh-changeLog h4 {margin:8px 0;}.wh-changeLog li{list-style: inside;}`;
|
// let progressText = document.createElement('p');
|
||||||
|
// progressText.innerText = '加载更新文件……';
|
||||||
popup.append(progressBar, progressText, style);
|
// progressText.style.textAlign = 'center';
|
||||||
|
// let style = document.createElement('style');
|
||||||
CommonUtils
|
// style.innerHTML = `.wh-changeLog h2,.wh-changeLog h3,.wh-changeLog h4 {margin:8px 0;}.wh-changeLog li{list-style: inside;}`;
|
||||||
.COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md?' + performance.now())
|
//
|
||||||
.then(update => {
|
// popup.append(progressBar, progressText, style);
|
||||||
progressBar.style.width = '60%';
|
//
|
||||||
progressText.innerText = '解析中……';
|
// CommonUtils
|
||||||
let md = this.mdUtils.parse(update);
|
// .COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md?' + performance.now())
|
||||||
popup.append(md);
|
// .then(update => {
|
||||||
progressBar.style.width = '100%';
|
// progressBar.style.width = '60%';
|
||||||
progressText.innerText = '加载完成';
|
// progressText.innerText = '解析中……';
|
||||||
|
// let md = this.mdUtils.parse(update);
|
||||||
window.setTimeout(() => {
|
// popup.append(md);
|
||||||
progressBar.remove();
|
// progressBar.style.width = '100%';
|
||||||
progressText.remove()
|
// progressText.innerText = '加载完成';
|
||||||
}, 3000);
|
//
|
||||||
})
|
// window.setTimeout(() => {
|
||||||
.catch(e => {
|
// progressBar.remove();
|
||||||
Log.error(e);
|
// progressText.remove()
|
||||||
progressBar.remove();
|
// }, 3000);
|
||||||
progressText.innerText = '无法加载';
|
// })
|
||||||
});
|
// .catch(e => {
|
||||||
}
|
// this.logger.error(e);
|
||||||
|
// progressBar.remove();
|
||||||
}
|
// progressText.innerText = '无法加载';
|
||||||
|
// });
|
||||||
export default {
|
// }
|
||||||
domType: MENU_ITEM_TYPE.BUTTON,
|
//
|
||||||
domText: '🐞 更新历史',
|
// }
|
||||||
clickFunc: () => Container.factory(ChangeLogHandler).show()
|
//
|
||||||
};
|
// export default {
|
||||||
|
// domType: MENU_ITEM_TYPE.BUTTON,
|
||||||
|
// domText: '🐞 更新历史',
|
||||||
|
// clickFunc: () => Container.factory(ChangeLogHandler).show()
|
||||||
|
// };
|
||||||
|
|||||||
@ -1,97 +1,97 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
// import CommonUtils from "../utils/CommonUtils";
|
||||||
import Popup from "../utils/Popup";
|
// import Popup from "../utils/Popup";
|
||||||
import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
|
// import QUICK_CRIMES_HTML from "../../../static/html/quick_crimes.html";
|
||||||
import ClassName from "../../container/ClassName";
|
// import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
// import { Injectable } from "../../container/Injectable";
|
||||||
|
//
|
||||||
@ClassName('IFrameCrimeHandler')
|
// @ClassName('IFrameCrimeHandler')
|
||||||
@Injectable()
|
// @Injectable()
|
||||||
export default class IFrameCrimeHandler {
|
// export default class IFrameCrimeHandler {
|
||||||
|
//
|
||||||
public handle(): void {
|
// public handle(): void {
|
||||||
// 弹出小窗口
|
// // 弹出小窗口
|
||||||
const ifHTML = `<iframe src="/crimes.php?step=main" style="width:100%;max-width: 450px;margin: 0 auto;display: none;height: 340px;"></iframe>`;
|
// const ifHTML = `<iframe src="/crimes.php?step=main" style="width:100%;max-width: 450px;margin: 0 auto;display: none;height: 340px;"></iframe>`;
|
||||||
const popup_insert = `<p>加载中请稍后${ CommonUtils.loading_gif_html() }</p><div id="wh-quick-crime-if-container"></div>`;
|
// const popup_insert = `<p>加载中请稍后${ CommonUtils.loading_gif_html() }</p><div id="wh-quick-crime-if-container"></div>`;
|
||||||
const $popup = new Popup(popup_insert, '小窗快速犯罪').getElement();
|
// const $popup = new Popup(popup_insert, '小窗快速犯罪').getElement();
|
||||||
// 运行状态node
|
// // 运行状态node
|
||||||
let loading_node = $popup.querySelector('p:first-of-type');
|
// let loading_node = $popup.querySelector('p:first-of-type');
|
||||||
// if容器
|
// // if容器
|
||||||
const if_cont = $popup.querySelector('#wh-quick-crime-if-container');
|
// const if_cont = $popup.querySelector('#wh-quick-crime-if-container');
|
||||||
if_cont.innerHTML = ifHTML;
|
// if_cont.innerHTML = ifHTML;
|
||||||
|
//
|
||||||
// if内未加载脚本时插入的快捷crime node
|
// // if内未加载脚本时插入的快捷crime node
|
||||||
const mobile_prepend_node = document.createElement('div');
|
// const mobile_prepend_node = document.createElement('div');
|
||||||
mobile_prepend_node.classList.add('wh-translate');
|
// mobile_prepend_node.classList.add('wh-translate');
|
||||||
mobile_prepend_node.innerHTML = QUICK_CRIMES_HTML;
|
// mobile_prepend_node.innerHTML = QUICK_CRIMES_HTML;
|
||||||
|
//
|
||||||
// if对象加载后运行
|
// // if对象加载后运行
|
||||||
let cIframe = $popup.querySelector('iframe');
|
// let cIframe = $popup.querySelector('iframe');
|
||||||
|
//
|
||||||
// 加载状态
|
// // 加载状态
|
||||||
const if_onload_func = () => {
|
// const if_onload_func = () => {
|
||||||
// if内部文档对象
|
// // if内部文档对象
|
||||||
const ifDocu = cIframe.contentWindow.document;
|
// const ifDocu = cIframe.contentWindow.document;
|
||||||
// 内部插件运行flag
|
// // 内部插件运行flag
|
||||||
const ifWH = cIframe.contentWindow.WHTRANS;
|
// const ifWH = cIframe.contentWindow.WHTRANS;
|
||||||
// 文档加载完成后移除
|
// // 文档加载完成后移除
|
||||||
if (!!loading_node) loading_node.remove();
|
// if (!!loading_node) loading_node.remove();
|
||||||
// 文档加载完成后才显示if
|
// // 文档加载完成后才显示if
|
||||||
cIframe.style.display = 'block';
|
// cIframe.style.display = 'block';
|
||||||
// 验证码flag
|
// // 验证码flag
|
||||||
const isValidate = ifDocu.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
// const isValidate = ifDocu.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
||||||
// 如果iframe内部未运行脚本
|
// // 如果iframe内部未运行脚本
|
||||||
if (ifWH === undefined) {
|
// if (ifWH === undefined) {
|
||||||
// 隐藏顶部
|
// // 隐藏顶部
|
||||||
CommonUtils.elementReady('#header-root', ifDocu).then(e => e.style.display = 'none');
|
// CommonUtils.elementReady('#header-root', ifDocu).then(e => e.style.display = 'none');
|
||||||
// 隐藏4条
|
// // 隐藏4条
|
||||||
CommonUtils.elementReady('#sidebarroot', ifDocu).then(e => e.style.display = 'none');
|
// CommonUtils.elementReady('#sidebarroot', ifDocu).then(e => e.style.display = 'none');
|
||||||
// 隐藏聊天
|
// // 隐藏聊天
|
||||||
CommonUtils.elementReady('#chatRoot', ifDocu).then(e => e.style.display = 'none');
|
// CommonUtils.elementReady('#chatRoot', ifDocu).then(e => e.style.display = 'none');
|
||||||
// 非验证码页面隐藏滚动条
|
// // 非验证码页面隐藏滚动条
|
||||||
if (!isValidate) ifDocu.body.style.overflow = 'hidden';
|
// if (!isValidate) ifDocu.body.style.overflow = 'hidden';
|
||||||
// 调整容器位置
|
// // 调整容器位置
|
||||||
CommonUtils.elementReady('.content-wrapper', ifDocu).then(elem => {
|
// CommonUtils.elementReady('.content-wrapper', ifDocu).then(elem => {
|
||||||
// 加入
|
// // 加入
|
||||||
elem.prepend(mobile_prepend_node);
|
// elem.prepend(mobile_prepend_node);
|
||||||
elem.style.margin = '0px';
|
// elem.style.margin = '0px';
|
||||||
elem.style.position = 'absolute';
|
// elem.style.position = 'absolute';
|
||||||
elem.style.top = '-35px';
|
// elem.style.top = '-35px';
|
||||||
new MutationObserver((m, o) => {
|
// new MutationObserver((m, o) => {
|
||||||
o.disconnect();
|
// o.disconnect();
|
||||||
if (!elem.querySelector('.wh-translate')) elem.prepend(mobile_prepend_node);
|
// if (!elem.querySelector('.wh-translate')) elem.prepend(mobile_prepend_node);
|
||||||
o.observe(elem, { childList: true, subtree: true });
|
// o.observe(elem, { childList: true, subtree: true });
|
||||||
})
|
// })
|
||||||
.observe(elem, { childList: true, subtree: true });
|
// .observe(elem, { childList: true, subtree: true });
|
||||||
});
|
// });
|
||||||
// 隐藏返回顶部按钮
|
// // 隐藏返回顶部按钮
|
||||||
CommonUtils.elementReady('#go-to-top-btn button', ifDocu).then(e => e.style.display = 'none');
|
// CommonUtils.elementReady('#go-to-top-btn button', ifDocu).then(e => e.style.display = 'none');
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
cIframe.onload = if_onload_func;
|
// cIframe.onload = if_onload_func;
|
||||||
|
//
|
||||||
// 超时判断
|
// // 超时判断
|
||||||
let time_counter = 0;
|
// let time_counter = 0;
|
||||||
let time_out_id = window.setInterval(() => {
|
// let time_out_id = window.setInterval(() => {
|
||||||
loading_node = $popup.querySelector('p:first-of-type');
|
// loading_node = $popup.querySelector('p:first-of-type');
|
||||||
if (!loading_node) {
|
// if (!loading_node) {
|
||||||
clearInterval(time_out_id);
|
// clearInterval(time_out_id);
|
||||||
time_out_id = undefined;
|
// time_out_id = undefined;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
time_counter++;
|
// time_counter++;
|
||||||
if (time_counter > 0 && !loading_node.querySelector('button')) {
|
// if (time_counter > 0 && !loading_node.querySelector('button')) {
|
||||||
const reload_btn = document.createElement('button');
|
// const reload_btn = document.createElement('button');
|
||||||
reload_btn.innerHTML = '重新加载';
|
// reload_btn.innerHTML = '重新加载';
|
||||||
reload_btn.onclick = () => {
|
// reload_btn.onclick = () => {
|
||||||
reload_btn.remove();
|
// reload_btn.remove();
|
||||||
time_counter = 0;
|
// time_counter = 0;
|
||||||
if_cont.innerHTML = null;
|
// if_cont.innerHTML = null;
|
||||||
if_cont.innerHTML = ifHTML;
|
// if_cont.innerHTML = ifHTML;
|
||||||
cIframe = $popup.querySelector('iframe');
|
// cIframe = $popup.querySelector('iframe');
|
||||||
cIframe.onload = if_onload_func;
|
// cIframe.onload = if_onload_func;
|
||||||
};
|
// };
|
||||||
loading_node.append(reload_btn);
|
// loading_node.append(reload_btn);
|
||||||
}
|
// }
|
||||||
}, 1000);
|
// }, 1000);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
@ -2,10 +2,13 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import QUICK_FLY_CSS from "../../../static/css/quick_fly.module.css";
|
import QUICK_FLY_CSS from "../../../static/css/quick_fly.module.css";
|
||||||
import QUICK_FLY_HTML from "../../../static/html/quick_fly.html";
|
import QUICK_FLY_HTML from "../../../static/html/quick_fly.html";
|
||||||
import Alert from "../utils/Alert";
|
import Alert from "../utils/Alert";
|
||||||
import TravelItem from "../action/TravelItem";
|
import TravelItem from "../../feature/TravelItem";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
|
import MsgWrapper from "../utils/MsgWrapper";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
import NetHighLvlWrapper from "../utils/NetHighLvlWrapper";
|
||||||
|
|
||||||
@ClassName('QuickFlyBtnHandler')
|
@ClassName('QuickFlyBtnHandler')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -16,6 +19,9 @@ export default class QuickFlyBtnHandler {
|
|||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly travelItem: TravelItem,
|
private readonly travelItem: TravelItem,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
|
// private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
|
private readonly netHighLvlWrapper: NetHighLvlWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +61,7 @@ export default class QuickFlyBtnHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 起飞目的地id
|
// 起飞目的地id
|
||||||
private static getDestId(dest): number {
|
private static getDestId(dest: number): number {
|
||||||
// 墨、开、加、夏、英、阿、瑞s、立本、祖、迪、南
|
// 墨、开、加、夏、英、阿、瑞s、立本、祖、迪、南
|
||||||
return [2, 12, 9, 3, 10, 7, 8, 5, 6, 11, 4][dest];
|
return [2, 12, 9, 3, 10, 7, 8, 5, 6, 11, 4][dest];
|
||||||
}
|
}
|
||||||
@ -114,4 +120,37 @@ export default class QuickFlyBtnHandler {
|
|||||||
showTime();
|
showTime();
|
||||||
yaoCD.innerHTML = `药CD剩余:${ CommonUtils.getYaoCD() }`;
|
yaoCD.innerHTML = `药CD剩余:${ CommonUtils.getYaoCD() }`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async directFly(destIndex: number, typeIndex: number) {
|
||||||
|
// 获取key
|
||||||
|
// if(false){
|
||||||
|
// let key;
|
||||||
|
// try {
|
||||||
|
// const resp = await (await fetch('/travelagency.php')).text();
|
||||||
|
// key = resp.match(/data-key="([0-9]+)"/)[1];
|
||||||
|
// } catch (e) {
|
||||||
|
// this.msgWrapper.create('起飞参数获取失败', {}, 'error');
|
||||||
|
// this.logger.error(e.stack);
|
||||||
|
// throw new Error('起飞参数获取失败');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
let msg: string;
|
||||||
|
try {
|
||||||
|
msg = await this.netHighLvlWrapper.doTravelFly(QuickFlyBtnHandler.getDestId(destIndex), null, ['standard', 'airstrip', 'private', 'business'][typeIndex])
|
||||||
|
const response = JSON.parse(msg);
|
||||||
|
if (!response.success) {
|
||||||
|
this.msgWrapper.create('起飞失败 ' + response.error, {}, 'error');
|
||||||
|
this.logger.error('起飞失败 ' + response.error, response.err);
|
||||||
|
throw new Error('起飞失败 ' + response.error);
|
||||||
|
}
|
||||||
|
console.log(msg);
|
||||||
|
} catch (e) {
|
||||||
|
this.msgWrapper.create('起飞时出现错误 ' + e.message, {}, 'error');
|
||||||
|
this.logger.error(e.stack);
|
||||||
|
throw new Error('起飞时出现错误 ' + e.message);
|
||||||
|
}
|
||||||
|
this.msgWrapper.create('已起飞', {}, 'success');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const QuickFlyBtnHandlerKey = Symbol('QuickFlyBtnHandlerKey') as InjectionKey<QuickFlyBtnHandler>
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { MenuItemConfig } from "../ZhongIcon";
|
import { MenuItemConfig } from "../ZhongIcon";
|
||||||
import Log from "../Log";
|
|
||||||
import Timer from "../utils/Timer";
|
import Timer from "../utils/Timer";
|
||||||
import BuyBeerHelper from "../action/BuyBeerHelper";
|
import BuyBeerHelper from "../../feature/BuyBeerHelper";
|
||||||
import UpdateTranslateDict from "./UpdateTranslateDict";
|
import UpdateTranslateDict from "./UpdateTranslateDict";
|
||||||
import landedRedirect from "../../func/module/landedRedirect";
|
import landedRedirect from "../../func/module/landedRedirect";
|
||||||
import Alert from "../utils/Alert";
|
import Alert from "../utils/Alert";
|
||||||
@ -15,6 +14,7 @@ import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
|
|||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import { Container } from "../../container/Container";
|
import { Container } from "../../container/Container";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
@ClassName('SettingsHandler')
|
@ClassName('SettingsHandler')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -30,6 +30,7 @@ class SettingsHandler extends Provider {
|
|||||||
private readonly customCssHandler: CustomCssHandler,
|
private readonly customCssHandler: CustomCssHandler,
|
||||||
private readonly viewLogsHandler: ViewLogsHandler,
|
private readonly viewLogsHandler: ViewLogsHandler,
|
||||||
private readonly additionalSettingsHandler: AdditionalSettingsHandler,
|
private readonly additionalSettingsHandler: AdditionalSettingsHandler,
|
||||||
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.constructWuhuSettingList();
|
this.constructWuhuSettingList();
|
||||||
@ -37,7 +38,7 @@ class SettingsHandler extends Provider {
|
|||||||
|
|
||||||
public show(): void {
|
public show(): void {
|
||||||
let startTime = new Timer();
|
let startTime = new Timer();
|
||||||
Log.info('构造设置开始');
|
this.logger.info('构造设置开始');
|
||||||
let pop = new Popup(CommonUtils.loading_gif_html(), '芜湖助手设置');
|
let pop = new Popup(CommonUtils.loading_gif_html(), '芜湖助手设置');
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
let tmp = document.createElement('div');
|
let tmp = document.createElement('div');
|
||||||
@ -49,14 +50,14 @@ class SettingsHandler extends Provider {
|
|||||||
pop.getElement().innerHTML = '';
|
pop.getElement().innerHTML = '';
|
||||||
pop.getElement().appendChild(tmp);
|
pop.getElement().appendChild(tmp);
|
||||||
(window.initializeTooltip) && (window.initializeTooltip('#wh-popup-cont', 'white-tooltip'));
|
(window.initializeTooltip) && (window.initializeTooltip('#wh-popup-cont', 'white-tooltip'));
|
||||||
Log.info('构造设置结束 ' + startTime.getTimeMs());
|
this.logger.info('构造设置结束 ' + startTime.getTimeMs());
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置
|
// 设置
|
||||||
private constructWuhuSettingList(): SettingsHandler {
|
private constructWuhuSettingList(): SettingsHandler {
|
||||||
let timer = new Timer();
|
let timer = new Timer();
|
||||||
Log.info('构造设置列表开始');
|
this.logger.info('构造设置列表开始');
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
let beer = this.buyBeerHelper;
|
let beer = this.buyBeerHelper;
|
||||||
@ -572,7 +573,7 @@ class SettingsHandler extends Provider {
|
|||||||
clickFunc: () => this.additionalSettingsHandler.show()
|
clickFunc: () => this.additionalSettingsHandler.show()
|
||||||
});
|
});
|
||||||
|
|
||||||
Log.info('构造设置列表结束' + timer.getTimeMs());
|
this.logger.info('构造设置列表结束' + timer.getTimeMs());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import CommonUtils from "../utils/CommonUtils";
|
|||||||
import VIEW_LOGS_HANDLER_HTML from "../../../static/html/view_logs_handler.html";
|
import VIEW_LOGS_HANDLER_HTML from "../../../static/html/view_logs_handler.html";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
@ClassName('ViewLogsHandler')
|
@ClassName('ViewLogsHandler')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -11,11 +12,12 @@ export default class ViewLogsHandler {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
let logCounter = Log.getCounter();
|
let logCounter = this.logger.getCounter();
|
||||||
let pop = new Popup(VIEW_LOGS_HANDLER_HTML
|
let pop = new Popup(VIEW_LOGS_HANDLER_HTML
|
||||||
.replace('{{}}', logCounter.info.toString())
|
.replace('{{}}', logCounter.info.toString())
|
||||||
.replace('{{}}', logCounter.warning.toString())
|
.replace('{{}}', logCounter.warning.toString())
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
import { MENU_ITEM_TYPE } from "../../interface/MenuItem";
|
|
||||||
|
|
||||||
const BUTTON_HANDLE_METADATA_KEY = Symbol("BUTTON_HANDLE_KEY")
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ButtonHandler
|
|
||||||
* 按钮
|
|
||||||
* @param target 类本身
|
|
||||||
*/
|
|
||||||
export function ButtonHandler<T>(target: T): void {
|
|
||||||
Reflect.defineMetadata(BUTTON_HANDLE_METADATA_KEY, MENU_ITEM_TYPE.BUTTON, target);
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
export default class Elem {
|
|
||||||
private readonly elem: HTMLElement;
|
|
||||||
|
|
||||||
constructor(tagName) {
|
|
||||||
this.elem = document.createElement(tagName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public html(htmlString): Elem {
|
|
||||||
this.elem.innerHTML = htmlString;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public id(id): Elem {
|
|
||||||
this.elem.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class(className): Elem {
|
|
||||||
this.elem.classList.add(className);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public el(): HTMLElement {
|
|
||||||
return this.elem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +1,37 @@
|
|||||||
import Log from "../Log";
|
|
||||||
import Timer from "../utils/Timer";
|
|
||||||
import ClassWithName from "../../interface/ClassWithName";
|
import ClassWithName from "../../interface/ClassWithName";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基类、单例
|
* 基类、单例
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
export default class Provider implements ClassWithName {
|
export default class Provider implements ClassWithName {
|
||||||
readonly className: string = 'Provider';
|
readonly className: string = 'Provider';
|
||||||
private static _instance;
|
// private static _instance;
|
||||||
|
//
|
||||||
private static readonly pool = {};
|
// private static readonly pool = {};
|
||||||
|
//
|
||||||
constructor(...args: unknown[]) {
|
// constructor(...args: unknown[]) {
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 返回继承类的实例
|
// 返回继承类的实例
|
||||||
public static getInstance<T extends typeof Provider>(this: T, ...args: unknown[]): InstanceType<T> {
|
// public static getInstance<T extends typeof Provider>(this: T, ...args: unknown[]): InstanceType<T> {
|
||||||
if (!this._instance) {
|
// if (!this._instance) {
|
||||||
let startTime = new Timer();
|
// let startTime = new Timer();
|
||||||
this._instance = new this(...args);
|
// this._instance = new this(...args);
|
||||||
let thatName = this._instance.getClassName() || this.name;
|
// let thatName = this._instance.getClassName() || this.name;
|
||||||
Log.info('实例已创建,', thatName, this._instance, '耗时' + startTime.getTimeMs());
|
// Log.info('实例已创建,', thatName, this._instance, '耗时' + startTime.getTimeMs());
|
||||||
Provider.pool[thatName] = this._instance;
|
// Provider.pool[thatName] = this._instance;
|
||||||
}
|
// }
|
||||||
return this._instance;
|
// return this._instance;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static getPool() {
|
// public static getPool() {
|
||||||
return {
|
// return {
|
||||||
pool: Provider.pool,
|
// pool: Provider.pool,
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public getClassName() {
|
// public getClassName() {
|
||||||
return this.className;
|
// return this.className;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,20 @@
|
|||||||
import ZhongIcon from "../ZhongIcon";
|
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
|
import globVars from "../../globVars";
|
||||||
|
|
||||||
@ClassName('ActionButtonUtils')
|
@ClassName('ActionButtonUtils')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class ActionButtonUtils {
|
export default class ActionButtonUtils {
|
||||||
private hasAdded: boolean = false;
|
private hasAdded: boolean = false;
|
||||||
|
private readonly logger = Logger.factory(ActionButtonUtils)
|
||||||
constructor(
|
|
||||||
private readonly logger: Logger,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public add(txt: string, func: (ev: Event) => void = () => null): void {
|
public add(txt: string, func: (ev: Event) => void = () => null): void {
|
||||||
if (!this.hasAdded) this.handle(txt, func);
|
|
||||||
else this.logger.warn('ActionButton已存在');
|
let added = { txt, func }
|
||||||
|
globVars.buttons.push(added)
|
||||||
|
|
||||||
|
this.logger.info({ globVars })
|
||||||
}
|
}
|
||||||
|
|
||||||
private handle(txt, func): void {
|
|
||||||
let btn = document.createElement('button');
|
|
||||||
btn.style.padding = '8px 13px 8px 0';
|
|
||||||
btn.style.verticalAlign = 'bottom';
|
|
||||||
btn.style.color = '#4CAF50';
|
|
||||||
btn.innerHTML = txt;
|
|
||||||
btn.addEventListener('click', func);
|
|
||||||
ZhongIcon.ZhongNode.querySelector('button').after(btn);
|
|
||||||
this.hasAdded = true;
|
|
||||||
this.logger.info('ActionButton已添加', { txt, func, btn });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import Log from "../Log";
|
|
||||||
import Device from "../../enum/Device";
|
import Device from "../../enum/Device";
|
||||||
import LOADING_IMG_HTML from "../../../static/html/loading_img.html";
|
import LOADING_IMG_HTML from "../../../static/html/loading_img.html";
|
||||||
import Timer from "./Timer";
|
import Timer from "./Timer";
|
||||||
@ -15,6 +14,7 @@ import Logger from "../Logger";
|
|||||||
import Global from "../Global";
|
import Global from "../Global";
|
||||||
import { Container } from "../../container/Container";
|
import { Container } from "../../container/Container";
|
||||||
import TornPDAUtils from "./TornPDAUtils";
|
import TornPDAUtils from "./TornPDAUtils";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('CommonUtils')
|
@ClassName('CommonUtils')
|
||||||
@ -40,13 +40,14 @@ export default class CommonUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static COFetch(url: URL | string, method: 'get' | 'post' | string = 'get', body: any = null): Promise<string> {
|
static COFetch(url: URL | string, method: 'get' | 'post' | string = 'get', body: any = null): Promise<string> {
|
||||||
|
let logger = Container.factory(Logger);
|
||||||
let start = new Timer();
|
let start = new Timer();
|
||||||
const engine = this.getScriptEngine();
|
const engine = this.getScriptEngine();
|
||||||
Log.info('跨域获取数据开始, 脚本引擎: ' + engine);
|
logger.info(`跨域请求 -> ${url}, 脚本引擎: ${engine}`);
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case UserScriptEngine.RAW: {
|
case UserScriptEngine.RAW: {
|
||||||
Log.error(`跨域请求错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
logger.error(`跨域请求错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
||||||
reject(`错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
reject(`错误:${ UserScriptEngine.RAW }环境下无法进行跨域请求`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -55,29 +56,29 @@ export default class CommonUtils {
|
|||||||
// get
|
// get
|
||||||
if (method === 'get') {
|
if (method === 'get') {
|
||||||
if (typeof PDA_httpGet !== 'function') {
|
if (typeof PDA_httpGet !== 'function') {
|
||||||
Log.error('COFetch网络错误:PDA版本不支持');
|
logger.error('COFetch网络错误:PDA版本不支持');
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
reject('COFetch网络错误:PDA版本不支持');
|
||||||
}
|
}
|
||||||
PDA_httpGet(url)
|
PDA_httpGet(url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
Log.info('跨域获取数据成功, 耗时' + start.getTimeMs());
|
logger.info('跨域获取数据成功, 耗时' + start.getTimeMs());
|
||||||
resolve(res.responseText);
|
resolve(res.responseText);
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
Log.error('COFetch网络错误', e);
|
logger.error('COFetch网络错误', e);
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
reject(`COFetch网络错误 ${ e }`);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// post
|
// post
|
||||||
else {
|
else {
|
||||||
if (typeof PDA_httpPost !== 'function') {
|
if (typeof PDA_httpPost !== 'function') {
|
||||||
Log.error('COFetch网络错误:PDA版本不支持');
|
logger.error('COFetch网络错误:PDA版本不支持');
|
||||||
reject('COFetch网络错误:PDA版本不支持');
|
reject('COFetch网络错误:PDA版本不支持');
|
||||||
}
|
}
|
||||||
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
PDA_httpPost(url, { 'content-type': 'application/json' }, body)
|
||||||
.then(res => resolve(res.responseText))
|
.then(res => resolve(res.responseText))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
Log.error('COFetch网络错误', e);
|
logger.error('COFetch网络错误', e);
|
||||||
reject(`COFetch网络错误 ${ e }`);
|
reject(`COFetch网络错误 ${ e }`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ export default class CommonUtils {
|
|||||||
case UserScriptEngine.GM: {
|
case UserScriptEngine.GM: {
|
||||||
let { GM_xmlhttpRequest } = Container.factory(Global);
|
let { GM_xmlhttpRequest } = Container.factory(Global);
|
||||||
if (typeof GM_xmlhttpRequest !== 'function') {
|
if (typeof GM_xmlhttpRequest !== 'function') {
|
||||||
Log.error('COFetch网络错误:用户脚本扩展API错误');
|
logger.error('COFetch网络错误:用户脚本扩展API错误');
|
||||||
reject('错误:用户脚本扩展API错误');
|
reject('错误:用户脚本扩展API错误');
|
||||||
}
|
}
|
||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
@ -95,7 +96,7 @@ export default class CommonUtils {
|
|||||||
data: method === 'get' ? null : body,
|
data: method === 'get' ? null : body,
|
||||||
headers: method === 'get' ? null : { 'content-type': 'application/json' },
|
headers: method === 'get' ? null : { 'content-type': 'application/json' },
|
||||||
onload: res => {
|
onload: res => {
|
||||||
Log.info('跨域获取数据成功,耗时' + start.getTimeMs());
|
logger.info('跨域获取数据成功,耗时' + start.getTimeMs());
|
||||||
resolve(res.response);
|
resolve(res.response);
|
||||||
},
|
},
|
||||||
onerror: res => reject(`连接错误 ${ JSON.stringify(res) }`),
|
onerror: res => reject(`连接错误 ${ JSON.stringify(res) }`),
|
||||||
@ -174,26 +175,27 @@ export default class CommonUtils {
|
|||||||
* @returns {Promise<HTMLElement|null>}
|
* @returns {Promise<HTMLElement|null>}
|
||||||
*/
|
*/
|
||||||
public static elementReady(selectors: string, content: Document = document, timeout: number = 30000): Promise<HTMLElement> {
|
public static elementReady(selectors: string, content: Document = document, timeout: number = 30000): Promise<HTMLElement> {
|
||||||
Log.info('等待元素:' + selectors);
|
const logger = Container.factory(Logger);
|
||||||
|
logger.info('等待元素:' + selectors);
|
||||||
let timer = new Timer();
|
let timer = new Timer();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let el = content.querySelector(selectors) as HTMLElement;
|
let el = content.querySelector(selectors) as HTMLElement;
|
||||||
if (el) {
|
if (el) {
|
||||||
Log.info('已获取元素, 耗时' + timer.getTimeMs(), el);
|
logger.info('已获取元素, 耗时' + timer.getTimeMs(), el);
|
||||||
resolve(el);
|
resolve(el);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let observer = new MutationObserver((_, observer) => {
|
let observer = new MutationObserver((_, observer) => {
|
||||||
content.querySelectorAll(selectors).forEach((element) => {
|
content.querySelectorAll(selectors).forEach((element) => {
|
||||||
Log.info({ innerHTML: element.innerHTML, element });
|
logger.info({ innerHTML: element.innerHTML, element });
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
Log.info('已获取元素, 耗时' + timer.getTimeMs(), element);
|
logger.info('已获取元素, 耗时' + timer.getTimeMs(), element);
|
||||||
resolve(element as HTMLElement);
|
resolve(element as HTMLElement);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
Log.error(`等待元素超时! [${ selectors }]\n${ content.documentElement.tagName }, 耗时` + timer.getTimeMs());
|
logger.error(`等待元素超时! [${ selectors }]\n${ content.documentElement.tagName }, 耗时` + timer.getTimeMs());
|
||||||
reject(`等待元素超时! [${ selectors }]\n${ content.documentElement.tagName }, 耗时` + timer.getTimeMs());
|
reject(`等待元素超时! [${ selectors }]\n${ content.documentElement.tagName }, 耗时` + timer.getTimeMs());
|
||||||
}, timeout);
|
}, timeout);
|
||||||
observer.observe(content.documentElement, { childList: true, subtree: true });
|
observer.observe(content.documentElement, { childList: true, subtree: true });
|
||||||
@ -210,7 +212,12 @@ export default class CommonUtils {
|
|||||||
return CommonUtils.elementReady(selectors, content, timeout);
|
return CommonUtils.elementReady(selectors, content, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public querySelector(selectors: string, content: Document = document, timeout: number = 30000): Promise<HTMLElement> {
|
||||||
|
return CommonUtils.elementReady(selectors, content, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
public static addStyle(rules: string): void {
|
public static addStyle(rules: string): void {
|
||||||
|
const logger = Container.factory(Logger);
|
||||||
let element = document.querySelector('style#wh-trans-gStyle');
|
let element = document.querySelector('style#wh-trans-gStyle');
|
||||||
if (element) {
|
if (element) {
|
||||||
element.innerHTML += rules;
|
element.innerHTML += rules;
|
||||||
@ -220,7 +227,7 @@ export default class CommonUtils {
|
|||||||
element.innerHTML = rules;
|
element.innerHTML = rules;
|
||||||
document.head.appendChild(element);
|
document.head.appendChild(element);
|
||||||
}
|
}
|
||||||
Log.info('CSS规则已添加', element);
|
logger.info('CSS规则已添加', element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public styleInject(rules: string): void {
|
public styleInject(rules: string): void {
|
||||||
@ -438,7 +445,11 @@ export default class CommonUtils {
|
|||||||
* @param m1 id->name map
|
* @param m1 id->name map
|
||||||
* @param m2 name->item map
|
* @param m2 name->item map
|
||||||
*/
|
*/
|
||||||
public getItemByIdOrName(key: string, m1, m2: { [k: string]: Partial<InventoryItemInfo> }): Partial<InventoryItemInfo> {
|
public getItemByIdOrName(key: string, m1, m2: {
|
||||||
|
[k: string]: Partial<InventoryItemInfo>
|
||||||
|
}): Partial<InventoryItemInfo> {
|
||||||
return m1[key] ? m2[m1[key]] : m2[key];
|
return m1[key] ? m2[m1[key]] : m2[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const CommonUtilsKey = Symbol('CommonUtilsKey') as InjectionKey<CommonUtils>;
|
||||||
|
|||||||
@ -1,19 +1,21 @@
|
|||||||
import Log from "../Log";
|
|
||||||
import DIALOG_MSG_BOX_HTML from "../../../static/html/dialog_msg_box.html";
|
import DIALOG_MSG_BOX_HTML from "../../../static/html/dialog_msg_box.html";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
|
||||||
export default class DialogMsgBox {
|
export default class DialogMsgBox {
|
||||||
private static existed = false;
|
private static existed = false;
|
||||||
private readonly container: HTMLElement;
|
private readonly container: HTMLElement;
|
||||||
|
|
||||||
constructor(msg: string, opt: DialogMsgBoxOptions) {
|
constructor(msg: string, opt: DialogMsgBoxOptions,
|
||||||
Log.info('创建DialogMsgBox', { msg, opt });
|
private readonly logger: Logger = Container.factory(Logger)) {
|
||||||
|
logger.info('创建DialogMsgBox', { msg, opt });
|
||||||
let { title = '提示', callback, cancel } = opt;
|
let { title = '提示', callback, cancel } = opt;
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
Log.error('无callback');
|
logger.error('无callback');
|
||||||
throw new Error('无callback');
|
throw new Error('无callback');
|
||||||
}
|
}
|
||||||
if (DialogMsgBox.existed) {
|
if (DialogMsgBox.existed) {
|
||||||
Log.error('无法创建DialogMsgBox:已存在');
|
logger.error('无法创建DialogMsgBox:已存在');
|
||||||
throw new Error('无法创建DialogMsgBox:已存在');
|
throw new Error('无法创建DialogMsgBox:已存在');
|
||||||
}
|
}
|
||||||
this.container = document.createElement('div');
|
this.container = document.createElement('div');
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import Alert from "./Alert";
|
|
||||||
import ISidebarData from "../../interface/ISidebarData";
|
import ISidebarData from "../../interface/ISidebarData";
|
||||||
import Log from "../Log";
|
|
||||||
import FetchUtils from "./FetchUtils";
|
import FetchUtils from "./FetchUtils";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import Logger from "../Logger";
|
import Logger from "../Logger";
|
||||||
|
import LocalConfigWrapper from "../LocalConfigWrapper";
|
||||||
|
import MsgWrapper from "./MsgWrapper";
|
||||||
|
import { ElMessageBox } from "element-plus";
|
||||||
|
import { MessageBoxData } from "element-plus/es/components/message-box/src/message-box.type";
|
||||||
|
|
||||||
@ClassName('InfoUtils')
|
@ClassName('InfoUtils')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -15,6 +17,8 @@ export default class InfoUtils {
|
|||||||
// private readonly commonUtils: CommonUtils,
|
// private readonly commonUtils: CommonUtils,
|
||||||
private readonly fetchUtils: FetchUtils,
|
private readonly fetchUtils: FetchUtils,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +34,51 @@ export default class InfoUtils {
|
|||||||
userID: parseInt(node.getAttribute('uid')),
|
userID: parseInt(node.getAttribute('uid')),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(() => new Alert('严重错误:芜湖助手无法获取用户数据,已退出'))();
|
// 自动登陆
|
||||||
throw '芜湖助手无法获取用户数据';
|
const { autoLoginEmail, autoLoginPwd } = this.localConfigWrapper.config;
|
||||||
|
if (autoLoginEmail && autoLoginPwd) {
|
||||||
|
window.setTimeout(async () => {
|
||||||
|
let alertRs: MessageBoxData = null;
|
||||||
|
try {
|
||||||
|
alertRs = await ElMessageBox.confirm(
|
||||||
|
'可进行自动登录',
|
||||||
|
'确认',
|
||||||
|
{
|
||||||
|
confirmButtonText: '好',
|
||||||
|
cancelButtonText: '算了',
|
||||||
|
type: 'info',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
if (alertRs !== 'confirm') return;
|
||||||
|
this.msgWrapper.create('正尝试自动登录...', null, 'info');
|
||||||
|
await fetch("https://www.torn.com/page.php?sid=Auth", {
|
||||||
|
"headers": {
|
||||||
|
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"content-type": "application/x-www-form-urlencoded",
|
||||||
|
"pragma": "no-cache",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-fetch-dest": "document",
|
||||||
|
"sec-fetch-mode": "navigate",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"sec-fetch-user": "?1",
|
||||||
|
"upgrade-insecure-requests": "1"
|
||||||
|
},
|
||||||
|
"referrer": "https://www.torn.com/",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": `email=${ autoLoginEmail }&password=${ autoLoginPwd }&redirectUrl=https%3A%2F%2Fwww.torn.com%2F&btnLogin=Login`,
|
||||||
|
"method": "POST",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
});
|
||||||
|
this.msgWrapper.create('自动登录完成,即将转跳', null, 'info');
|
||||||
|
window.setTimeout(() => window.location.href = '//www.torn.com/index.php', 1000);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
this.msgWrapper.create('错误:芜湖助手无法获取用户数据,已退出', null, 'error');
|
||||||
|
throw new TypeError('芜湖助手无法获取用户数据');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +103,7 @@ export default class InfoUtils {
|
|||||||
ret = {};
|
ret = {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.info('无法从sessionStorage获取数据')
|
this.logger.info('无法从sessionStorage获取数据')
|
||||||
ret = await (await this.fetchUtils.ajaxFetch({
|
ret = await (await this.fetchUtils.ajaxFetch({
|
||||||
url: window.addRFC('/sidebarAjaxAction.php?q=getSidebarData'),
|
url: window.addRFC('/sidebarAjaxAction.php?q=getSidebarData'),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
import InventoryItemInfo from "../../interface/responseType/InventoryItemInfo";
|
||||||
import FetchUtils from "./FetchUtils";
|
import FetchUtils from "./FetchUtils";
|
||||||
import CommonUtils from "./CommonUtils";
|
import CommonUtils from "./CommonUtils";
|
||||||
import Log from "../Log";
|
|
||||||
import PriceData from "../../interface/PriceData";
|
import PriceData from "../../interface/PriceData";
|
||||||
import Asyncable from "../../interface/Asyncable";
|
import Asyncable from "../../interface/Asyncable";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
@ClassName('ItemHelper')
|
@ClassName('ItemHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -13,6 +14,7 @@ export default class ItemHelper {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly fetchUtils: FetchUtils,
|
private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ export default class ItemHelper {
|
|||||||
* 物品查价值
|
* 物品查价值
|
||||||
*/
|
*/
|
||||||
public async getItemValue(idOrName) {
|
public async getItemValue(idOrName) {
|
||||||
return (await this.getItemData(idOrName)).itemValue.replaceAll(/[,$]/, '');
|
return (await this.getItemData(idOrName)).itemValue.replaceAll(/[,$]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 返回本地物品价格数据,id对应物品名和价格 */
|
/** 返回本地物品价格数据,id对应物品名和价格 */
|
||||||
@ -99,7 +101,7 @@ export default class ItemHelper {
|
|||||||
try {
|
try {
|
||||||
data = JSON.parse(localStore);
|
data = JSON.parse(localStore);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Log.error(e.stack || e.message || e);
|
this.logger.error(e.stack || e.message || e);
|
||||||
throw new Error('JSON解析错误');
|
throw new Error('JSON解析错误');
|
||||||
}
|
}
|
||||||
// 缓存超时
|
// 缓存超时
|
||||||
@ -139,7 +141,7 @@ export default class ItemHelper {
|
|||||||
else {
|
else {
|
||||||
ret.promise = new Promise(async resolve => {
|
ret.promise = new Promise(async resolve => {
|
||||||
let response = await localData.promise;
|
let response = await localData.promise;
|
||||||
Log.info({ response });
|
this.logger.info({ response });
|
||||||
let promiseRet = {};
|
let promiseRet = {};
|
||||||
Object.keys(response).forEach(k => {
|
Object.keys(response).forEach(k => {
|
||||||
promiseRet[response[k].name] = k;
|
promiseRet[response[k].name] = k;
|
||||||
@ -161,7 +163,7 @@ export default class ItemHelper {
|
|||||||
try {
|
try {
|
||||||
res = JSON.parse(await CommonUtils.COFetch('https://jjins.github.io/item_price_raw.json'))
|
res = JSON.parse(await CommonUtils.COFetch('https://jjins.github.io/item_price_raw.json'))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Log.error(err.stack || err.message || err);
|
this.logger.error(err.stack || err.message || err);
|
||||||
throw new Error('获取在线价格时出错');
|
throw new Error('获取在线价格时出错');
|
||||||
}
|
}
|
||||||
// 更新缓存
|
// 更新缓存
|
||||||
@ -173,3 +175,5 @@ export default class ItemHelper {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ItemHelperKey = Symbol('ItemHelperKey') as InjectionKey<ItemHelper>;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
@ClassName('MathUtils')
|
@ClassName('MathUtils')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -14,3 +15,5 @@ export default class MathUtils {
|
|||||||
return Math.floor(Math.random() * (max - min)) + min;
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MathUtilsKey = Symbol('MathUtilsKey') as InjectionKey<MathUtils>
|
||||||
|
|||||||
@ -1,12 +1,32 @@
|
|||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
import Alert from "./Alert";
|
|
||||||
import IWHNotify from "../../interface/IWHNotify";
|
import IWHNotify from "../../interface/IWHNotify";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
import NotificationUtils from "./NotificationUtils";
|
||||||
|
import WindowActiveState from "../action/WindowActiveState";
|
||||||
|
|
||||||
@ClassName('MsgWrapper')
|
@ClassName('MsgWrapper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class MsgWrapper {
|
export default class MsgWrapper {
|
||||||
create(msg: string, options: IWHNotify = {},): Alert {
|
constructor(
|
||||||
return new Alert(msg, options);
|
private readonly notificationUtils: NotificationUtils,
|
||||||
|
private readonly windowActiveState: WindowActiveState,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
create(msg: string, options: IWHNotify = {}, type: 'info' | 'warning' | 'error' | 'success' = 'info') {
|
||||||
|
if (!this.windowActiveState.get()) return null;
|
||||||
|
if (options?.sysNotify) {
|
||||||
|
this.notificationUtils.push(msg, options);
|
||||||
|
}
|
||||||
|
return ElMessage({
|
||||||
|
message: msg,
|
||||||
|
type,
|
||||||
|
showClose: true,
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MsgWrapperKey = Symbol('MsgWrapperKey') as InjectionKey<MsgWrapper>;
|
||||||
|
|||||||
@ -34,6 +34,26 @@ export default class NetHighLvlWrapper {
|
|||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async doTravelFly(destId, key, type): Promise<string> {
|
||||||
|
return await (await fetch(window.addRFC("https://www.torn.com/travelagency.php"), {
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"accept-language": "zh-CN,zh;q=0.9",
|
||||||
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
"referrer": "https://www.torn.com/travelagency.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": `step=travel&id=${ destId }&type=${ type }`,
|
||||||
|
"method": "POST",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
})).text()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum BATTLE_STAT {
|
export enum BATTLE_STAT {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import IWHNotify from "../../interface/IWHNotify";
|
import IWHNotify from "../../interface/IWHNotify";
|
||||||
import Log from "../Log";
|
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../../container/ClassName";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Logger from "../Logger";
|
||||||
|
|
||||||
@ClassName('NotificationUtils')
|
@ClassName('NotificationUtils')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -9,19 +9,21 @@ export default class NotificationUtils {
|
|||||||
constructor(
|
constructor(
|
||||||
// TODO 循环依赖
|
// TODO 循环依赖
|
||||||
// private readonly global: Global,
|
// private readonly global: Global,
|
||||||
|
private readonly logger: Logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private permission: boolean = window.Notification && window.Notification.permission === 'granted';
|
private permission: boolean = window.Notification && window.Notification.permission === 'granted';
|
||||||
|
|
||||||
public push(msg: string, options: IWHNotify = {}): void {
|
public push(msg: string, options: IWHNotify = {}): void {
|
||||||
|
// this.logger.info({msg, options})
|
||||||
// let { notifies } = this.global;
|
// let { notifies } = this.global;
|
||||||
|
|
||||||
if (options.sysNotify && this.permission) {
|
if (options.sysNotify && this.permission) {
|
||||||
let tmpNode = document.createElement('p');
|
let tmpNode = document.createElement('p');
|
||||||
tmpNode.innerHTML = msg;
|
tmpNode.innerHTML = msg;
|
||||||
let notify = new Notification('芜湖助手', {
|
let notify = new Notification('芜湖助手', {
|
||||||
body: Log.getTime() + '\r\n' + tmpNode.innerText,
|
body: this.logger.getTime() + '\r\n' + tmpNode.innerText,
|
||||||
// requireInteraction: true,
|
// requireInteraction: true,
|
||||||
// renotify: true,
|
// renotify: true,
|
||||||
// tag: '芜湖助手' + Utils.getRandomInt(0, 99),
|
// tag: '芜湖助手' + Utils.getRandomInt(0, 99),
|
||||||
|
|||||||
14
src/ts/class/utils/PopupWrapper.ts
Normal file
14
src/ts/class/utils/PopupWrapper.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
import Popup from "./Popup";
|
||||||
|
import { InjectionKey } from "vue";
|
||||||
|
|
||||||
|
@ClassName('PopupWrapper')
|
||||||
|
@Injectable()
|
||||||
|
export default class PopupWrapper {
|
||||||
|
public create(html: string, title: string, onClosing: () => unknown) {
|
||||||
|
return new Popup(html, title, onClosing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PopupWrapperKey = Symbol('PopupWrapperKey') as InjectionKey<PopupWrapper>;
|
||||||
@ -3,13 +3,13 @@ const CLASSNAME_METADATA_KEY = Symbol("CLASSNAME_KEY");
|
|||||||
/**
|
/**
|
||||||
* 记录类名,避免打包后丢失原类名
|
* 记录类名,避免打包后丢失原类名
|
||||||
*/
|
*/
|
||||||
export default function ClassName(className?: string): ClassDecorator {
|
export default function ClassName(className: string): ClassDecorator {
|
||||||
return function <TFunction extends Function>(target: TFunction): TFunction {
|
return function <TFunction extends Function>(target: TFunction): TFunction {
|
||||||
Reflect.defineMetadata(CLASSNAME_METADATA_KEY, className || target.name, target);
|
Reflect.defineMetadata(CLASSNAME_METADATA_KEY, className, target);
|
||||||
return target;
|
return target;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GetClassName(target: any) {
|
export function GetClassName(target: ClassType<{}>): string {
|
||||||
return Reflect.getMetadata(CLASSNAME_METADATA_KEY, target);
|
return Reflect.getMetadata(CLASSNAME_METADATA_KEY, target);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +1,38 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
import { assertInjectable } from "./Injectable";
|
import { assertInjectable } from "./Injectable";
|
||||||
import { GetClassName } from "./ClassName";
|
import ClassName, { GetClassName } from "./ClassName";
|
||||||
|
import Logger from "../class/Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一个简单的类容器
|
* 一个简单的类容器
|
||||||
*/
|
*/
|
||||||
|
@ClassName('Container')
|
||||||
export class Container {
|
export class Container {
|
||||||
static _container = new Map();
|
static _container = new Map();
|
||||||
private static logger;
|
private static logger;
|
||||||
|
|
||||||
static set(k: any, v: any): void {
|
static set<T>(k: Constructor<T>, v: T): void {
|
||||||
if (!this._container.has(k)) {
|
if (!this._container.has(k)) {
|
||||||
this._container.set(k, v);
|
this._container.set(k, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(k: any): any {
|
static get<T>(k: Constructor<T>): T {
|
||||||
return this._container.get(k);
|
return this._container.get(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
static factory<T>(target: Constructor<T>): T {
|
static factory<T>(target: ClassType<T>): T {
|
||||||
assertInjectable(target);
|
assertInjectable(target);
|
||||||
// if (Container.get(target))
|
|
||||||
// return Container.get(target);
|
|
||||||
return this.get(target) || this.initParam(target);
|
return this.get(target) || this.initParam(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static setLogger(logger: { info(...o: any[]), error(...o: any[]), warn(...o: any[]) }): void {
|
static setLogger(logger: Logger): void {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static initParam<T>(target: Constructor<T>): T {
|
private static initParam<T>(target: Constructor<T>): T {
|
||||||
// 获取所有注入的服务
|
// 获取所有注入的服务
|
||||||
const providers = Reflect.getMetadata('design:paramtypes', target);
|
const providers = Reflect.getMetadata('design:paramtypes', target);
|
||||||
// this.logger.info({providers})
|
|
||||||
// this.logger.info('原型名'+Object.getPrototypeOf(target).constructor.name)
|
|
||||||
// this.logger.info('直接名'+target.name)
|
|
||||||
const args = providers ? providers.map((provider: Constructor) => {
|
const args = providers ? providers.map((provider: Constructor) => {
|
||||||
return this.factory(provider);
|
return this.factory(provider);
|
||||||
}) : [];
|
}) : [];
|
||||||
|
|||||||
@ -5,7 +5,6 @@ const INJECTABLE_METADATA_KEY = Symbol("INJECTABLE_KEY");
|
|||||||
// TODO 实现非单例注入
|
// TODO 实现非单例注入
|
||||||
export enum INJECT_MODE {
|
export enum INJECT_MODE {
|
||||||
Singleton = 1,
|
Singleton = 1,
|
||||||
Multi = 2,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Injectable(injectMode: INJECT_MODE = INJECT_MODE.Singleton): ClassDecorator {
|
export function Injectable(injectMode: INJECT_MODE = INJECT_MODE.Singleton): ClassDecorator {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
278
src/ts/feature/Atk.ts
Normal file
278
src/ts/feature/Atk.ts
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
import ClassName from "../container/ClassName"
|
||||||
|
import { Injectable } from "../container/Injectable"
|
||||||
|
import IFeature from "../man/IFeature"
|
||||||
|
import LocalConfigWrapper from "../class/LocalConfigWrapper"
|
||||||
|
import CommonUtils from "../class/utils/CommonUtils"
|
||||||
|
import Global from "../class/Global"
|
||||||
|
import ActionButtonUtils from "../class/utils/ActionButtonUtils"
|
||||||
|
import Logger from "../class/Logger"
|
||||||
|
import Alert from "../class/utils/Alert"
|
||||||
|
import Device from "../enum/Device"
|
||||||
|
import ATTACK_HELPER_CSS from "../../static/css/attack_helper.module.css"
|
||||||
|
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
|
||||||
|
|
||||||
|
enum FIGHT_STAGE {
|
||||||
|
READY = 'ready',
|
||||||
|
IN_PROGRESS_OR_ERROR = 'in_progress_or_error',
|
||||||
|
FINISHED = 'finished',
|
||||||
|
END = 'end',
|
||||||
|
OTHER = 'other'
|
||||||
|
}
|
||||||
|
|
||||||
|
@ClassName('Atk')
|
||||||
|
@Injectable()
|
||||||
|
export default class Atk implements IFeature {
|
||||||
|
|
||||||
|
private currentStage: FIGHT_STAGE = FIGHT_STAGE.OTHER;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly actionButtonUtils: ActionButtonUtils,
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly global: Global,
|
||||||
|
// private readonly mathUtils: MathUtils,
|
||||||
|
// private readonly fetchUtils: FetchUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [ATK_PAGE_REG]
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return '攻击助手'
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
// 光速刷新按钮
|
||||||
|
this.actionButtonUtils.add('光速刷新', () => this.doAttackReload());
|
||||||
|
|
||||||
|
new MutationObserver((_, observer) => {
|
||||||
|
let btnList = document.querySelectorAll('div[class^="dialogButtons___"] button') as NodeListOf<HTMLButtonElement>;
|
||||||
|
|
||||||
|
if (btnList.length === 0) {
|
||||||
|
if (this.currentStage === FIGHT_STAGE.READY && this.localConfigWrapper.config.quickFinishAtt === 3) {
|
||||||
|
document.body.classList.remove('wh-move-btn');
|
||||||
|
this.logger.info('移除body class wh-move-btn');
|
||||||
|
observer.disconnect();
|
||||||
|
}
|
||||||
|
// 错误或正在打
|
||||||
|
this.currentStage = FIGHT_STAGE.IN_PROGRESS_OR_ERROR;
|
||||||
|
this.logger.info('[attackHelper] currentStage', this.currentStage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
btnList.forEach(btn => {
|
||||||
|
let btnText = btn.innerText.toLowerCase();
|
||||||
|
if (btnText.includes('start') || btnText.includes('join')) {
|
||||||
|
// 开始
|
||||||
|
this.quickStartFight();
|
||||||
|
} else if (btnText.includes('continue')) {
|
||||||
|
// 结束end
|
||||||
|
this.currentStage = FIGHT_STAGE.END;
|
||||||
|
observer.disconnect();
|
||||||
|
} else if (btnText.includes('leave')) {
|
||||||
|
// 无意识状态FINISHED
|
||||||
|
this.quickFinishFight(btnList);
|
||||||
|
}
|
||||||
|
this.logger.info('[attackHelper] currentStage', this.currentStage);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.observe(document.querySelector('#react-root'), { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// 战斗页面快速刷新
|
||||||
|
private doAttackReload(): void {
|
||||||
|
if (!window.ReactDOM) {
|
||||||
|
new Alert('光速刷新失败:未找到React对象');
|
||||||
|
this.logger.error('光速刷新失败:未找到React对象');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!document.querySelector('#react-root #attacker')) {
|
||||||
|
this.logger.error('dom元素未找到selector: [#react-root #attacker]');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let script = document.querySelector('script[src*="/builds/attack/"]');
|
||||||
|
let url = script.src;
|
||||||
|
if (!url.contains(/runtime\..+\.js/)) {
|
||||||
|
this.logger.error('脚本源[' + url + '] 不匹配规则');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.ReactDOM.unmountComponentAtNode(document.querySelector('#react-root'));
|
||||||
|
script.remove();
|
||||||
|
let node = document.createElement('script');
|
||||||
|
node.src = url;
|
||||||
|
node.type = 'text/javascript';
|
||||||
|
document.head.appendChild(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 光速拔刀
|
||||||
|
private quickStartFight(): void {
|
||||||
|
if (this.currentStage === FIGHT_STAGE.READY) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.currentStage = FIGHT_STAGE.READY;
|
||||||
|
}
|
||||||
|
if (this.localConfigWrapper.config.quickAttIndex === 6) return;
|
||||||
|
/**
|
||||||
|
* pc #defender
|
||||||
|
* mobile #attacker
|
||||||
|
*/
|
||||||
|
const btn = <HTMLInputElement>(document.querySelector('#attacker button') || document.querySelector('#defender button'));
|
||||||
|
this.logger.info('操作按钮', { btn });
|
||||||
|
if (!btn.innerText.toLowerCase().includes('fight')) {
|
||||||
|
this.logger.info('未找到攻击按钮, 光速拔刀跳过');
|
||||||
|
new Alert('未找到攻击按钮, 光速拔刀跳过');
|
||||||
|
} else {
|
||||||
|
// 判断是否存在脚踢
|
||||||
|
const hasKick = !!document.querySelector('#weapon_boots');
|
||||||
|
// modal层
|
||||||
|
// const modal: HTMLElement = document.querySelector('div[class^="modal___"]');
|
||||||
|
let device = this.global.device;
|
||||||
|
this.logger.info(`当前设备类型是${ device }`);
|
||||||
|
// 区分设备
|
||||||
|
switch (device) {
|
||||||
|
case Device.PC: {
|
||||||
|
this.logger.info(`开始调整按钮位置`);
|
||||||
|
// 隐藏modal层
|
||||||
|
// modal.style.display = 'none';
|
||||||
|
// 根据选择的武器调整css
|
||||||
|
let css_top = '0';
|
||||||
|
switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
|
// weapon_second
|
||||||
|
case 1: {
|
||||||
|
css_top = '97px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// weapon_melee
|
||||||
|
case 2: {
|
||||||
|
css_top = '194px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// weapon_temp
|
||||||
|
case 3: {
|
||||||
|
css_top = '291px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// weapon_fists
|
||||||
|
case 4:
|
||||||
|
// weapon_boots
|
||||||
|
case 5: {
|
||||||
|
css_top = '375px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.commonUtils.styleInject(ATTACK_HELPER_CSS);
|
||||||
|
CommonUtils.addStyle(`.wh-move-btn #defender div[class^="modal___"]{top: ${ css_top };}`);
|
||||||
|
document.body.classList.add('wh-move-btn');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Device.MOBILE: {
|
||||||
|
this.logger.info(`开始调整按钮位置`);
|
||||||
|
// 加入css
|
||||||
|
let css_top = '0';
|
||||||
|
let slot_height = '76px';
|
||||||
|
// 判断有没有脚踢
|
||||||
|
if (hasKick) {
|
||||||
|
// 根据选择的武器调整
|
||||||
|
switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
|
case 1: { // weapon_second
|
||||||
|
css_top = '76px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: { // weapon_melee
|
||||||
|
css_top = '152px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: { // weapon_temp
|
||||||
|
css_top = '228px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: { // weapon_fists
|
||||||
|
css_top = '304px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: { // weapon_boots
|
||||||
|
css_top = '380px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const slot = document.querySelector('#weapon_main') as HTMLElement;
|
||||||
|
const height = slot.offsetHeight + 1;
|
||||||
|
// TODO 待验证
|
||||||
|
slot_height = height + 'px';
|
||||||
|
// 根据选择的武器调整
|
||||||
|
switch (this.localConfigWrapper.config.quickAttIndex) {
|
||||||
|
case 1: { // weapon_second
|
||||||
|
css_top = `${ height }px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: { // weapon_melee
|
||||||
|
css_top = `${ height * 2 }px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: { // weapon_temp
|
||||||
|
css_top = `${ height * 3 }px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: { // weapon_fists
|
||||||
|
css_top = `${ height * 4 }px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: { // weapon_boots
|
||||||
|
css_top = `${ height * 5 }px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const css_rule = ATTACK_HELPER_CSS.replace('CSSVAR', css_top).replace('CSSVAR', slot_height);
|
||||||
|
|
||||||
|
this.commonUtils.styleInject(css_rule);
|
||||||
|
document.body.classList.toggle('wh-move-btn');
|
||||||
|
btn.onclick = () => {
|
||||||
|
if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
|
||||||
|
btn.remove();
|
||||||
|
// 停止自动刷新
|
||||||
|
// stop_reload = true;
|
||||||
|
} else {
|
||||||
|
document.body.classList.toggle('wh-move-btn');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Device.TABLET: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 光速跑路
|
||||||
|
private quickFinishFight(btnList: NodeListOf<HTMLButtonElement>): void {
|
||||||
|
if (this.currentStage === FIGHT_STAGE.FINISHED) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.currentStage = FIGHT_STAGE.FINISHED;
|
||||||
|
}
|
||||||
|
if (this.localConfigWrapper.config.quickFinishAtt === 3) {
|
||||||
|
document.body.classList.remove('wh-move-btn');
|
||||||
|
this.logger.info('移除body class wh-move-btn');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const user_btn_select = ['leave', 'mug', 'hosp'][this.localConfigWrapper.config.quickFinishAtt];
|
||||||
|
// const wrap = document.querySelector('#react-root');
|
||||||
|
this.logger.info('光速跑路选项选中:', user_btn_select);
|
||||||
|
// const btn_arr: HTMLButtonElement[] = document.querySelectorAll('div[class^="dialogButtons___"] button') as unknown as HTMLButtonElement[];
|
||||||
|
if (btnList.length > 1) btnList.forEach(btn => {
|
||||||
|
const flag = btn.innerText.toLowerCase().includes(user_btn_select);
|
||||||
|
this.logger.info('按钮内容:', btn.innerText, ',是否包含选中:', flag);
|
||||||
|
if (!flag) btn.style.display = 'none';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
68
src/ts/feature/BeerShopModifier.ts
Normal file
68
src/ts/feature/BeerShopModifier.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import ClassName from "../container/ClassName"
|
||||||
|
import { Injectable } from "../container/Injectable"
|
||||||
|
import IFeature from "../man/IFeature"
|
||||||
|
import TornStyleBlock from "../class/utils/TornStyleBlock"
|
||||||
|
import ADD_BEER_HEAD_HTML from "../../static/html/buyBeer/add_beer_head.html"
|
||||||
|
import SHOP_BEER_STATIC_ITEM_HTML from "../../static/html/buyBeer/shop_beer_static_item.html"
|
||||||
|
import globVars from "../globVars"
|
||||||
|
import Logger from "../class/Logger";
|
||||||
|
import BuyBeerHelper from "./BuyBeerHelper";
|
||||||
|
|
||||||
|
@ClassName('BeerShopModifier')
|
||||||
|
@Injectable()
|
||||||
|
export default class BeerShopModifier implements IFeature {
|
||||||
|
private readonly logger = Logger.factory(BeerShopModifier)
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly buyBeerHelper: BuyBeerHelper,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "啤酒店页面修改";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/shops.php\?step=bitsnbobs/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
let block = new TornStyleBlock('啤酒助手').insert2Dom();
|
||||||
|
block.setContent(ADD_BEER_HEAD_HTML);
|
||||||
|
const msg_node = block.querySelector('#wh-msg');
|
||||||
|
// 加入啤酒
|
||||||
|
block.querySelector('button').addEventListener('click', e => {
|
||||||
|
let node = document.querySelector('ul.items-list');
|
||||||
|
if (!node) {
|
||||||
|
msg_node.innerHTML = '❌ 商品未加载完';
|
||||||
|
this.logger.error('商品未加载完');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (node.querySelector('span[id="180-name"]')) {
|
||||||
|
msg_node.innerHTML = '❌ 页面已经有啤酒了';
|
||||||
|
this.logger.warn('商店页面已有啤酒');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const clear_node = node.querySelector('li.clear');
|
||||||
|
const beer = document.createElement('li');
|
||||||
|
beer.classList.add('torn-divider', 'divider-vertical');
|
||||||
|
beer.style.backgroundColor = '#c8c8c8';
|
||||||
|
beer.innerHTML = SHOP_BEER_STATIC_ITEM_HTML;
|
||||||
|
if (clear_node) clear_node.before(beer);
|
||||||
|
else node.append(beer);
|
||||||
|
(<HTMLInputElement>e.target).disabled = true;
|
||||||
|
msg_node.innerHTML = '添加成功';
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听啤酒购买
|
||||||
|
globVars.responseHandlers.push((...args: any[]) => this.buyBeerHelper.responseHandler.apply(this.buyBeerHelper, args));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,18 +1,37 @@
|
|||||||
import Log from "../Log";
|
import InfoUtils from "../class/utils/InfoUtils";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import MathUtils from "../class/utils/MathUtils";
|
||||||
import Alert from "../utils/Alert";
|
import NOTIFY_HTML from "../../static/html/buyBeer/notify.html";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
import NOTIFY_HTML from "../../../static/html/buyBeer/notify.html";
|
import Popup from "../class/utils/Popup";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import ResponseInject from "../interface/ResponseInject";
|
||||||
import Popup from "../utils/Popup";
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
import ResponseInject from "../../interface/ResponseInject";
|
import ClassName from "../container/ClassName";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import { Injectable } from "../container/Injectable";
|
||||||
import ClassName from "../../container/ClassName";
|
import Logger from "../class/Logger";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import MsgWrapper from "../class/utils/MsgWrapper";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
|
||||||
|
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
|
||||||
|
|
||||||
@ClassName('BuyBeerHelper')
|
@ClassName('BuyBeerHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject, IFeature {
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [ALL_PAGE_REG]
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [ATK_PAGE_REG]
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return '啤酒助手'
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
(this.localConfigWrapper.config._15Alarm) && this.start()
|
||||||
|
}
|
||||||
|
|
||||||
private isNotifying = false;
|
private isNotifying = false;
|
||||||
private loopId: number = null;
|
private loopId: number = null;
|
||||||
@ -24,15 +43,17 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
private readonly mathUtils: MathUtils,
|
private readonly mathUtils: MathUtils,
|
||||||
|
private readonly logger: Logger,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
this.time = this.localConfigWrapper.config._15AlarmTime || 30;
|
this.time = this.localConfigWrapper.config._15AlarmTime || 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
public start(): void {
|
public start(): void {
|
||||||
if (this.loopId) {
|
if (this.loopId) {
|
||||||
Log.info('啤酒助手已在运行');
|
this.logger.info('啤酒助手已在运行');
|
||||||
} else {
|
} else {
|
||||||
Log.info('啤酒助手启动');
|
this.logger.info('啤酒助手启动');
|
||||||
this.loopId = window.setInterval(async () => {
|
this.loopId = window.setInterval(async () => {
|
||||||
// 海外取消提醒
|
// 海外取消提醒
|
||||||
let { isTravelling, isAbroad } = await this.infoUtils.getUserState();
|
let { isTravelling, isAbroad } = await this.infoUtils.getUserState();
|
||||||
@ -59,16 +80,18 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
if (this.isNotifying) return;
|
if (this.isNotifying) return;
|
||||||
this.isNotifying = true;
|
this.isNotifying = true;
|
||||||
// 发送通知
|
// 发送通知
|
||||||
const notify = new Alert(this.notifyHtml, {
|
const rNum = this.mathUtils.getRandomInt(0, 99);
|
||||||
|
// const notify =
|
||||||
|
this.msgWrapper.create(NOTIFY_HTML.replace('{{}}', rNum.toString()), {
|
||||||
timeout: 30,
|
timeout: 30,
|
||||||
sysNotify: true,
|
sysNotify: true,
|
||||||
});
|
});
|
||||||
notify.getElement().querySelector('.wh-notify-msg button').addEventListener('click', () => this.skip_today());
|
document.querySelector('button#wh-rd-btn-' + rNum).addEventListener('click', () => this.skip_today());
|
||||||
notify.getElement().addEventListener('click', ev => {
|
// notify.getElement().addEventListener('click', ev => {
|
||||||
if ((ev.target as HTMLElement).tagName.toLowerCase() === 'a') {
|
// if ((ev.target as HTMLElement).tagName.toLowerCase() === 'a') {
|
||||||
notify.close();
|
// notify.close();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
// 声音提醒
|
// 声音提醒
|
||||||
{
|
{
|
||||||
let loop = 3;
|
let loop = 3;
|
||||||
@ -109,9 +132,10 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
this.localConfigWrapper.config._15_alarm_ignore = [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()];
|
this.localConfigWrapper.config._15_alarm_ignore = [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()];
|
||||||
// WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
// WuhuConfig.set('_15_alarm_ignore', [date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()], false);
|
||||||
// 通知
|
// 通知
|
||||||
const notify = new Alert(`明早8点前将不再提醒 <button id="wh-rd-btn-${ this.mathUtils.getRandomInt(0, 100) }">取消</button>`);
|
const rNumber = this.mathUtils.getRandomInt(0, 100);
|
||||||
|
const notify = this.msgWrapper.create(`明早8点前将不再提醒 <button id="wh-rd-btn-${ rNumber }">取消</button>`);
|
||||||
// 通知中的取消按钮
|
// 通知中的取消按钮
|
||||||
notify.getElement().querySelector('.wh-notify-msg button')
|
document.querySelector('#wh-rd-btn-' + rNumber)
|
||||||
.addEventListener(
|
.addEventListener(
|
||||||
'click',
|
'click',
|
||||||
() => this.localConfigWrapper.config._15_alarm_ignore.length = 0
|
() => this.localConfigWrapper.config._15_alarm_ignore.length = 0
|
||||||
@ -138,11 +162,14 @@ export default class BuyBeerHelper implements BeerMonitorLoop, ResponseInject {
|
|||||||
popup.element.appendChild(confirm);
|
popup.element.appendChild(confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }, opt: { method: "GET" | "POST"; requestBody: string }) {
|
public responseHandler(url: string, body: { json: unknown; text: string; isModified: boolean }, opt: {
|
||||||
|
method: "GET" | "POST";
|
||||||
|
requestBody: string
|
||||||
|
}) {
|
||||||
if (url.includes('shops.php') && opt?.method === 'POST') {
|
if (url.includes('shops.php') && opt?.method === 'POST') {
|
||||||
let req = opt.requestBody;
|
let req = opt.requestBody;
|
||||||
if (req && req.includes('step=buyShopItem') && req.includes('ID=180') && body.json && body.json['success']) {
|
if (req && req.includes('step=buyShopItem') && req.includes('ID=180') && body.json && body.json['success']) {
|
||||||
new Alert('检测到已成功购买啤酒');
|
this.msgWrapper.create('检测到已成功购买啤酒');
|
||||||
this.skip_today();
|
this.skip_today();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
25
src/ts/feature/ChristmasTown.ts
Normal file
25
src/ts/feature/ChristmasTown.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import christmasTownHelper from "../func/module/christmasTownHelper";
|
||||||
|
|
||||||
|
@ClassName('ChristmasTown')
|
||||||
|
@Injectable()
|
||||||
|
export default class ChristmasTown implements IFeature {
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/christmas_town\.php/]
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return '圣诞小镇助手'
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
christmasTownHelper()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,27 +1,46 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../class/utils/FetchUtils";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import InfoUtils from "../class/utils/InfoUtils";
|
||||||
import Alert from "../utils/Alert";
|
import TRAVEL_STATE from "../enum/TravelState";
|
||||||
import TRAVEL_STATE from "../../enum/TravelState";
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import { Injectable } from "../container/Injectable";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import ClassName from "../container/ClassName";
|
||||||
import ClassName from "../../container/ClassName";
|
import Logger from "../class/Logger";
|
||||||
import Logger from "../Logger";
|
import MsgWrapper from "../class/utils/MsgWrapper";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
|
||||||
|
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公司助手
|
* 公司助手
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('CompanyHelper')
|
@ClassName('CompanyHelper')
|
||||||
export default class CompanyHelper {
|
export default class CompanyHelper implements IFeature {
|
||||||
className = 'CompanyHelper';
|
private readonly logger: Logger = Logger.factory(CompanyHelper)
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "公司助手、火车爆仓检测";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [ATK_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [ALL_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly fetchUtils: FetchUtils,
|
private readonly fetchUtils: FetchUtils,
|
||||||
private readonly logger: Logger,
|
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,10 +48,6 @@ export default class CompanyHelper {
|
|||||||
this.localConfigWrapper.config.CHTrainsDetectSwitch && this.trainsDetect().then();
|
this.localConfigWrapper.config.CHTrainsDetectSwitch && this.trainsDetect().then();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public detectNow(): void {
|
|
||||||
// this.trainsDetect(true).then();
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 火车检测
|
* 火车检测
|
||||||
* 每日判断一次,非公司老板跳过检测
|
* 每日判断一次,非公司老板跳过检测
|
||||||
@ -40,7 +55,7 @@ export default class CompanyHelper {
|
|||||||
*/
|
*/
|
||||||
private async trainsDetect(test: boolean = false): Promise<null> {
|
private async trainsDetect(test: boolean = false): Promise<null> {
|
||||||
// 通过用户的icon判断公司老板
|
// 通过用户的icon判断公司老板
|
||||||
if ((await this.infoUtils.getSessionData()).statusIcons.icons.company.iconID !== 'icon73') {
|
if ((await this.infoUtils.getSessionData()).statusIcons.icons.company?.iconID !== 'icon73') {
|
||||||
this.logger.info('火车检测跳过:非公司老板');
|
this.logger.info('火车检测跳过:非公司老板');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -55,7 +70,7 @@ export default class CompanyHelper {
|
|||||||
this.fetchUtils.fetchText('/companies.php')
|
this.fetchUtils.fetchText('/companies.php')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let tmp: HTMLElement = document.createElement('div');
|
let tmp: HTMLElement = document.createElement('div');
|
||||||
let bodyTagStart = this.commonUtils.matchOne(res, /<body.+>/);
|
let bodyTagStart = this.commonUtils.matchOne(res, /<body.+/);
|
||||||
if (!bodyTagStart) {
|
if (!bodyTagStart) {
|
||||||
this.logger.warn('火车检测: 无法获取数据');
|
this.logger.warn('火车检测: 无法获取数据');
|
||||||
throw new Error('火车检测: 无法获取数据');
|
throw new Error('火车检测: 无法获取数据');
|
||||||
@ -76,7 +91,7 @@ export default class CompanyHelper {
|
|||||||
this.logger.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
this.logger.info('火车检测: 火车/星级: ' + trains + '/' + stars);
|
||||||
this.logger.info({ tmp });
|
this.logger.info({ tmp });
|
||||||
if (trains + stars > 20) {
|
if (trains + stars > 20) {
|
||||||
new Alert(`公司助手<br/><br/>火车检测:火车明日将溢出!${ trains }/20火车`, {
|
this.msgWrapper.create(`【公司助手】火车检测:火车明日将溢出!${ trains }/20火车`, {
|
||||||
timeout: 15,
|
timeout: 15,
|
||||||
force: true,
|
force: true,
|
||||||
sysNotify: true
|
sysNotify: true
|
||||||
78
src/ts/feature/CrimePageModifier.ts
Normal file
78
src/ts/feature/CrimePageModifier.ts
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
|
import QUICK_CRIMES_HTML from "../../static/html/quick_crimes.html";
|
||||||
|
|
||||||
|
@ClassName('CrimePageModifier')
|
||||||
|
@Injectable()
|
||||||
|
export default class CrimePageModifier implements IFeature {
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "页面快速crime";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/crimes\.php/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() { // TODO 重构、与翻译解藕
|
||||||
|
if (this.localConfigWrapper.config.quickCrime) {
|
||||||
|
// iframe
|
||||||
|
if (self !== top) {
|
||||||
|
const isValidate = document.querySelector('h4#skip-to-content').innerText.toLowerCase().includes('validate');
|
||||||
|
CommonUtils.elementReady('#header-root').then(e => e.style.display = 'none');
|
||||||
|
CommonUtils.elementReady('#sidebarroot').then(e => e.style.display = 'none');
|
||||||
|
CommonUtils.elementReady('#chatRoot').then(e => e.style.display = 'none');
|
||||||
|
if (!isValidate) document.body.style.overflow = 'hidden';
|
||||||
|
CommonUtils.elementReady('.content-wrapper').then(e => {
|
||||||
|
e.style.margin = '0px';
|
||||||
|
e.style.position = 'absolute';
|
||||||
|
e.style.top = '-35px';
|
||||||
|
});
|
||||||
|
CommonUtils.elementReady('#go-to-top-btn button').then(e => e.style.display = 'none');
|
||||||
|
}
|
||||||
|
const element = document.querySelector('.content-wrapper');
|
||||||
|
const OB = new MutationObserver(() => {
|
||||||
|
OB.disconnect();
|
||||||
|
trans();
|
||||||
|
OB.observe(element, {
|
||||||
|
characterData: true,
|
||||||
|
attributes: true,
|
||||||
|
subtree: true,
|
||||||
|
childList: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const trans = () => {
|
||||||
|
const dom = QUICK_CRIMES_HTML;
|
||||||
|
const hasInserted = element.querySelector('.wh-translate') !== null;
|
||||||
|
const $title = document.querySelector('div.content-title');
|
||||||
|
const $info = document.querySelector('.info-msg-cont');
|
||||||
|
if (!hasInserted) {
|
||||||
|
if ($title) $title.insertAdjacentHTML('beforebegin', dom);
|
||||||
|
else if ($info) $info.insertAdjacentHTML('beforebegin', dom);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
trans();
|
||||||
|
OB.observe(element, {
|
||||||
|
characterData: true,
|
||||||
|
attributes: true,
|
||||||
|
subtree: true,
|
||||||
|
childList: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
76
src/ts/feature/IconHelper.ts
Normal file
76
src/ts/feature/IconHelper.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import Logger, { LoggerKey } from "../class/Logger"
|
||||||
|
import ClassName from "../container/ClassName"
|
||||||
|
import { Injectable } from "../container/Injectable"
|
||||||
|
import CommonUtils, { CommonUtilsKey } from "../class/utils/CommonUtils"
|
||||||
|
import LocalConfigWrapper, { LocalConfigWrapperKey } from "../class/LocalConfigWrapper"
|
||||||
|
import { createApp } from "vue"
|
||||||
|
import FloatMenu from "../../vue/FloatMenu.vue"
|
||||||
|
import PopupWrapper, { PopupWrapperKey } from "../class/utils/PopupWrapper"
|
||||||
|
import TravelItem from "./TravelItem"
|
||||||
|
import QuickGymTrain, { QuickGymTrainKey } from "../class/action/QuickGymTrain"
|
||||||
|
import QuickFlyBtnHandler, { QuickFlyBtnHandlerKey } from "../class/handler/QuickFlyBtnHandler"
|
||||||
|
import ItemHelper, { ItemHelperKey } from "../class/utils/ItemHelper"
|
||||||
|
import MathUtils, { MathUtilsKey } from "../class/utils/MathUtils"
|
||||||
|
import IFeature from "../man/IFeature"
|
||||||
|
import ALL_PAGE_REG from "./url/ALL_PAGE_REG"
|
||||||
|
|
||||||
|
@ClassName("IconHelper")
|
||||||
|
@Injectable()
|
||||||
|
export default class IconHelper implements IFeature {
|
||||||
|
private readonly _element: HTMLElement = document.createElement('div');
|
||||||
|
private readonly logger = Logger.factory(IconHelper)
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "浮动图标、侧边菜单、标签式便携功能";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [ALL_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly popupWrapper: PopupWrapper,
|
||||||
|
private readonly travelItem: TravelItem,
|
||||||
|
private readonly quickGymTrain: QuickGymTrain,
|
||||||
|
private readonly quickFlyBtnHandler: QuickFlyBtnHandler,
|
||||||
|
private readonly itemHelper: ItemHelper,
|
||||||
|
private readonly mathUtils: MathUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
get element() {
|
||||||
|
return this._element;
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._element.id = 'WHMenu2023';
|
||||||
|
document.body.append(this._element);
|
||||||
|
let app = createApp(FloatMenu);
|
||||||
|
this.logger.info('Vue实例已创建', { app })
|
||||||
|
|
||||||
|
app.config.errorHandler = (err) => this.logger.error('[VUE错误]', err);
|
||||||
|
app.config.warnHandler = (err) => this.logger.warn('[VUE警告]', err);
|
||||||
|
app.provide(LoggerKey, this.logger);
|
||||||
|
app.provide(CommonUtilsKey, this.commonUtils);
|
||||||
|
app.provide(MathUtilsKey, this.mathUtils);
|
||||||
|
// app.provide(TravelItemKey, this.travelItem);
|
||||||
|
app.provide(PopupWrapperKey, this.popupWrapper);
|
||||||
|
app.provide(LocalConfigWrapperKey, this.localConfigWrapper);
|
||||||
|
app.provide(QuickGymTrainKey, this.quickGymTrain);
|
||||||
|
app.provide(QuickFlyBtnHandlerKey, this.quickFlyBtnHandler);
|
||||||
|
app.provide(ItemHelperKey, this.itemHelper);
|
||||||
|
app.mount(this._element);
|
||||||
|
this.logger.info('Vue实例已挂载')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,19 +1,34 @@
|
|||||||
import Log from "../Log";
|
import InfoUtils from "../class/utils/InfoUtils";
|
||||||
import InfoUtils from "../utils/InfoUtils";
|
import MathUtils from "../class/utils/MathUtils";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import TornStyleBlock from "../class/utils/TornStyleBlock";
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import Timer from "../class/utils/Timer";
|
||||||
import Timer from "../utils/Timer";
|
import FetchUtils from "../class/utils/FetchUtils";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import { Injectable } from "../container/Injectable";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import ClassName from "../container/ClassName";
|
||||||
import ClassName from "../../container/ClassName";
|
import Logger from "../class/Logger";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 彩票助手
|
* 彩票助手
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('LotteryHelper')
|
@ClassName('LotteryHelper')
|
||||||
export default class LotteryHelper {
|
export default class LotteryHelper implements IFeature {
|
||||||
|
private readonly logger: Logger = Logger.factory(LotteryHelper)
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "彩票助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
private loopFlag = true;
|
private loopFlag = true;
|
||||||
|
|
||||||
private radioDaily: HTMLInputElement = null;
|
private radioDaily: HTMLInputElement = null;
|
||||||
@ -26,6 +41,10 @@ export default class LotteryHelper {
|
|||||||
private status: HTMLElement = null;
|
private status: HTMLElement = null;
|
||||||
private desc: HTMLElement = null;
|
private desc: HTMLElement = null;
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/loader\.php\?sid=lottery/];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly mathUtils: MathUtils,
|
private readonly mathUtils: MathUtils,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
@ -36,7 +55,7 @@ export default class LotteryHelper {
|
|||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
let startTime = new Timer();
|
let startTime = new Timer();
|
||||||
Log.info('彩票助手初始化开始');
|
this.logger.info('彩票助手初始化开始');
|
||||||
|
|
||||||
let radioLabelDaily = document.createElement('label');
|
let radioLabelDaily = document.createElement('label');
|
||||||
let radioLabelWeekly = document.createElement('label');
|
let radioLabelWeekly = document.createElement('label');
|
||||||
@ -112,7 +131,7 @@ export default class LotteryHelper {
|
|||||||
progressBarBg, progressBar, status, desc).insert2Dom();
|
progressBarBg, progressBar, status, desc).insert2Dom();
|
||||||
// document.querySelector('#websocketConnectionData').after(container);
|
// document.querySelector('#websocketConnectionData').after(container);
|
||||||
|
|
||||||
Log.info('彩票助手初始化结束,耗时:' + startTime.getTimeMs());
|
this.logger.info('彩票助手初始化结束,耗时:' + startTime.getTimeMs());
|
||||||
}
|
}
|
||||||
|
|
||||||
private async start() {
|
private async start() {
|
||||||
@ -158,7 +177,7 @@ export default class LotteryHelper {
|
|||||||
if (this.loopFlag) rsMsg = '批量购买完成';
|
if (this.loopFlag) rsMsg = '批量购买完成';
|
||||||
} else {
|
} else {
|
||||||
rsMsg = '代币或现金不足';
|
rsMsg = '代币或现金不足';
|
||||||
Log.warn({ totalCost, inputNumber });
|
this.logger.warn({ totalCost, inputNumber });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rsMsg = '输入有误';
|
rsMsg = '输入有误';
|
||||||
50
src/ts/feature/MapItem.ts
Normal file
50
src/ts/feature/MapItem.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import TornStyleBlock from "../class/utils/TornStyleBlock";
|
||||||
|
import TornStyleSwitch from "../class/utils/TornStyleSwitch";
|
||||||
|
import cityFinder from "../func/module/cityFinder";
|
||||||
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
|
|
||||||
|
@ClassName('MapItem')
|
||||||
|
@Injectable()
|
||||||
|
export default class MapItem implements IFeature {
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "捡垃圾助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/city\.php/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if (this.localConfigWrapper.config.cityFinder) {
|
||||||
|
let _base = new TornStyleBlock('芜湖助手').insert2Dom();
|
||||||
|
// let reloadSwitch = new TornStyleSwitch('解决一直转圈(加载中)的问题');
|
||||||
|
// reloadSwitch.getInput().checked = this.localConfigWrapper.config.SolveGoogleScriptPendingIssue;
|
||||||
|
// _base.append(reloadSwitch.getBase()).insert2Dom();
|
||||||
|
// reloadSwitch.getInput().addEventListener('change', () => {
|
||||||
|
// if (reloadSwitch.getInput().checked) window.location.replace(window.location.href);
|
||||||
|
// this.localConfigWrapper.config.SolveGoogleScriptPendingIssue = reloadSwitch.getInput().checked;
|
||||||
|
// });
|
||||||
|
|
||||||
|
_base.append(document.createElement('br'));
|
||||||
|
|
||||||
|
cityFinder(_base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
77
src/ts/feature/MissionPageModifier.ts
Normal file
77
src/ts/feature/MissionPageModifier.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
|
import getTaskHint from "../func/translate/getTaskHint";
|
||||||
|
import { missionDict } from "../dictionary/translation";
|
||||||
|
|
||||||
|
@ClassName('MissionPageModifier')
|
||||||
|
@Injectable()
|
||||||
|
export default class MissionPageModifier implements IFeature {
|
||||||
|
constructor(
|
||||||
|
private readonly localConfigWrapper: LocalConfigWrapper
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "页面快速crime";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/crimes\.php/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
const anchor = document.querySelector('.content-wrapper');
|
||||||
|
const OB = new MutationObserver(() => {
|
||||||
|
OB.disconnect();
|
||||||
|
trans();
|
||||||
|
OB.observe(anchor, {
|
||||||
|
characterData: true,
|
||||||
|
attributes: true,
|
||||||
|
subtree: true,
|
||||||
|
childList: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const taskList = {};
|
||||||
|
const trans = () => {
|
||||||
|
$('ul#giver-tabs a.ui-tabs-anchor').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if ($e.children().hasClass('mission-complete-icon')) {
|
||||||
|
taskList[i] = e.innerText.trim();
|
||||||
|
} else {
|
||||||
|
taskList[i] = $e.clone().children().remove().end().text().trim();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 助手注入
|
||||||
|
$('div.max-height-fix.info').each((i, e) => {
|
||||||
|
let $e = $(e);
|
||||||
|
if ($e.find('.wh-translated').length !== 0) return;
|
||||||
|
$e.append(`<div class="wh-translated"><h6 style="color:green"><b>任务助手</b></h6><p>${ getTaskHint(taskList[i]) }</p></div>`);
|
||||||
|
});
|
||||||
|
// 任务目标
|
||||||
|
$('ul.tasks-list span.title-wrap').contents().each((i, e) => {
|
||||||
|
if (e.nodeType === 3) {
|
||||||
|
if (missionDict[e.nodeValue.trim()]) {
|
||||||
|
e.nodeValue = missionDict[e.nodeValue.trim()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
trans();
|
||||||
|
OB.observe(anchor, {
|
||||||
|
characterData: true,
|
||||||
|
attributes: true,
|
||||||
|
subtree: true,
|
||||||
|
childList: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,13 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
import Global from "../Global";
|
import Global from "../class/Global";
|
||||||
import Device from "../../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import Log from "../Log";
|
import ClassName from "../container/ClassName";
|
||||||
import ClassName from "../../container/ClassName";
|
import { Injectable } from "../container/Injectable";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import Logger from "../class/Logger";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
|
||||||
|
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ### 边栏助手
|
* ### 边栏助手
|
||||||
@ -13,12 +16,29 @@ import LocalConfigWrapper from "../LocalConfigWrapper";
|
|||||||
*/
|
*/
|
||||||
@ClassName('SidebarHelper')
|
@ClassName('SidebarHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class SidebarHelper {
|
export default class SidebarHelper implements IFeature {
|
||||||
|
private readonly logger: Logger = Logger.factory(SidebarHelper)
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "边栏助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [ATK_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
private readonly sidebarRootNode: HTMLElement;
|
private readonly sidebarRootNode: HTMLElement;
|
||||||
private readonly toggleBtn: HTMLButtonElement;
|
private readonly toggleBtn: HTMLButtonElement;
|
||||||
private isHide: boolean;
|
private isHide: boolean;
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [ALL_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
private readonly global: Global,
|
private readonly global: Global,
|
||||||
@ -34,7 +54,7 @@ export default class SidebarHelper {
|
|||||||
this.initToggleBtn();
|
this.initToggleBtn();
|
||||||
this.barRedirect();
|
this.barRedirect();
|
||||||
} else {
|
} else {
|
||||||
Log.warn('[SidebarHelper] 页面未开启边栏,边栏助手退出');
|
this.logger.warn('页面未开启边栏,边栏助手退出');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,10 +92,10 @@ export default class SidebarHelper {
|
|||||||
// 4条转跳
|
// 4条转跳
|
||||||
private barRedirect(): void {
|
private barRedirect(): void {
|
||||||
if (this.localConfigWrapper.config.barsRedirect) {
|
if (this.localConfigWrapper.config.barsRedirect) {
|
||||||
const eb = document.getElementById('barEnergy') as HTMLAnchorElement;
|
const eb = document.querySelector<HTMLAnchorElement>('#barEnergy');
|
||||||
const nb = document.getElementById('barNerve') as HTMLAnchorElement;
|
const nb = document.querySelector<HTMLAnchorElement>('#barNerve');
|
||||||
const hb = document.getElementById('barHappy') as HTMLAnchorElement;
|
const hb = document.querySelector<HTMLAnchorElement>('#barHappy');
|
||||||
const lb = document.getElementById('barLife') as HTMLAnchorElement;
|
const lb = document.querySelector<HTMLAnchorElement>('#barLife');
|
||||||
if (eb) {
|
if (eb) {
|
||||||
eb.addEventListener('click', () => location.href = '/gym.php');
|
eb.addEventListener('click', () => location.href = '/gym.php');
|
||||||
eb.href = '/gym.php';
|
eb.href = '/gym.php';
|
||||||
@ -1,15 +1,36 @@
|
|||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../class/utils/TornStyleBlock";
|
||||||
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
import TornStyleSwitch from "../class/utils/TornStyleSwitch";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import { Injectable } from "../container/Injectable";
|
||||||
import ClassName from "../../container/ClassName";
|
import ClassName from "../container/ClassName";
|
||||||
import LocalConfigWrapper from "../LocalConfigWrapper";
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ClassName('StackHelper')
|
@ClassName('StackHelper')
|
||||||
export default class StackHelper {
|
export default class StackHelper implements IFeature {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
) {
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "叠e助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [/gym\.php/];
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
let block = new TornStyleBlock('叠E保护').insert2Dom();
|
let block = new TornStyleBlock('叠E保护').insert2Dom();
|
||||||
let switcher = new TornStyleSwitch('启用');
|
let switcher = new TornStyleSwitch('启用');
|
||||||
let input = switcher.getInput();
|
let input = switcher.getInput();
|
||||||
@ -23,5 +44,4 @@ export default class StackHelper {
|
|||||||
this.localConfigWrapper.config.SEProtect = target.checked;
|
this.localConfigWrapper.config.SEProtect = target.checked;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,49 +1,20 @@
|
|||||||
import titleTrans from "../translate/titleTrans";
|
import titleTrans from "../func/translate/titleTrans";
|
||||||
import contentTitleLinksTrans from "../translate/contentTitleLinksTrans";
|
import contentTitleLinksTrans from "../func/translate/contentTitleLinksTrans";
|
||||||
import Device from "../../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import Alert from "../../class/utils/Alert";
|
import ActionButtonUtils from "../class/utils/ActionButtonUtils";
|
||||||
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import TRAVEL_ALARM_CSS from "../../static/css/travel_alarm.module.css";
|
||||||
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.module.css";
|
import TRAVEL_ALARM_HTML from "../../static/html/travel_alarm.html";
|
||||||
import TRAVEL_ALARM_HTML from "../../../static/html/travel_alarm.html";
|
import TornStyleBlock from "../class/utils/TornStyleBlock";
|
||||||
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
import QuickFlyBtnHandler from "../class/handler/QuickFlyBtnHandler";
|
||||||
import QuickFlyBtnHandler from "../../class/handler/QuickFlyBtnHandler";
|
import TRAVEL_STATE from "../enum/TravelState";
|
||||||
import TRAVEL_STATE from "../../enum/TravelState";
|
import Global from "../class/Global";
|
||||||
import Global from "../../class/Global";
|
import ClassName from "../container/ClassName";
|
||||||
import ClassName from "../../container/ClassName";
|
import { Injectable } from "../container/Injectable";
|
||||||
import { Injectable } from "../../container/Injectable";
|
import LocalConfigWrapper from "../class/LocalConfigWrapper";
|
||||||
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
import MsgWrapper from "../class/utils/MsgWrapper";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
// async function travelHelper(): Promise<void> {
|
import INDEX_PAGE_REG from "./url/INDEX_PAGE_REG";
|
||||||
// let global = Container.factory(Global);
|
|
||||||
// let commonUtils = Container.factory(CommonUtils);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async function travelBack(): Promise<null> {
|
|
||||||
// if (typeof window['getAction'] !== 'function') return;
|
|
||||||
// let backHomeAction = function (): Promise<string> {
|
|
||||||
// return new Promise(resolve => {
|
|
||||||
// window.getAction({
|
|
||||||
// type: "post",
|
|
||||||
// action: 'travelagency.php',
|
|
||||||
// data: {
|
|
||||||
// step: 'backHomeAction'
|
|
||||||
// },
|
|
||||||
// success: function (msg) {
|
|
||||||
// resolve(msg);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// let res = await backHomeAction();
|
|
||||||
// new Alert(res);
|
|
||||||
// if (!res.includes('error')) {
|
|
||||||
// new Alert('成功,即将刷新');
|
|
||||||
// window.setTimeout(() => location.reload(), 3000);
|
|
||||||
// } else {
|
|
||||||
// new Alert('出错了');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 飞行助手
|
* 飞行助手
|
||||||
@ -55,12 +26,29 @@ import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
|||||||
*/
|
*/
|
||||||
@ClassName('TravelHelper')
|
@ClassName('TravelHelper')
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class TravelHelper {
|
export default class TravelHelper implements IFeature {
|
||||||
|
description(): string {
|
||||||
|
return "飞行助手";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [INDEX_PAGE_REG, /travelagency\.php/];
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly global: Global,
|
private readonly global: Global,
|
||||||
private readonly commonUtils: CommonUtils,
|
private readonly commonUtils: CommonUtils,
|
||||||
private readonly actionButtonUtils: ActionButtonUtils,
|
private readonly actionButtonUtils: ActionButtonUtils,
|
||||||
private readonly localConfigWrapper: LocalConfigWrapper,
|
private readonly localConfigWrapper: LocalConfigWrapper,
|
||||||
|
private readonly msgWrapper: MsgWrapper,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,10 +121,6 @@ export default class TravelHelper {
|
|||||||
const set_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[0] as HTMLButtonElement;
|
const set_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[0] as HTMLButtonElement;
|
||||||
// 落地前响铃时长
|
// 落地前响铃时长
|
||||||
const cd_time = wh_trv_alarm_node.querySelector('input[type="number"]') as HTMLInputElement;
|
const cd_time = wh_trv_alarm_node.querySelector('input[type="number"]') as HTMLInputElement;
|
||||||
let count_down_notify: MyHTMLElement | { close: Function } = {
|
|
||||||
close: () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
set_node.onclick = () => {
|
set_node.onclick = () => {
|
||||||
try {
|
try {
|
||||||
wh_trv_alarm.alert_time = parseInt(cd_time.value);
|
wh_trv_alarm.alert_time = parseInt(cd_time.value);
|
||||||
@ -145,8 +129,7 @@ export default class TravelHelper {
|
|||||||
}
|
}
|
||||||
save_trv_settings();
|
save_trv_settings();
|
||||||
set_node.value = wh_trv_alarm.alert_time;
|
set_node.value = wh_trv_alarm.alert_time;
|
||||||
count_down_notify.close();
|
this.msgWrapper.create('设置已更新');
|
||||||
count_down_notify = new Alert('设置已更新');
|
|
||||||
};
|
};
|
||||||
// 停止响铃按钮
|
// 停止响铃按钮
|
||||||
const stop_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[1] as HTMLButtonElement;
|
const stop_node = wh_trv_alarm_node.querySelectorAll('#wh-trv-alarm-cont button')[1] as HTMLButtonElement;
|
||||||
@ -157,15 +140,10 @@ export default class TravelHelper {
|
|||||||
}
|
}
|
||||||
// 开启闹钟勾选
|
// 开启闹钟勾选
|
||||||
const enable_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-cont input[type="checkbox"]') as HTMLInputElement;
|
const enable_node = wh_trv_alarm_node.querySelector('#wh-trv-alarm-cont input[type="checkbox"]') as HTMLInputElement;
|
||||||
let on_off_notify: MyHTMLElement | { close: Function } = {
|
|
||||||
close: () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
enable_node.onchange = ev => {
|
enable_node.onchange = ev => {
|
||||||
wh_trv_alarm.enable = (<HTMLInputElement>ev.target).checked;
|
wh_trv_alarm.enable = (<HTMLInputElement>ev.target).checked;
|
||||||
save_trv_settings();
|
save_trv_settings();
|
||||||
on_off_notify.close();
|
this.msgWrapper.create(wh_trv_alarm.enable ? '闹钟已开启' : '闹钟已关闭');
|
||||||
on_off_notify = new Alert(wh_trv_alarm.enable ? '闹钟已开启' : '闹钟已关闭');
|
|
||||||
};
|
};
|
||||||
// 剩余时间 秒
|
// 剩余时间 秒
|
||||||
const remaining_sec = parseInt(remaining_arr);
|
const remaining_sec = parseInt(remaining_arr);
|
||||||
@ -193,7 +171,7 @@ export default class TravelHelper {
|
|||||||
// 响铃的方法
|
// 响铃的方法
|
||||||
let audio_play_handle = () => {
|
let audio_play_handle = () => {
|
||||||
if (user_stop_alert) {
|
if (user_stop_alert) {
|
||||||
clearInterval(audio_play_id);
|
window.clearInterval(audio_play_id);
|
||||||
audio_play_id = null;
|
audio_play_id = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -234,7 +212,7 @@ export default class TravelHelper {
|
|||||||
} else {
|
} else {
|
||||||
// flying_status.innerHTML = `飞行中...`;
|
// flying_status.innerHTML = `飞行中...`;
|
||||||
if (wh_trv_alarm.enable) {
|
if (wh_trv_alarm.enable) {
|
||||||
clearInterval(audio_play_id);
|
window.clearInterval(audio_play_id);
|
||||||
audio_play_id = null;
|
audio_play_id = null;
|
||||||
stop_node.parentElement.classList.add('wh-trv-alarm-stop-hide');
|
stop_node.parentElement.classList.add('wh-trv-alarm-stop-hide');
|
||||||
}
|
}
|
||||||
@ -260,7 +238,7 @@ export default class TravelHelper {
|
|||||||
// 海外警告
|
// 海外警告
|
||||||
if (this.localConfigWrapper.config.abroadWarning) {
|
if (this.localConfigWrapper.config.abroadWarning) {
|
||||||
let c = 1;
|
let c = 1;
|
||||||
setInterval(() => new Alert(`警告:您已海外落地${ c++ * 30 }秒`, {
|
setInterval(() => this.msgWrapper.create(`警告:您已海外落地${ c++ * 30 }秒`, {
|
||||||
timeout: 30,
|
timeout: 30,
|
||||||
sysNotify: true
|
sysNotify: true
|
||||||
}), 30000);
|
}), 30000);
|
||||||
@ -306,6 +284,7 @@ export default class TravelHelper {
|
|||||||
});
|
});
|
||||||
const trans = () => {
|
const trans = () => {
|
||||||
// 当前能量e
|
// 当前能量e
|
||||||
|
// @ts-ignore
|
||||||
const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim();
|
const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim();
|
||||||
const [curE, maxE] = energyBarStr.split('/').length === 2
|
const [curE, maxE] = energyBarStr.split('/').length === 2
|
||||||
? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])]
|
? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])]
|
||||||
@ -314,6 +293,7 @@ export default class TravelHelper {
|
|||||||
const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime
|
const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime
|
||||||
+ (incTime - new Date().getMinutes() % incTime) : NaN;
|
+ (incTime - new Date().getMinutes() % incTime) : NaN;
|
||||||
// 起飞前提示
|
// 起飞前提示
|
||||||
|
// @ts-ignore
|
||||||
$('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => {
|
$('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => {
|
||||||
if (isNaN(fullEnergyTime)) return;
|
if (isNaN(fullEnergyTime)) return;
|
||||||
const spl = e.innerText.trim().split(' ');
|
const spl = e.innerText.trim().split(' ');
|
||||||
@ -344,10 +324,6 @@ export default class TravelHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TODO */
|
|
||||||
inTravelPage() {
|
|
||||||
}
|
|
||||||
|
|
||||||
async doTravelBack(): Promise<void> {
|
async doTravelBack(): Promise<void> {
|
||||||
if (typeof window['getAction'] !== 'function') return;
|
if (typeof window['getAction'] !== 'function') return;
|
||||||
let backHomeAction = function (): Promise<string> {
|
let backHomeAction = function (): Promise<string> {
|
||||||
@ -365,12 +341,12 @@ export default class TravelHelper {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
let res = await backHomeAction();
|
let res = await backHomeAction();
|
||||||
new Alert(res);
|
this.msgWrapper.create(res);
|
||||||
if (!res.includes('error')) {
|
if (!res.includes('error')) {
|
||||||
new Alert('成功,即将刷新');
|
this.msgWrapper.create('成功,即将刷新');
|
||||||
window.setTimeout(() => location.reload(), 3000);
|
window.setTimeout(() => location.reload(), 3000);
|
||||||
} else {
|
} else {
|
||||||
new Alert('出错了');
|
this.msgWrapper.create('出错了');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
196
src/ts/feature/TravelItem.ts
Normal file
196
src/ts/feature/TravelItem.ts
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
import CommonUtils from "../class/utils/CommonUtils";
|
||||||
|
import UserScriptEngine from "../enum/UserScriptEngine";
|
||||||
|
import Popup from "../class/utils/Popup";
|
||||||
|
import STOCK_IMG_HTML from "../../static/html/stock_img.html";
|
||||||
|
import WindowActiveState from "../class/action/WindowActiveState";
|
||||||
|
import { Injectable } from "../container/Injectable";
|
||||||
|
import ClassName from "../container/ClassName";
|
||||||
|
import Logger from "../class/Logger";
|
||||||
|
import IFeature from "../man/IFeature";
|
||||||
|
import ATK_PAGE_REG from "./url/ATK_PAGE_REG";
|
||||||
|
import ALL_PAGE_REG from "./url/ALL_PAGE_REG";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
@ClassName('TravelItem')
|
||||||
|
export default class TravelItem implements IFeature {
|
||||||
|
private readonly logger: Logger = Logger.factory(TravelItem)
|
||||||
|
|
||||||
|
description(): string {
|
||||||
|
return "海外货物存量静默获取";
|
||||||
|
}
|
||||||
|
|
||||||
|
iStart(): void | Promise<void> {
|
||||||
|
this.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
urlExcludes(): RegExp[] {
|
||||||
|
return [ATK_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly apiUrl: string = 'https://yata.yt/api/v1/travel/export/';
|
||||||
|
private foreignStockInfo: any = null;
|
||||||
|
|
||||||
|
urlIncludes(): RegExp[] {
|
||||||
|
return [ALL_PAGE_REG];
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
private readonly windowActiveState: WindowActiveState,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
|
||||||
|
window.setInterval(async () => {
|
||||||
|
if (!this.windowActiveState.get()) return;
|
||||||
|
this.logger.info('COFetch ', this.apiUrl);
|
||||||
|
try {
|
||||||
|
this.foreignStockInfo = JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('解析错误', e.stack || e.message || e);
|
||||||
|
}
|
||||||
|
this.logger.info({ info: 'TravelItem 跨域返回', 'returned': this.foreignStockInfo });
|
||||||
|
}, 30 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get itemFiler() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"name": "mex",
|
||||||
|
"show": "墨西哥",
|
||||||
|
"stocks": {
|
||||||
|
"Dahlia": "花",
|
||||||
|
"Jaguar Plushie": "偶"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cay",
|
||||||
|
"show": "开曼",
|
||||||
|
"stocks": {
|
||||||
|
"Banana Orchid": "花",
|
||||||
|
"Stingray Plushie": "偶"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "can",
|
||||||
|
"show": "加拿大",
|
||||||
|
"stocks": {
|
||||||
|
"Crocus": "花",
|
||||||
|
"Wolverine Plushie": "偶"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "haw",
|
||||||
|
"show": "夏威夷",
|
||||||
|
"stocks": {
|
||||||
|
"Orchid": "花",
|
||||||
|
"Large Suitcase": "大箱"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "uni",
|
||||||
|
"show": "嘤国",
|
||||||
|
"stocks": {
|
||||||
|
"Heather": "花",
|
||||||
|
"Red Fox Plushie": "赤狐",
|
||||||
|
"Nessie Plushie": "水怪"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "arg",
|
||||||
|
"show": "阿根廷",
|
||||||
|
"stocks": {
|
||||||
|
"Ceibo Flower": "花",
|
||||||
|
"Monkey Plushie": "偶",
|
||||||
|
"Tear Gas": "催泪弹"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "swi",
|
||||||
|
"show": "瑞士",
|
||||||
|
"stocks": {
|
||||||
|
"Edelweiss": "花",
|
||||||
|
"Chamois Plushie": "偶"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jap",
|
||||||
|
"show": "日本",
|
||||||
|
"stocks": {
|
||||||
|
"Cherry Blossom": "花"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "chi",
|
||||||
|
"show": "祖国",
|
||||||
|
"stocks": {
|
||||||
|
"Peony": "花",
|
||||||
|
"Panda Plushie": "偶"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "uae",
|
||||||
|
"show": "阿联酋 (UAE)",
|
||||||
|
"stocks": {
|
||||||
|
"Tribulus Omanense": "花",
|
||||||
|
"Camel Plushie": "偶"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sou",
|
||||||
|
"show": "南非",
|
||||||
|
"stocks": {
|
||||||
|
"African Violet": "花",
|
||||||
|
"Lion Plushie": "偶",
|
||||||
|
"Xanax": "XAN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 呈现内容
|
||||||
|
public async clickHandler(): Promise<void> {
|
||||||
|
if (this.commonUtils.getScriptEngine() === UserScriptEngine.RAW) {
|
||||||
|
new Popup(STOCK_IMG_HTML.replace('{{}}', performance.now().toString()), '飞花库存');
|
||||||
|
} else {
|
||||||
|
const popup = new Popup("请稍后 " + CommonUtils.loading_gif_html(), '飞花库存');
|
||||||
|
let table = `<table><tr><th colspan="2">目的地 - 更新时间</th><th colspan="3">库存</th></tr>`;
|
||||||
|
// const dest = FILTER.default;
|
||||||
|
const dest = this.itemFiler;
|
||||||
|
const now = new Date();
|
||||||
|
const res = await this.get();
|
||||||
|
this.logger.info({ res })
|
||||||
|
if (!res || !res.stocks) return;
|
||||||
|
dest.forEach(el => {
|
||||||
|
const update = (now.getTime() - new Date(res.stocks[el.name]['update'] * 1000).getTime()) / 1000 | 0
|
||||||
|
table += `<tr><td>${ el.show }</td><td>${ update / 60 | 0 }分${ update % 60 | 0 }秒前</td>`;
|
||||||
|
let count = 0;
|
||||||
|
res.stocks[el.name]['stocks'].forEach(stock => {
|
||||||
|
if (el.stocks[stock.name]) {
|
||||||
|
table += `<td${ stock['quantity'] === 0 ? ' style="background-color:#f44336;color:white;border-color:#000;"' : '' }>${ el.stocks[stock.name] } (${ stock['quantity'] })</td>`;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
while (count < 3) {
|
||||||
|
count++;
|
||||||
|
table += '<td></td>';
|
||||||
|
}
|
||||||
|
table += '</tr>';
|
||||||
|
});
|
||||||
|
table += '</table>';
|
||||||
|
popup.getElement().innerHTML = table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get() {
|
||||||
|
try {
|
||||||
|
return this.foreignStockInfo ||= JSON.parse(await CommonUtils.COFetch(this.apiUrl));
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error('解析出错', e.stack || e.message || e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// export const TravelItemKey = Symbol('TravelItemKey') as InjectionKey<TravelItem>
|
||||||
2
src/ts/feature/url/ALL_PAGE_REG.ts
Normal file
2
src/ts/feature/url/ALL_PAGE_REG.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const ALL_PAGE_REG = /^/
|
||||||
|
export default ALL_PAGE_REG
|
||||||
2
src/ts/feature/url/ATK_PAGE_REG.ts
Normal file
2
src/ts/feature/url/ATK_PAGE_REG.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const ATK_PAGE_REG = /\/loader.php\?sid=attack&user2ID=/
|
||||||
|
export default ATK_PAGE_REG
|
||||||
2
src/ts/feature/url/INDEX_PAGE_REG.ts
Normal file
2
src/ts/feature/url/INDEX_PAGE_REG.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const INDEX_PAGE_REG = /index\.php/
|
||||||
|
export default INDEX_PAGE_REG
|
||||||
@ -1,7 +1,10 @@
|
|||||||
import Popup from "../../class/utils/Popup";
|
import Popup from "../../class/utils/Popup";
|
||||||
|
import { Container } from "../../container/Container";
|
||||||
|
import Logger from "../../class/Logger";
|
||||||
|
|
||||||
// 传单助手
|
// 传单助手
|
||||||
export default function adHelper() {
|
export default function adHelper() {
|
||||||
|
Container.factory(Logger).error('adHelper')
|
||||||
let popup = new Popup('', '传单助手').getElement();
|
let popup = new Popup('', '传单助手').getElement();
|
||||||
document.querySelector('#chatRoot').classList.remove('wh-hide');
|
document.querySelector('#chatRoot').classList.remove('wh-hide');
|
||||||
let info = document.createElement('p');
|
let info = document.createElement('p');
|
||||||
|
|||||||
@ -280,7 +280,7 @@ export default function christmasTownHelper() {
|
|||||||
const history = Object.keys(dropHist).map(key => dropHist[key]).sort((a, b) => a.id - b.id);
|
const history = Object.keys(dropHist).map(key => dropHist[key]).sort((a, b) => a.id - b.id);
|
||||||
let table_html = '';
|
let table_html = '';
|
||||||
history.forEach(e => {
|
history.forEach(e => {
|
||||||
table_html += `<tr><td>${ e.pos }</td><td>${ e.map }</td><td>${ e.name }</td><td>${ e.last }</td><td>${ e.isPassed ? '已取得' : '不确定' }</td></tr>`;
|
table_html += `<tr><td>${ e.pos }</td><td>${ e.map ?? e.data }</td><td>${ e.name }</td><td>${ e.last }</td><td>${ e.isPassed ? '已取得' : '不确定' }</td></tr>`;
|
||||||
});
|
});
|
||||||
$tbody.innerHTML = table_html;
|
$tbody.innerHTML = table_html;
|
||||||
localStorage.setItem('wh-loot-store', JSON.stringify(dropHist));
|
localStorage.setItem('wh-loot-store', JSON.stringify(dropHist));
|
||||||
@ -288,4 +288,4 @@ export default function christmasTownHelper() {
|
|||||||
});
|
});
|
||||||
getDOMOb.observe($root, { childList: true, subtree: true });
|
getDOMOb.observe($root, { childList: true, subtree: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,9 @@ import { Container } from "../../container/Container";
|
|||||||
* @param _base
|
* @param _base
|
||||||
*/
|
*/
|
||||||
export default function cityFinder(_base: TornStyleBlock): void {
|
export default function cityFinder(_base: TornStyleBlock): void {
|
||||||
Container.factory(CommonUtils).styleInject(CITY_FINDER_CSS);
|
let commonUtils: CommonUtils = Container.factory(CommonUtils);
|
||||||
|
commonUtils.styleInject(CITY_FINDER_CSS);
|
||||||
|
let itemHelper: ItemHelper = Container.factory(ItemHelper);
|
||||||
// 物品名与价格
|
// 物品名与价格
|
||||||
let items: {
|
let items: {
|
||||||
[k: number]: {
|
[k: number]: {
|
||||||
@ -28,8 +30,7 @@ export default function cityFinder(_base: TornStyleBlock): void {
|
|||||||
_base.append(header, info);
|
_base.append(header, info);
|
||||||
document.body.classList.add('wh-city-finds');
|
document.body.classList.add('wh-city-finds');
|
||||||
|
|
||||||
let itemHelper = Container.factory(ItemHelper);
|
commonUtils.querySelector('div.leaflet-marker-pane').then(elem => {
|
||||||
CommonUtils.elementReady('div.leaflet-marker-pane').then(elem => {
|
|
||||||
|
|
||||||
// 发现的物品id与map img node
|
// 发现的物品id与map img node
|
||||||
const founds = [];
|
const founds = [];
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import Log from "../../class/Log";
|
|
||||||
import Alert from "../../class/utils/Alert";
|
import Alert from "../../class/utils/Alert";
|
||||||
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
import ActionButtonUtils from "../../class/utils/ActionButtonUtils";
|
||||||
import FetchUtils from "../../class/utils/FetchUtils";
|
import FetchUtils from "../../class/utils/FetchUtils";
|
||||||
@ -7,10 +6,12 @@ import DEPO_CSS from "../../../static/css/depo.module.css";
|
|||||||
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
||||||
import { Container } from "../../container/Container";
|
import { Container } from "../../container/Container";
|
||||||
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
import LocalConfigWrapper from "../../class/LocalConfigWrapper";
|
||||||
|
import Logger from "../../class/Logger";
|
||||||
|
|
||||||
const fetchUtils = Container.factory(FetchUtils);
|
const fetchUtils = Container.factory(FetchUtils);
|
||||||
|
|
||||||
export default function depoHelper() {
|
export default function depoHelper() {
|
||||||
|
let logger: Logger = Container.factory(Logger);
|
||||||
let actionButtonUtils: ActionButtonUtils = Container.factory(ActionButtonUtils);
|
let actionButtonUtils: ActionButtonUtils = Container.factory(ActionButtonUtils);
|
||||||
let localConfigWrapper: LocalConfigWrapper = Container.factory(LocalConfigWrapper);
|
let localConfigWrapper: LocalConfigWrapper = Container.factory(LocalConfigWrapper);
|
||||||
let commonUtils: CommonUtils = Container.factory(CommonUtils);
|
let commonUtils: CommonUtils = Container.factory(CommonUtils);
|
||||||
@ -25,7 +26,7 @@ export default function depoHelper() {
|
|||||||
const btn = document.getElementById('ui-id-9');
|
const btn = document.getElementById('ui-id-9');
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.click();
|
btn.click();
|
||||||
Log.info('已自动打开存钱页面');
|
logger.info('已自动打开存钱页面');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 收起冰蛙表格
|
// 收起冰蛙表格
|
||||||
@ -80,14 +81,14 @@ export default function depoHelper() {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.info('已添加GT助手');
|
logger.info('已添加GT助手');
|
||||||
// 获取交易id
|
// 获取交易id
|
||||||
let query_params = location.hash.slice(1);
|
let query_params = location.hash.slice(1);
|
||||||
let traceId = id;
|
let traceId = id;
|
||||||
if (!traceId) query_params.split('&').forEach(param =>
|
if (!traceId) query_params.split('&').forEach(param =>
|
||||||
(param.startsWith('ID=')) && (traceId = param.slice(3))
|
(param.startsWith('ID=')) && (traceId = param.slice(3))
|
||||||
);
|
);
|
||||||
Log.info('交易id为', traceId);
|
logger.info('交易id为', traceId);
|
||||||
|
|
||||||
// 获取全部的钱数
|
// 获取全部的钱数
|
||||||
let getTraceMoney = async () => {
|
let getTraceMoney = async () => {
|
||||||
@ -101,7 +102,7 @@ export default function depoHelper() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 监听jquery ajax请求
|
// 监听jquery ajax请求
|
||||||
if (Log.debug()) $(document).ajaxComplete((_, xhr, settings) => Log.info({ xhr, settings }));
|
if (logger.debug()) $(document).ajaxComplete((_, xhr, settings) => logger.info({ xhr, settings }));
|
||||||
// react 加载完成后将节点加入视图中
|
// react 加载完成后将节点加入视图中
|
||||||
CommonUtils.elementReady('#trade-container').then(() =>
|
CommonUtils.elementReady('#trade-container').then(() =>
|
||||||
document.querySelector('#trade-container').before(_node.getBase())
|
document.querySelector('#trade-container').before(_node.getBase())
|
||||||
@ -197,7 +198,7 @@ export default function depoHelper() {
|
|||||||
} else {
|
} else {
|
||||||
if (node_link) node_link.remove();
|
if (node_link) node_link.remove();
|
||||||
node_link = null;
|
node_link = null;
|
||||||
Log.info('已移除GT助手');
|
logger.info('已移除GT助手');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ async function factionDeposit() {
|
|||||||
|
|
||||||
// 所有页面公司一键存钱
|
// 所有页面公司一键存钱
|
||||||
async function companyDepositAnywhere() {
|
async function companyDepositAnywhere() {
|
||||||
// let fetchUtils: FetchUtils = FetchUtils.getInstance();
|
const logger: Logger = Container.factory(Logger);
|
||||||
let { addRFC } = window;
|
let { addRFC } = window;
|
||||||
if (typeof addRFC !== 'function') return;
|
if (typeof addRFC !== 'function') return;
|
||||||
let url = addRFC('https://www.torn.com/inputMoneyAction.php?step=generalAction');
|
let url = addRFC('https://www.torn.com/inputMoneyAction.php?step=generalAction');
|
||||||
@ -274,7 +275,7 @@ async function companyDepositAnywhere() {
|
|||||||
body: 'deposit=' + money,
|
body: 'deposit=' + money,
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/x-www-form-urlencoded' }
|
headers: { 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})).text();
|
})).text();
|
||||||
Log.info(res);
|
logger.info(res);
|
||||||
let node = document.createElement('div');
|
let node = document.createElement('div');
|
||||||
node.innerHTML = res;
|
node.innerHTML = res;
|
||||||
let success = node.querySelector('.success-message');
|
let success = node.querySelector('.success-message');
|
||||||
|
|||||||
98
src/ts/func/module/fetchYata.ts
Normal file
98
src/ts/func/module/fetchYata.ts
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import CommonUtils from "../../class/utils/CommonUtils"
|
||||||
|
|
||||||
|
type YataBSEstData = {
|
||||||
|
"total": number,
|
||||||
|
"score": number,
|
||||||
|
"type": "Offensive" | "Defensive" | "Balanced",
|
||||||
|
"skewness": number,
|
||||||
|
"timestamp": number,
|
||||||
|
"version": 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
type YataApiResponse = {
|
||||||
|
// key为请求id
|
||||||
|
[key: number]: YataBSEstData
|
||||||
|
error?: { 'error': string, 'code': 1 | 2 | 3 | 4 }
|
||||||
|
}
|
||||||
|
|
||||||
|
type YataApiDataWrap = YataBSEstData & {
|
||||||
|
id: string,
|
||||||
|
isCache: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheExpireMs = 86400000 // 一天
|
||||||
|
const KEY = 'WHBSEstCache'
|
||||||
|
|
||||||
|
const getCacheObj = () => {
|
||||||
|
let obj: { [key: string]: YataApiDataWrap }
|
||||||
|
try {
|
||||||
|
obj = JSON.parse(localStorage.getItem(KEY)) ?? {}
|
||||||
|
} catch (e) {
|
||||||
|
obj = {}
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
const getCache = (id: number): YataApiDataWrap => {
|
||||||
|
let cache: YataApiDataWrap = getCacheObj()[id]
|
||||||
|
if (cache && ((Date.now() - (cache.timestamp * 1000)) < cacheExpireMs)) {
|
||||||
|
cache.isCache = true
|
||||||
|
} else {
|
||||||
|
cache = null
|
||||||
|
}
|
||||||
|
return cache
|
||||||
|
}
|
||||||
|
|
||||||
|
const setCache = (data: YataApiDataWrap): void => {
|
||||||
|
const cache = getCacheObj()
|
||||||
|
cache[data.id] = data
|
||||||
|
localStorage.setItem(KEY, JSON.stringify(cache))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空本地缓存
|
||||||
|
*/
|
||||||
|
const purge = () => {
|
||||||
|
localStorage.removeItem(KEY)
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchYata = async (id: number, apikey: string): Promise<YataApiDataWrap> => {
|
||||||
|
if (!id || !apikey) {
|
||||||
|
throw new TypeError('请求yata接口时出错: id和apikey不能为空')
|
||||||
|
}
|
||||||
|
const cache = getCache(id)
|
||||||
|
if (cache) {
|
||||||
|
return cache
|
||||||
|
} else {
|
||||||
|
let responseString: string, response: YataApiResponse
|
||||||
|
try {
|
||||||
|
responseString = await CommonUtils.COFetch(`https://yata.yt/api/v1/bs/${ id }?key=${ apikey }`)
|
||||||
|
} catch (e) {
|
||||||
|
throw new TypeError('请求yata接口时出错 ' + e.message)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
response = JSON.parse(responseString)
|
||||||
|
} catch (e) {
|
||||||
|
throw new TypeError('解析yata接口响应时出错 ' + e.message)
|
||||||
|
}
|
||||||
|
if (response.error) {
|
||||||
|
switch (response.error.code) {
|
||||||
|
case 1:
|
||||||
|
throw new TypeError('请求yata接口时出错: yata服务端错误-' + response.error.error)
|
||||||
|
case 2:
|
||||||
|
throw new TypeError('请求yata接口时出错: 脚本逻辑错误-' + response.error.error)
|
||||||
|
case 3:
|
||||||
|
throw new TypeError('请求yata接口时出错: 已达到次数限制-' + response.error.error)
|
||||||
|
case 4:
|
||||||
|
throw new TypeError('请求yata接口时出错: apikey错误-' + response.error.error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const wrapper = <YataApiDataWrap>response[id]
|
||||||
|
wrapper.id = String(id)
|
||||||
|
wrapper.isCache = false
|
||||||
|
setCache(wrapper)
|
||||||
|
return wrapper
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { fetchYata, YataApiDataWrap, purge }
|
||||||
@ -1,120 +1,120 @@
|
|||||||
import UserScriptEngine from "../../enum/UserScriptEngine";
|
// import UserScriptEngine from "../../enum/UserScriptEngine";
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
// import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import Alert from "../../class/utils/Alert";
|
// import Alert from "../../class/utils/Alert";
|
||||||
import { Container } from "../../container/Container";
|
// import { Container } from "../../container/Container";
|
||||||
import Logger from "../../class/Logger";
|
// import Logger from "../../class/Logger";
|
||||||
|
//
|
||||||
// gs loader
|
// // gs loader
|
||||||
export default function loadGS(use) {
|
// export default function loadGS(use) {
|
||||||
let logger = Container.factory(Logger);
|
// let logger = Container.factory(Logger);
|
||||||
if (use === UserScriptEngine.PDA) {
|
// if (use === UserScriptEngine.PDA) {
|
||||||
let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
|
// let ifr: HTMLIFrameElement = document.querySelector('#wh-gs-loader-ifr');
|
||||||
if (ifr) {
|
// if (ifr) {
|
||||||
new Alert('飞贼小助手已经加载了');
|
// new Alert('飞贼小助手已经加载了');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
const container = document.createElement('div');
|
// const container = document.createElement('div');
|
||||||
container.id = 'wh-gs-loader';
|
// container.id = 'wh-gs-loader';
|
||||||
ifr = document.createElement('iframe');
|
// ifr = document.createElement('iframe');
|
||||||
ifr.id = 'wh-gs-loader-ifr';
|
// ifr.id = 'wh-gs-loader-ifr';
|
||||||
ifr.src = 'https://www.torn.com/crimes.php';
|
// ifr.src = 'https://www.torn.com/crimes.php';
|
||||||
container.append(ifr);
|
// container.append(ifr);
|
||||||
document.body.append(container);
|
// document.body.append(container);
|
||||||
CommonUtils.addStyle(`
|
// CommonUtils.addStyle(`
|
||||||
#wh-gs-loader {
|
// #wh-gs-loader {
|
||||||
position:fixed;
|
// position:fixed;
|
||||||
top:0;
|
// top:0;
|
||||||
left:0;
|
// left:0;
|
||||||
z-index:100001;
|
// z-index:100001;
|
||||||
}
|
// }
|
||||||
`);
|
// `);
|
||||||
let notify = new Alert('加载中');
|
// let notify = new Alert('加载中');
|
||||||
ifr.onload = () => {
|
// ifr.onload = () => {
|
||||||
notify.close();
|
// notify.close();
|
||||||
const _window = ifr.contentWindow;
|
// const _window = ifr.contentWindow;
|
||||||
const _docu = _window.document;
|
// const _docu = _window.document;
|
||||||
_docu.head.innerHTML = '';
|
// _docu.head.innerHTML = '';
|
||||||
_docu.body.innerHTML = '';
|
// _docu.body.innerHTML = '';
|
||||||
notify = new Alert('加载依赖');
|
// notify = new Alert('加载依赖');
|
||||||
CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
// CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
||||||
.then(vuejs => {
|
// .then(vuejs => {
|
||||||
notify.close();
|
// notify.close();
|
||||||
_window.eval(vuejs);
|
// _window.eval(vuejs);
|
||||||
_window.GM_getValue = (k, v = undefined) => {
|
// _window.GM_getValue = (k, v = undefined) => {
|
||||||
const objV = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
// const objV = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
||||||
return objV || v;
|
// return objV || v;
|
||||||
};
|
// };
|
||||||
_window.GM_setValue = (k, v) => {
|
// _window.GM_setValue = (k, v) => {
|
||||||
const obj = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}');
|
// const obj = JSON.parse(_window.localStorage.getItem('wh-gs-storage') || '{}');
|
||||||
obj[k] = v;
|
// obj[k] = v;
|
||||||
_window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
// _window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
||||||
};
|
// };
|
||||||
_window.GM_xmlhttpRequest = function (opt) {
|
// _window.GM_xmlhttpRequest = function (opt) {
|
||||||
// 暂不适配pda post
|
// // 暂不适配pda post
|
||||||
if (opt.method.toLowerCase() === 'post') return;
|
// if (opt.method.toLowerCase() === 'post') return;
|
||||||
CommonUtils.COFetch(opt.url).then(res => {
|
// CommonUtils.COFetch(opt.url).then(res => {
|
||||||
const obj = {
|
// const obj = {
|
||||||
responseText: res
|
// responseText: res
|
||||||
};
|
// };
|
||||||
opt.onload(obj);
|
// opt.onload(obj);
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
notify = new Alert('加载飞贼小助手');
|
// notify = new Alert('加载飞贼小助手');
|
||||||
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
// CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||||
.then(res => {
|
// .then(res => {
|
||||||
_window.eval(res.replace('http://222.160.142.50:8154/mugger', `https://api.ljs-lyt.com/mugger`));
|
// _window.eval(res.replace('http://222.160.142.50:8154/mugger', `https://api.ljs-lyt.com/mugger`));
|
||||||
_window.GM_setValue("gsp_x", 10);
|
// _window.GM_setValue("gsp_x", 10);
|
||||||
_window.GM_setValue("gsp_y", 10);
|
// _window.GM_setValue("gsp_y", 10);
|
||||||
notify.close();
|
// notify.close();
|
||||||
notify = new Alert('飞贼小助手已加载', { timeout: 1 });
|
// notify = new Alert('飞贼小助手已加载', { timeout: 1 });
|
||||||
const gsp: HTMLElement = _docu.querySelector('#gsp');
|
// const gsp: HTMLElement = _docu.querySelector('#gsp');
|
||||||
const thisRun = () => {
|
// const thisRun = () => {
|
||||||
ifr.style.height = `${ gsp.offsetHeight + 10 }px`;
|
// ifr.style.height = `${ gsp.offsetHeight + 10 }px`;
|
||||||
ifr.style.width = `${ gsp.offsetWidth + 20 }px`;
|
// ifr.style.width = `${ gsp.offsetWidth + 20 }px`;
|
||||||
gsp.style.top = '10px';
|
// gsp.style.top = '10px';
|
||||||
gsp.style.left = '10px';
|
// gsp.style.left = '10px';
|
||||||
};
|
// };
|
||||||
new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
|
// new MutationObserver(thisRun).observe(gsp, { childList: true, subtree: true });
|
||||||
thisRun();
|
// thisRun();
|
||||||
if (logger.debug()) _window.GM_setValue("gsp_showContent", true)
|
// if (logger.debug()) _window.GM_setValue("gsp_showContent", true)
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (use === UserScriptEngine.GM) {
|
// if (use === UserScriptEngine.GM) {
|
||||||
if (typeof window.Vue !== 'function') {
|
// if (typeof window.Vue !== 'function') {
|
||||||
let notify = new Alert('正在加载依赖');
|
// let notify = new Alert('正在加载依赖');
|
||||||
CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
// CommonUtils.COFetch('https://cdn.staticfile.org/vue/2.2.2/vue.min.js')
|
||||||
.then(VueJS => {
|
// .then(VueJS => {
|
||||||
window.eval(VueJS);
|
// window.eval(VueJS);
|
||||||
notify.close();
|
// notify.close();
|
||||||
notify = new Alert('已载入依赖');
|
// notify = new Alert('已载入依赖');
|
||||||
window.GM_getValue = (k, v = undefined) => {
|
// window.GM_getValue = (k, v = undefined) => {
|
||||||
const objV = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
// const objV = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}')[k];
|
||||||
return objV || v;
|
// return objV || v;
|
||||||
};
|
// };
|
||||||
window.GM_setValue = (k, v) => {
|
// window.GM_setValue = (k, v) => {
|
||||||
const obj = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}');
|
// const obj = JSON.parse(window.localStorage.getItem('wh-gs-storage') || '{}');
|
||||||
obj[k] = v;
|
// obj[k] = v;
|
||||||
window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
// window.localStorage.setItem('wh-gs-storage', JSON.stringify(obj));
|
||||||
};
|
// };
|
||||||
// TODO
|
// // TODO
|
||||||
// window.GM_xmlhttpRequest = GM_xmlhttpRequest;
|
// // window.GM_xmlhttpRequest = GM_xmlhttpRequest;
|
||||||
CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
// CommonUtils.COFetch(`https://gitee.com/ameto_kasao/tornjs/raw/master/GoldenSnitch.js?${ performance.now() }`)
|
||||||
.then(GSJS => {
|
// .then(GSJS => {
|
||||||
window.eval(GSJS);
|
// window.eval(GSJS);
|
||||||
if (logger.debug()) window.GM_setValue("gsp_showContent", true);
|
// if (logger.debug()) window.GM_setValue("gsp_showContent", true);
|
||||||
notify.close();
|
// notify.close();
|
||||||
notify = new Alert('已载入飞贼助手');
|
// notify = new Alert('已载入飞贼助手');
|
||||||
})
|
// })
|
||||||
.catch(err => new Alert(`PDA API错误。${ JSON.stringify(err) }`));
|
// .catch(err => new Alert(`PDA API错误。${ JSON.stringify(err) }`));
|
||||||
})
|
// })
|
||||||
.catch(err => new Alert(JSON.stringify(err)));
|
// .catch(err => new Alert(JSON.stringify(err)));
|
||||||
} else {
|
// } else {
|
||||||
new Alert('飞贼助手已经加载了');
|
// new Alert('飞贼助手已经加载了');
|
||||||
}
|
// }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
new Alert('暂不支持');
|
// new Alert('暂不支持');
|
||||||
}
|
// }
|
||||||
@ -1,12 +1,13 @@
|
|||||||
import Alert from "../../class/utils/Alert";
|
import Alert from "../../class/utils/Alert";
|
||||||
import InfoUtils from "../../class/utils/InfoUtils";
|
import InfoUtils from "../../class/utils/InfoUtils";
|
||||||
import Log from "../../class/Log";
|
|
||||||
import Popup from "../../class/utils/Popup";
|
import Popup from "../../class/utils/Popup";
|
||||||
import { Container } from "../../container/Container";
|
import { Container } from "../../container/Container";
|
||||||
|
import Logger from "../../class/Logger";
|
||||||
|
|
||||||
// 守望者
|
// 守望者
|
||||||
export default function safeKeeper() {
|
export default function safeKeeper() {
|
||||||
let infoUtils = Container.factory(InfoUtils);
|
let infoUtils = Container.factory(InfoUtils);
|
||||||
|
let logger = Container.factory(Logger);
|
||||||
|
|
||||||
let url = `https://www.torn.com/loader.php?sid=attackData&mode=json&step=poll&user2ID=`;
|
let url = `https://www.torn.com/loader.php?sid=attackData&mode=json&step=poll&user2ID=`;
|
||||||
let popup = new Popup('<p>监测目标ID玩家的防御状态,找出隐身攻击者</p>', '守望者 (测试中)');
|
let popup = new Popup('<p>监测目标ID玩家的防御状态,找出隐身攻击者</p>', '守望者 (测试中)');
|
||||||
@ -51,13 +52,13 @@ export default function safeKeeper() {
|
|||||||
} else new Alert('守望者运行中,请先停止', { timeout: 2 });
|
} else new Alert('守望者运行中,请先停止', { timeout: 2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
popup.getElement().appendChild(p);
|
popup.element.appendChild(p);
|
||||||
popup.getElement().appendChild(uid);
|
popup.element.appendChild(uid);
|
||||||
popup.getElement().appendChild(start);
|
popup.element.appendChild(start);
|
||||||
popup.getElement().appendChild(stop);
|
popup.element.appendChild(stop);
|
||||||
popup.getElement().appendChild(self_target);
|
popup.element.appendChild(self_target);
|
||||||
popup.getElement().appendChild(attackers);
|
popup.element.appendChild(attackers);
|
||||||
popup.getElement().appendChild(records);
|
popup.element.appendChild(records);
|
||||||
|
|
||||||
start.addEventListener('click', () => {
|
start.addEventListener('click', () => {
|
||||||
if (loop_id !== null || !uid.value) return;
|
if (loop_id !== null || !uid.value) return;
|
||||||
@ -75,7 +76,7 @@ export default function safeKeeper() {
|
|||||||
})).text();
|
})).text();
|
||||||
if (loop_id !== that_id) return;
|
if (loop_id !== that_id) return;
|
||||||
let data = JSON.parse(res.split('<div')[0]);
|
let data = JSON.parse(res.split('<div')[0]);
|
||||||
Log.info(count++, data);
|
logger.info(count++, data);
|
||||||
let { DB, currentFightStatistics, histLog } = data;
|
let { DB, currentFightStatistics, histLog } = data;
|
||||||
// 攻击人
|
// 攻击人
|
||||||
// 格式:currentFightStatistics = {uid: {...}, uid2: {...}}
|
// 格式:currentFightStatistics = {uid: {...}, uid2: {...}}
|
||||||
|
|||||||
@ -67,57 +67,57 @@ export default function translateMain(href: string): void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 边栏
|
// 边栏
|
||||||
let sidebarTimeOut = 60;
|
// let sidebarTimeOut = 60;
|
||||||
const sidebarInterval = setInterval(() => {
|
// const sidebarInterval = setInterval(() => {
|
||||||
// 60秒后取消定时
|
// // 60秒后取消定时
|
||||||
if ($('div[class^="sidebar"]').length === 0) {
|
// if ($('div[class^="sidebar"]').length === 0) {
|
||||||
sidebarTimeOut--;
|
// sidebarTimeOut--;
|
||||||
if (sidebarTimeOut < 0) {
|
// if (sidebarTimeOut < 0) {
|
||||||
clearInterval(sidebarInterval);
|
// clearInterval(sidebarInterval);
|
||||||
}
|
// }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// 边栏块标题
|
// // 边栏块标题
|
||||||
$('h2[class^="header"]').each((i, e) => {
|
// $('h2[class^="header"]').each((i, e) => {
|
||||||
if (!sidebarDict[e.firstChild.nodeValue]) return;
|
// if (!sidebarDict[e.firstChild.nodeValue]) return;
|
||||||
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
// e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||||
});
|
// });
|
||||||
// 边栏人物名字
|
// // 边栏人物名字
|
||||||
$('span[class^="menu-name"]').each((i, e) => {
|
// $('span[class^="menu-name"]').each((i, e) => {
|
||||||
e.firstChild.nodeValue = '名字:';
|
// e.firstChild.nodeValue = '名字:';
|
||||||
});
|
// });
|
||||||
// 钱 等级 pt 天赋点
|
// // 钱 等级 pt 天赋点
|
||||||
$('p[class^="point-block"]').each((i, e) => {
|
// $('p[class^="point-block"]').each((i, e) => {
|
||||||
if (sidebarDict[e.firstChild.firstChild.nodeValue])
|
// if (sidebarDict[e.firstChild.firstChild.nodeValue])
|
||||||
e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue];
|
// e.firstChild.firstChild.nodeValue = sidebarDict[e.firstChild.firstChild.nodeValue];
|
||||||
});
|
// });
|
||||||
// 4条 状态条
|
// // 4条 状态条
|
||||||
$('p[class^="bar-name"]').each((i, e) => {
|
// $('p[class^="bar-name"]').each((i, e) => {
|
||||||
if (sidebarDict[e.firstChild.nodeValue])
|
// if (sidebarDict[e.firstChild.nodeValue])
|
||||||
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
// e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||||
});
|
// });
|
||||||
// 边栏菜单
|
// // 边栏菜单
|
||||||
$('span[class^="linkName"]').each((i, e) => {
|
// $('span[class^="linkName"]').each((i, e) => {
|
||||||
if (sidebarDict[e.firstChild.nodeValue])
|
// if (sidebarDict[e.firstChild.nodeValue])
|
||||||
e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
// e.firstChild.nodeValue = sidebarDict[e.firstChild.nodeValue];
|
||||||
});
|
// });
|
||||||
// [use]按钮
|
// // [use]按钮
|
||||||
if (document.querySelector('#pointsMerits'))
|
// if (document.querySelector('#pointsMerits'))
|
||||||
$('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
|
// $('#pointsMerits')[0].firstChild.nodeValue = '[使用]';
|
||||||
if (document.querySelector('#pointsPoints'))
|
// if (document.querySelector('#pointsPoints'))
|
||||||
$('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
|
// $('#pointsPoints')[0].firstChild.nodeValue = '[使用]';
|
||||||
if (document.querySelector('#pointsLevel'))
|
// if (document.querySelector('#pointsLevel'))
|
||||||
$('#pointsLevel')[0].firstChild.nodeValue = '[升级]';
|
// $('#pointsLevel')[0].firstChild.nodeValue = '[升级]';
|
||||||
|
//
|
||||||
// 手机 区域菜单
|
// // 手机 区域菜单
|
||||||
$('div[class*="areas-mobile"] span:nth-child(2)').contents().each((i, e) => {
|
// $('div[class*="areas-mobile"] span:nth-child(2)').contents().each((i, e) => {
|
||||||
//log(e);
|
// //log(e);
|
||||||
if (sidebarDict[e.nodeValue])
|
// if (sidebarDict[e.nodeValue])
|
||||||
e.nodeValue = sidebarDict[e.nodeValue];
|
// e.nodeValue = sidebarDict[e.nodeValue];
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
clearInterval(sidebarInterval);
|
// clearInterval(sidebarInterval);
|
||||||
}, 1000);
|
// }, 1000);
|
||||||
|
|
||||||
// header
|
// header
|
||||||
if (document.querySelector('div#header-root')) {
|
if (document.querySelector('div#header-root')) {
|
||||||
|
|||||||
5
src/ts/func/utils/Sleep.ts
Normal file
5
src/ts/func/utils/Sleep.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const Sleep = (ms: number = 0) => {
|
||||||
|
return new Promise(resolve => window.setTimeout(resolve, ms))
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Sleep
|
||||||
14
src/ts/func/utils/convert2Csv.ts
Normal file
14
src/ts/func/utils/convert2Csv.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
const convertToCSV = (data: any[]) => {
|
||||||
|
let csv = ''
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
let row = ''
|
||||||
|
for (const key in data[i]) {
|
||||||
|
row += `"${ data[i][key] }",`
|
||||||
|
}
|
||||||
|
row = row.slice(0, -1) // 删除最后一个逗号
|
||||||
|
csv += row + '\r\n' // 添加换行符
|
||||||
|
}
|
||||||
|
return csv
|
||||||
|
}
|
||||||
|
|
||||||
|
export { convertToCSV }
|
||||||
21
src/ts/func/utils/equipItem.ts
Normal file
21
src/ts/func/utils/equipItem.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const equipItem = (itemId: string, armoryId: string, type: number) => {
|
||||||
|
return fetch(window.addRFC("https://www.torn.com/item.php"), {
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
"referrer": "https://www.torn.com/item.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": `step=actionForm&item_id=${ itemId }&armour-from-set=&type=${ type }&action=equip&item=${ itemId }&id=${ armoryId }&confirm=1`,
|
||||||
|
"method": "POST",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default equipItem
|
||||||
28
src/ts/func/utils/fetchCurrentMoney.ts
Normal file
28
src/ts/func/utils/fetchCurrentMoney.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
const init: RequestInit = {
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
"referrer": "https://www.torn.com/companies.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": null,
|
||||||
|
"method": "GET",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchCurrentMoney = async (action?: string): Promise<number> => {
|
||||||
|
return Number(await (await fetch(window.addRFC("/inputMoneyAction.php?step=" + (action ? action : "generalAction")), init)).text());
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchCurrentCompanyAvailableMoney = () => {
|
||||||
|
return fetchCurrentMoney("companyAction");
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fetchCurrentPropVaultAvailableMoney = () => {
|
||||||
|
return fetchCurrentMoney("propertyDepositAction");
|
||||||
|
};
|
||||||
19
src/ts/func/utils/getSidebarData.ts
Normal file
19
src/ts/func/utils/getSidebarData.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { SessionStoreDataType } from "../../interface/SessionStoreDataType";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寻找 session storage 中以 sidebarData 开头的数据以对象返回
|
||||||
|
*/
|
||||||
|
export default function (): SessionStoreDataType {
|
||||||
|
let json: string = null
|
||||||
|
for (let i = 0; i < sessionStorage.length; i++) {
|
||||||
|
let key = sessionStorage.key(i)
|
||||||
|
if (key.startsWith('sidebarData')) {
|
||||||
|
json = sessionStorage.getItem(key)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!json) {
|
||||||
|
throw new TypeError('未找到 sidebarData')
|
||||||
|
}
|
||||||
|
return JSON.parse(json)
|
||||||
|
}
|
||||||
20
src/ts/func/utils/timePastFormat.ts
Normal file
20
src/ts/func/utils/timePastFormat.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
const timePastFormat = (ts: number): string => {
|
||||||
|
// 毫秒
|
||||||
|
if (ts < 1000) {
|
||||||
|
return ts + 'ms'
|
||||||
|
}
|
||||||
|
// 秒
|
||||||
|
else if (ts < 60000) {
|
||||||
|
return (ts / 1000 | 0) + 's'
|
||||||
|
}
|
||||||
|
// 分
|
||||||
|
else if (ts < 3600000) {
|
||||||
|
return (ts / 60000 | 0) + 'm'
|
||||||
|
}
|
||||||
|
// 时
|
||||||
|
else {
|
||||||
|
return (ts / 3600000 | 0) + 'h'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { timePastFormat }
|
||||||
51
src/ts/func/utils/useItem.ts
Normal file
51
src/ts/func/utils/useItem.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { ElMessage } from "element-plus"
|
||||||
|
|
||||||
|
type CrimeResVo = { text: string, success: boolean }
|
||||||
|
|
||||||
|
const defaultCb = (res: CrimeResVo) => {
|
||||||
|
ElMessage({
|
||||||
|
message: res.text,
|
||||||
|
type: res.success ? 'success' : 'error',
|
||||||
|
dangerouslyUseHTMLString: true,
|
||||||
|
grouping: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const useItem = (itemId: string, cb = defaultCb) => {
|
||||||
|
fetch(window.addRFC("https://www.torn.com/item.php"), {
|
||||||
|
"headers": {
|
||||||
|
"accept": "*/*",
|
||||||
|
"content-type": "application/x-www-form-urlencoded;charset=UTF-8",
|
||||||
|
"sec-ch-ua-mobile": "?0",
|
||||||
|
"sec-fetch-dest": "empty",
|
||||||
|
"sec-fetch-mode": "cors",
|
||||||
|
"sec-fetch-site": "same-origin",
|
||||||
|
"x-requested-with": "XMLHttpRequest"
|
||||||
|
},
|
||||||
|
"referrer": "https://www.torn.com/item.php",
|
||||||
|
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||||
|
"body": `step=useItem&id=${ itemId }&itemID=${ itemId }`,
|
||||||
|
"method": "POST",
|
||||||
|
"mode": "cors",
|
||||||
|
"credentials": "include"
|
||||||
|
})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(res => cb(res))
|
||||||
|
.catch(e => ElMessage({
|
||||||
|
message: e.toString,
|
||||||
|
type: 'error'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
const useItemSync = (itemId: string, showMsg = true, cb = (response: CrimeResVo) => null) => {
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
useItem(itemId, (_res) => {
|
||||||
|
if (showMsg) defaultCb(_res)
|
||||||
|
cb(_res)
|
||||||
|
res(null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useItem
|
||||||
|
export { useItemSync }
|
||||||
@ -1,22 +1,15 @@
|
|||||||
import Popup from "./class/utils/Popup";
|
import Popup from "./class/utils/Popup";
|
||||||
|
import { reactive } from 'vue'
|
||||||
|
import IFeatureResult from "./man/IFeatureResult";
|
||||||
|
|
||||||
// export default {
|
type ResponseHandlers = ((url: string, responseBody: {
|
||||||
// // 监听到的fetch数据
|
json: unknown,
|
||||||
// WH_NET_LOG: [],
|
text: string,
|
||||||
// map: {},
|
isModified: boolean
|
||||||
// responseHandlers: [],
|
}, opt: {
|
||||||
// version: '$$WUHU_DEV_VERSION$$',
|
method: string,
|
||||||
// } as IGlobVars;
|
requestBody: unknown
|
||||||
//
|
}) => void)[];
|
||||||
// interface IGlobVars {
|
|
||||||
// WH_NET_LOG: unknown[],
|
|
||||||
// map: { [key: string]: unknown },
|
|
||||||
// responseHandlers: ((url: string, responseBody: { json: unknown, text: string, isModified: boolean }, opt: { method: string, requestBody: unknown }) => void)[],
|
|
||||||
// version: string,
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
type ResponseHandlers = ((url: string, responseBody: { json: unknown, text: string, isModified: boolean }, opt: { method: string, requestBody: unknown }) => void)[];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用全局参数
|
* 通用全局参数
|
||||||
@ -28,6 +21,14 @@ class GlobVars {
|
|||||||
responseHandlers: ResponseHandlers = [];
|
responseHandlers: ResponseHandlers = [];
|
||||||
version = '$$WUHU_DEV_VERSION$$';
|
version = '$$WUHU_DEV_VERSION$$';
|
||||||
popup_node: MyHTMLElement | Popup = null;
|
popup_node: MyHTMLElement | Popup = null;
|
||||||
|
loadTime: number = 0;
|
||||||
|
buttons = reactive<FloatButtonData[]>([])
|
||||||
|
featureStatus = reactive<IFeatureResult[]>([])
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new GlobVars();
|
export default new GlobVars();
|
||||||
|
|
||||||
|
interface FloatButtonData {
|
||||||
|
txt: string,
|
||||||
|
func: (ev: Event) => void
|
||||||
|
}
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { Container } from "./container/Container";
|
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import Logger from "./class/Logger";
|
import EntryPoint from "./starter/EntryPoint";
|
||||||
import EntryPoint from "./class/provider/EntryPoint";
|
import { Injectable } from "./container/Injectable";
|
||||||
|
import ClassName from "./container/ClassName";
|
||||||
|
import { Container } from "./container/Container";
|
||||||
|
|
||||||
@EntryPoint
|
@EntryPoint
|
||||||
class _ {
|
@ClassName('Index')
|
||||||
static main() {
|
@Injectable()
|
||||||
Container.setLogger(new Logger());
|
class Index {
|
||||||
Container.factory(App).run();
|
public static main() {
|
||||||
|
Container.factory(App).run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import Device from "../enum/Device";
|
import Device from "../enum/Device";
|
||||||
import { BeerMonitorLoop } from "../class/action/BuyBeerHelper";
|
import { BeerMonitorLoop } from "../feature/BuyBeerHelper";
|
||||||
import Popup from "../class/utils/Popup";
|
import Popup from "../class/utils/Popup";
|
||||||
import TravelItem from "../class/action/TravelItem";
|
import TravelItem from "../feature/TravelItem";
|
||||||
|
|
||||||
export default interface IGlobal {
|
export default interface IGlobal {
|
||||||
GM_xmlhttpRequest?: Function;
|
GM_xmlhttpRequest?: Function;
|
||||||
|
|||||||
@ -38,7 +38,10 @@ export default interface IUserProfileData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
medalInformation: unknown;
|
medalInformation: unknown;
|
||||||
basicInformation: unknown;
|
basicInformation: {
|
||||||
|
icons: { id: number, title: string }[],
|
||||||
|
lastAction: { seconds: number }
|
||||||
|
};
|
||||||
personalInformation: unknown;
|
personalInformation: unknown;
|
||||||
competitionStatus: unknown;
|
competitionStatus: unknown;
|
||||||
staffTools: null;
|
staffTools: null;
|
||||||
|
|||||||
@ -7,4 +7,4 @@ export default interface IWHNotify {
|
|||||||
sysNotifyClick?: Function;
|
sysNotifyClick?: Function;
|
||||||
// 强制后台也通知
|
// 强制后台也通知
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,4 @@ export enum MENU_ITEM_TYPE {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// export
|
// export
|
||||||
export const menuItemList = Symbol() as InjectionKey<MenuItem[]>;
|
export const menuItemList = Symbol('menuItemList') as InjectionKey<MenuItem[]>;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user