更新
This commit is contained in:
parent
e623d6fd14
commit
4b51e156bb
12
build.mjs
12
build.mjs
@ -3,10 +3,8 @@
|
|||||||
* 并生成日期时间与版本号
|
* 并生成日期时间与版本号
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import rollupConfig from "./rollup-prod.config.js";
|
import { readFileSync, writeFileSync } from "fs";
|
||||||
import { readFileSync, rmSync, writeFileSync } from "fs";
|
import { prodConfig } from "./rollup.config.js";
|
||||||
|
|
||||||
let startTime = Date.now();
|
|
||||||
|
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
let version = process.env.npm_package_version;
|
let version = process.env.npm_package_version;
|
||||||
@ -32,11 +30,11 @@ let metaData =
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
`
|
`
|
||||||
|
|
||||||
const data = readFileSync('./' + rollupConfig.output.file, 'utf8');
|
const data = readFileSync('./' + prodConfig.output.file, 'utf8');
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
'./release.min.user.js',
|
'./release.min.user.js',
|
||||||
metaData + data.replace('$$WUHU_DEV_VERSION$$', version),
|
metaData + data.replace('$$WUHU_DEV_VERSION$$', version),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
rmSync('./' + rollupConfig.output.file);
|
// rmSync('./' + prodConfig.output.file);
|
||||||
console.log(`版本 ${ version } 构建完成, build.mjs耗时${ Date.now() - startTime }ms`);
|
console.log(`版本 ${ version } 构建完成`);
|
||||||
|
|||||||
6
css-module.d.ts
vendored
Normal file
6
css-module.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// declare module "*.module.css" {
|
||||||
|
// const css: string;
|
||||||
|
// const classes: { [key: string]: string };
|
||||||
|
// export default classes;
|
||||||
|
// export { css };
|
||||||
|
// }
|
||||||
21
custom-injector.js
Normal file
21
custom-injector.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export const customInjector = (varName) => {
|
||||||
|
let rt = ((__var) => {
|
||||||
|
const inject = (ob) => {
|
||||||
|
if (document && document.head) {
|
||||||
|
ob?.disconnect();
|
||||||
|
const style = document.createElement('style');
|
||||||
|
style.setAttribute('type', 'text/css');
|
||||||
|
style.innerHTML = __var;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (document && document.head) {
|
||||||
|
inject();
|
||||||
|
} else {
|
||||||
|
new MutationObserver((_, ob) => {
|
||||||
|
inject(ob);
|
||||||
|
}).observe(document.documentElement, { childList: true });
|
||||||
|
}
|
||||||
|
}).toString();
|
||||||
|
return `(${ rt })(${ varName })`;
|
||||||
|
};
|
||||||
23
global.d.ts
vendored
23
global.d.ts
vendored
@ -108,23 +108,16 @@ declare interface TornGetActionParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare module "*.html" {
|
declare module "*.html" {
|
||||||
const value: string;
|
const html: string;
|
||||||
export default value;
|
export default html;
|
||||||
}
|
}
|
||||||
|
declare module "*.module.css" {
|
||||||
declare module "*.css" {
|
const css: string;
|
||||||
const value: string;
|
// const classes: { [key: string]: string };
|
||||||
export default value;
|
// export default classes;
|
||||||
|
export default css;
|
||||||
|
// export { css };
|
||||||
}
|
}
|
||||||
// declare module '*.vue' {
|
|
||||||
// import type { DefineComponent } from 'vue'
|
|
||||||
// const component: DefineComponent<{}, {}, any>
|
|
||||||
//
|
|
||||||
// export interface HTMLAttributes {
|
|
||||||
// vModel?: any;
|
|
||||||
// }
|
|
||||||
// export default component
|
|
||||||
// }
|
|
||||||
|
|
||||||
declare function GM_xmlhttpRequest(init: any): void;
|
declare function GM_xmlhttpRequest(init: any): void;
|
||||||
|
|
||||||
|
|||||||
1769
package-lock.json
generated
1769
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "wuhu-torn-helper",
|
"name": "wuhu-torn-helper",
|
||||||
"version": "0.8.5",
|
"version": "0.8.6",
|
||||||
"description": "芜湖助手",
|
"description": "芜湖助手",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "cross-env NODE_ENV=production rollup -c rollup-prod.config.js && node build.mjs",
|
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs",
|
||||||
"watch": "cross-env NODE_ENV=development rollup -c -w",
|
"watch": "cross-env NODE_ENV=development rollup -c -w",
|
||||||
"rollup": "cross-env NODE_ENV=development rollup -c"
|
"rollup": "cross-env NODE_ENV=development rollup -c"
|
||||||
},
|
},
|
||||||
@ -19,11 +19,13 @@
|
|||||||
"@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",
|
||||||
|
"just-clone": "^6.2.0",
|
||||||
"npm": "^8.19.2",
|
"npm": "^8.19.2",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rollup": "^2.79.0",
|
"rollup": "^2.79.0",
|
||||||
"rollup-plugin-postcss": "^4.0.2",
|
"rollup-plugin-postcss": "^4.0.2",
|
||||||
"rollup-plugin-string-html": "^1.0.0",
|
"rollup-plugin-string-html": "^1.0.0",
|
||||||
|
"rollup-plugin-styles": "^4.0.0",
|
||||||
"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",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1,7 +0,0 @@
|
|||||||
import terser from "@rollup/plugin-terser";
|
|
||||||
import rollupConfig from "./rollup.config.js";
|
|
||||||
|
|
||||||
rollupConfig.plugins.push(terser());
|
|
||||||
rollupConfig.output.file = 'dist/bundle.min.js';
|
|
||||||
rollupConfig.output.name = 'bundle.min.js';
|
|
||||||
export default rollupConfig;
|
|
||||||
@ -10,14 +10,18 @@ import html from "rollup-plugin-string-html";
|
|||||||
import resolve from "@rollup/plugin-node-resolve";
|
import resolve from "@rollup/plugin-node-resolve";
|
||||||
import replace from "@rollup/plugin-replace";
|
import replace from "@rollup/plugin-replace";
|
||||||
import alias from "@rollup/plugin-alias";
|
import alias from "@rollup/plugin-alias";
|
||||||
import postcss from 'rollup-plugin-postcss';
|
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import styles from "rollup-plugin-styles";
|
||||||
|
import { customInjector } from "./custom-injector.js";
|
||||||
|
import terser from "@rollup/plugin-terser";
|
||||||
|
import clone from "just-clone";
|
||||||
|
|
||||||
let node_env = process.env.NODE_ENV;
|
let node_env = process.env.NODE_ENV;
|
||||||
let vuePath = node_env === 'production' ?
|
let vuePath = node_env === 'production' ?
|
||||||
'vue/dist/vue.runtime.esm-browser.prod.js' :
|
'vue/dist/vue.runtime.esm-browser.prod.js' :
|
||||||
'vue/dist/vue.runtime.esm-browser.js';
|
'vue/dist/vue.runtime.esm-browser.js';
|
||||||
export default {
|
|
||||||
|
const devConfig = {
|
||||||
input: 'src/ts/index.ts',
|
input: 'src/ts/index.ts',
|
||||||
output: {
|
output: {
|
||||||
file: 'dist/bundle.js',
|
file: 'dist/bundle.js',
|
||||||
@ -27,8 +31,6 @@ export default {
|
|||||||
plugins: [
|
plugins: [
|
||||||
json(),
|
json(),
|
||||||
html({
|
html({
|
||||||
// include: ["**/*.html", "src/static/css/*.css"],
|
|
||||||
// include: ["**/*.html", "**/*.css"],
|
|
||||||
include: ["**/*.html"],
|
include: ["**/*.html"],
|
||||||
minifier: {
|
minifier: {
|
||||||
includeAutoGeneratedTags: true,
|
includeAutoGeneratedTags: true,
|
||||||
@ -64,12 +66,38 @@ export default {
|
|||||||
preferBuiltins: false,
|
preferBuiltins: false,
|
||||||
}),
|
}),
|
||||||
vue({ isProduction: node_env === 'production' }),
|
vue({ isProduction: node_env === 'production' }),
|
||||||
typescript2({
|
// 自定义注入器注入vue部分css
|
||||||
tsconfig: "tsconfig.json",
|
styles({
|
||||||
// clean: true,
|
// modules: true,
|
||||||
// check: false,
|
// namedExports: true,
|
||||||
|
exclude: /static\/css\/.+\.css/,
|
||||||
|
mode: [
|
||||||
|
"inject",
|
||||||
|
(varName) => customInjector(varName),
|
||||||
|
],
|
||||||
|
minimize: true
|
||||||
|
}),
|
||||||
|
// 非vue部分css逻辑代码中手动注入
|
||||||
|
styles({
|
||||||
|
include: /static\/css\/.+\.css/,
|
||||||
|
// modules: true,
|
||||||
|
// namedExports: true,
|
||||||
|
mode: [
|
||||||
|
"inject",
|
||||||
|
() => ``,
|
||||||
|
],
|
||||||
|
minimize: true
|
||||||
|
}),
|
||||||
|
typescript2({
|
||||||
|
tsconfig: "./tsconfig.json",
|
||||||
}),
|
}),
|
||||||
postcss({ minimize: true }),
|
|
||||||
// typescript(),
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const prodConfig = clone(devConfig);
|
||||||
|
prodConfig.plugins.push(terser());
|
||||||
|
prodConfig.output.file = 'dist/bundle.min.js';
|
||||||
|
prodConfig.output.name = 'bundle.min.js';
|
||||||
|
|
||||||
|
export default [devConfig, prodConfig];
|
||||||
|
export { prodConfig };
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
<h4>手机</h4>
|
<h4>手机</h4>
|
||||||
<p>安卓 KIWI 等可以用油猴脚本的浏览器也可以点上面的链接安装👆</p>
|
<p>安卓 KIWI 等可以用油猴脚本的浏览器也可以点上面的链接安装👆</p>
|
||||||
<p>Torn PDA app 或 Alook 用户可打开<a href="//jjins.github.io/fyfuzhi/" target="_blank">这个网页</a>快捷复制粘贴。</p>
|
<p>Torn PDA app 或 Alook 用户可打开<a href="//jjins.github.io/fyfuzhi/" target="_blank">这个网页</a>快捷复制粘贴。</p>
|
||||||
|
<p>注:Torn PDA 中,Injection time 请选择 Start 达到最好效果。</p>
|
||||||
<h4>直接复制</h4>
|
<h4>直接复制</h4>
|
||||||
<p>加载脚本然后直接复制粘贴到用户脚本处。</p>
|
<p>加载脚本然后直接复制粘贴到用户脚本处。</p>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@ -13,8 +13,9 @@ import { Injectable } from "./container/Injectable";
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export default class App {
|
export default class App {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly tornHelper: WuHuTornHelper,
|
|
||||||
private readonly icon: ZhongIcon,
|
private readonly icon: ZhongIcon,
|
||||||
|
private readonly wuhuBase: WuhuBase,
|
||||||
|
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,
|
||||||
@ -22,9 +23,9 @@ export default class App {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public run(): void {
|
public run() {
|
||||||
|
|
||||||
WuhuBase.conditionInterrupt();
|
this.wuhuBase.conditionInterrupt();
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
this.tornHelper.init();
|
this.tornHelper.init();
|
||||||
|
|||||||
@ -16,19 +16,22 @@ export default class LocalConfigWrapper {
|
|||||||
|
|
||||||
public get config(): Config {
|
public get config(): Config {
|
||||||
const _this = this;
|
const _this = this;
|
||||||
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];
|
return target[prop] ?? defaultConfig[prop];
|
||||||
},
|
},
|
||||||
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 (preVal !== value) {
|
||||||
config[prop] = value;
|
config[prop] = value;
|
||||||
_this.setLocal(config);
|
_this.setLocal(config);
|
||||||
let msg = `[${ prop }]值变更 ${ preVal }->${ value }`;
|
let msg = `[${ prop }]值变更 ${ preVal }->${ value }`;
|
||||||
_this.logger.info(msg);
|
_this.logger.info(msg);
|
||||||
if (isNotified(prop))
|
if (isNotified(prop)) {
|
||||||
_this.msgWrapper.create(msg);
|
_this.msgWrapper.create(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -110,7 +110,7 @@ export default class UrlRouter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 监听啤酒购买
|
// 监听啤酒购买
|
||||||
globVars.responseHandlers.push(this.buyBeerHelper.responseHandler);
|
globVars.responseHandlers.push((...args: any[]) => this.buyBeerHelper.responseHandler.apply(this.buyBeerHelper, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快速crime TODO 重构、与翻译解藕
|
// 快速crime TODO 重构、与翻译解藕
|
||||||
|
|||||||
@ -1,24 +1,15 @@
|
|||||||
import IWHSettings from "../interface/IWHSettings";
|
import ClassName from "../container/ClassName";
|
||||||
import Log from "./Log";
|
import { Injectable } from "../container/Injectable";
|
||||||
|
|
||||||
|
|
||||||
|
@ClassName('WuhuBase')
|
||||||
|
@Injectable()
|
||||||
export default class WuhuBase {
|
export default class WuhuBase {
|
||||||
|
|
||||||
/**
|
constructor() {
|
||||||
* 获取 localStorage 中的 wh_trans_settings 值 (json),以对象形式返回
|
|
||||||
*/
|
|
||||||
public static getLocal(): IWHSettings {
|
|
||||||
let localObject;
|
|
||||||
let localItem = localStorage.getItem('wh_trans_settings') || '{}';
|
|
||||||
try {
|
|
||||||
localObject = JSON.parse(localItem);
|
|
||||||
} catch (e) {
|
|
||||||
Log.error('解析localStorage对象出错', e);
|
|
||||||
localStorage.setItem('wh_trans_settings', '{}');
|
|
||||||
}
|
|
||||||
return localObject || {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static conditionInterrupt() {
|
public conditionInterrupt() {
|
||||||
let title: HTMLElement | { innerText: string } = (document.querySelector('#skip-to-content') ||
|
let title: HTMLElement | { innerText: string } = (document.querySelector('#skip-to-content') ||
|
||||||
document.querySelector('[href*="#skip-to-content"]')) as HTMLElement || { innerText: '' };
|
document.querySelector('[href*="#skip-to-content"]')) as HTMLElement || { innerText: '' };
|
||||||
let condition = (
|
let condition = (
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import CommonUtils from "./utils/CommonUtils";
|
import CommonUtils from "./utils/CommonUtils";
|
||||||
import Global from "./Global";
|
import Global from "./Global";
|
||||||
import COMMON_CSS from "../../static/css/common.css";
|
import COMMON_CSS from "../../static/css/common.module.css";
|
||||||
import globVars from "../globVars";
|
import globVars from "../globVars";
|
||||||
import { Injectable } from "../container/Injectable";
|
import { Injectable } from "../container/Injectable";
|
||||||
import ClassName from "../container/ClassName";
|
import ClassName from "../container/ClassName";
|
||||||
@ -15,6 +15,7 @@ export default class WuHuTornHelper {
|
|||||||
private readonly global: Global,
|
private readonly global: Global,
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly infoUtils: InfoUtils,
|
private readonly infoUtils: InfoUtils,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +148,8 @@ export default class WuHuTornHelper {
|
|||||||
}
|
}
|
||||||
})(XMLHttpRequest.prototype);
|
})(XMLHttpRequest.prototype);
|
||||||
|
|
||||||
CommonUtils.addStyle(COMMON_CSS.replace('{{}}', performance.now().toString()));
|
let commonCssStr = COMMON_CSS.replace('{{}}', performance.now().toString());
|
||||||
|
this.commonUtils.styleInject(commonCssStr);
|
||||||
|
|
||||||
// 测试用
|
// 测试用
|
||||||
if ('Ok' !== localStorage['WHTEST']) {
|
if ('Ok' !== localStorage['WHTEST']) {
|
||||||
|
|||||||
@ -115,10 +115,9 @@ export default class ZhongIcon {
|
|||||||
// 更新按钮点击事件
|
// 更新按钮点击事件
|
||||||
(<MyHTMLElement>zhongNode.querySelector('#wh-update-btn')).onclick = e => {
|
(<MyHTMLElement>zhongNode.querySelector('#wh-update-btn')).onclick = e => {
|
||||||
(<HTMLButtonElement>e.target).blur();
|
(<HTMLButtonElement>e.target).blur();
|
||||||
const innerHtml = ZHONG_UPDATE_HTML;
|
|
||||||
// 直接复制的按钮
|
// 直接复制的按钮
|
||||||
new Popup(innerHtml, '如何更新')
|
new Popup(ZHONG_UPDATE_HTML, '如何更新')
|
||||||
.getElement()
|
.element
|
||||||
.querySelector('button').onclick = async (e) => {
|
.querySelector('button').onclick = async (e) => {
|
||||||
let target = e.target as HTMLButtonElement;
|
let target = e.target as HTMLButtonElement;
|
||||||
target.innerHTML = '加载中';
|
target.innerHTML = '加载中';
|
||||||
@ -170,7 +169,7 @@ export default class ZhongIcon {
|
|||||||
}
|
}
|
||||||
document.body.append(zhongNode);
|
document.body.append(zhongNode);
|
||||||
// 引入torn自带浮动提示
|
// 引入torn自带浮动提示
|
||||||
this.logger.info('引入torn自带浮动提示');
|
this.logger.info('引入torn浮动提示');
|
||||||
(window.initializeTooltip) && (window.initializeTooltip('.wh-container', 'white-tooltip'));
|
(window.initializeTooltip) && (window.initializeTooltip('.wh-container', 'white-tooltip'));
|
||||||
// 加载torn mini profile
|
// 加载torn mini profile
|
||||||
this.logger.info('加载torn mini profile');
|
this.logger.info('加载torn mini profile');
|
||||||
@ -185,7 +184,7 @@ export default class ZhongIcon {
|
|||||||
}, 1000),
|
}, 1000),
|
||||||
counter: 0
|
counter: 0
|
||||||
};
|
};
|
||||||
this.logger.info('图标加入文档树完成');
|
this.logger.info('图标加入文档树');
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ 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.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";
|
||||||
@ -186,7 +186,7 @@ export default class AttackHelper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommonUtils.addStyle(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;
|
||||||
@ -258,7 +258,7 @@ export default class AttackHelper {
|
|||||||
// .wh-move-btn #attacker div[class^="title___"]{height:0;}
|
// .wh-move-btn #attacker div[class^="title___"]{height:0;}
|
||||||
// .wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;}
|
// .wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;}
|
||||||
// `;
|
// `;
|
||||||
CommonUtils.addStyle(css_rule);
|
this.commonUtils.styleInject(css_rule);
|
||||||
document.body.classList.toggle('wh-move-btn');
|
document.body.classList.toggle('wh-move-btn');
|
||||||
btn.onclick = () => {
|
btn.onclick = () => {
|
||||||
if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
|
if (this.localConfigWrapper.config.quickFinishAtt !== 3) {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export default class ProfileHelper implements ResponseInject {
|
|||||||
this.localConfigWrapper.config.HideProfileImg = hideImgSwitch.getInput().checked;
|
this.localConfigWrapper.config.HideProfileImg = hideImgSwitch.getInput().checked;
|
||||||
});
|
});
|
||||||
if (this.localConfigWrapper.config.ShowNameHistory) {
|
if (this.localConfigWrapper.config.ShowNameHistory) {
|
||||||
globVars.responseHandlers.push((url, body) => this.responseHandler(url, body));
|
globVars.responseHandlers.push((...args: any[]) => this.responseHandler.apply(this, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -328,11 +328,10 @@ export default class TranslateNew extends Provider implements ResponseInject {
|
|||||||
'Glass of Beer': {
|
'Glass of Beer': {
|
||||||
itemName: '一杯啤酒',
|
itemName: '一杯啤酒',
|
||||||
itemInfo: '[译]Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you\'d get from a regular bottle of suds. Provides a moderate nerve increase when consumed.',
|
itemInfo: '[译]Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you\'d get from a regular bottle of suds. Provides a moderate nerve increase when consumed.',
|
||||||
itemInfoContent: "\n" +
|
itemInfoContent: "<div class='m-bottom10'>" +
|
||||||
" <div class='m-bottom10'>\n" +
|
"<span class=\"bold\">一杯啤酒</span> 是酒类物品" +
|
||||||
" <span class=\"bold\">一杯啤酒</span> 是酒类物品\n" +
|
"</div>" +
|
||||||
" </div>\n" +
|
"Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you'd get from a regular bottle of suds. Provides a moderate nerve increase when consumed." +
|
||||||
" Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you'd get from a regular bottle of suds. Provides a moderate nerve increase when consumed.\n" +
|
|
||||||
"<div class=\"t-green bold item-effect m-top10\">效果: 犯罪 + 2,增幅CD + 1h。</div>",
|
"<div class=\"t-green bold item-effect m-top10\">效果: 犯罪 + 2,增幅CD + 1h。</div>",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import XUNZHAOMUZHUANG_HTML from "../../../static/html/xunzhaomuzhuang/index.html";
|
import XUNZHAOMUZHUANG_HTML from "../../../static/html/xunzhaomuzhuang/index.html";
|
||||||
import * as MUZHUANG_ID_LIST_JSON from "../../../static/json/muzhuang_id_list.json";
|
import * as MUZHUANG_ID_LIST_JSON from "../../../static/json/muzhuang_id_list.json";
|
||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import XUNZHAOMUZHUANG_CSS from "../../../static/css/xunzhaomuzhuang.css";
|
import XUNZHAOMUZHUANG_CSS from "../../../static/css/xunzhaomuzhuang.module.css";
|
||||||
import TornStyleBlock from "../utils/TornStyleBlock";
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
||||||
import MathUtils from "../utils/MathUtils";
|
import MathUtils from "../utils/MathUtils";
|
||||||
import FetchUtils from "../utils/FetchUtils";
|
import FetchUtils from "../utils/FetchUtils";
|
||||||
@ -32,7 +32,7 @@ export default class XZMZ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
CommonUtils.addStyle(XUNZHAOMUZHUANG_CSS);
|
this.commonUtils.styleInject(XUNZHAOMUZHUANG_CSS);
|
||||||
document.body.classList.add('wh-hide-title');
|
document.body.classList.add('wh-hide-title');
|
||||||
document.title = document.title.replace('Items', '寻找木桩');
|
document.title = document.title.replace('Items', '寻找木桩');
|
||||||
this.mainRoleContainer = document.querySelector('div[role="main"]');
|
this.mainRoleContainer = document.querySelector('div[role="main"]');
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import QUICK_FLY_CSS from "../../../static/css/quick_fly.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 "../action/TravelItem";
|
||||||
@ -15,6 +15,7 @@ export default class QuickFlyBtnHandler {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly logger: Logger,
|
private readonly logger: Logger,
|
||||||
private readonly travelItem: TravelItem,
|
private readonly travelItem: TravelItem,
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ export default class QuickFlyBtnHandler {
|
|||||||
if (window.hasWHQuickFlyOpt) return;
|
if (window.hasWHQuickFlyOpt) return;
|
||||||
window.hasWHQuickFlyOpt = true;
|
window.hasWHQuickFlyOpt = true;
|
||||||
// TODO
|
// TODO
|
||||||
CommonUtils.addStyle(QUICK_FLY_CSS);
|
this.commonUtils.styleInject(QUICK_FLY_CSS);
|
||||||
const node = document.createElement('div');
|
const node = document.createElement('div');
|
||||||
node.id = 'wh-quick-fly-opt';
|
node.id = 'wh-quick-fly-opt';
|
||||||
node.innerHTML = QUICK_FLY_HTML;
|
node.innerHTML = QUICK_FLY_HTML;
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
import CommonUtils from "../utils/CommonUtils";
|
import CommonUtils from "../utils/CommonUtils";
|
||||||
import QUICK_LINK_CSS from "../../../static/css/quick_link.css";
|
import QUICK_LINK_CSS from "../../../static/css/quick_link.module.css";
|
||||||
import Popup from "../utils/Popup";
|
import Popup from "../utils/Popup";
|
||||||
|
import ClassName from "../../container/ClassName";
|
||||||
|
import { Injectable } from "../../container/Injectable";
|
||||||
|
|
||||||
|
@ClassName('QuickLinksHandler')
|
||||||
|
@Injectable()
|
||||||
export default class QuickLinksHandler {
|
export default class QuickLinksHandler {
|
||||||
|
|
||||||
private styleAdded: boolean = false;
|
private styleAdded: boolean = false;
|
||||||
private list = [];
|
private list = [];
|
||||||
|
|
||||||
constructor() {
|
constructor(
|
||||||
|
private readonly commonUtils: CommonUtils,
|
||||||
|
) {
|
||||||
let list = this.list;
|
let list = this.list;
|
||||||
// 生存手册
|
// 生存手册
|
||||||
list.push({
|
list.push({
|
||||||
@ -69,7 +75,7 @@ export default class QuickLinksHandler {
|
|||||||
|
|
||||||
public handle(): void {
|
public handle(): void {
|
||||||
if (!this.styleAdded) {
|
if (!this.styleAdded) {
|
||||||
CommonUtils.addStyle(QUICK_LINK_CSS);
|
this.commonUtils.styleInject(QUICK_LINK_CSS);
|
||||||
this.styleAdded = true;
|
this.styleAdded = true;
|
||||||
}
|
}
|
||||||
const list = this.list;
|
const list = this.list;
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
import Log from "../Log";
|
import Log from "../Log";
|
||||||
import ZhongIcon from "../ZhongIcon";
|
import ZhongIcon from "../ZhongIcon";
|
||||||
|
|
||||||
export default function EntryPoint(T: { main: () => void }) {
|
export default function EntryPoint(T: { main: () => void }) {
|
||||||
if (window.WHTRANS) throw '退出, 已运行次数' + window.WHTRANS;
|
if (window.WHTRANS) {
|
||||||
|
console.log('退出, 已运行次数' + window.WHTRANS)
|
||||||
|
} else {
|
||||||
window.WHTRANS = window.WHTRANS === undefined ? 1 : window.WHTRANS++;
|
window.WHTRANS = window.WHTRANS === undefined ? 1 : window.WHTRANS++;
|
||||||
|
|
||||||
|
let started = false;
|
||||||
|
const starter = () => {
|
||||||
|
console.log('starter init...');
|
||||||
let started = performance.now();
|
let started = performance.now();
|
||||||
try {
|
try {
|
||||||
T.main();
|
T.main();
|
||||||
@ -15,4 +21,17 @@ export default function EntryPoint(T: { main: () => void }) {
|
|||||||
Log.info(`芜湖脚本完成加载, 耗时${ runTime }ms`);
|
Log.info(`芜湖脚本完成加载, 耗时${ runTime }ms`);
|
||||||
if (ZhongIcon.ZhongNode && ZhongIcon.ZhongNode.initTimer)
|
if (ZhongIcon.ZhongNode && ZhongIcon.ZhongNode.initTimer)
|
||||||
ZhongIcon.ZhongNode.initTimer.innerHTML = `加载时间 ${ runTime }ms`;
|
ZhongIcon.ZhongNode.initTimer.innerHTML = `加载时间 ${ runTime }ms`;
|
||||||
|
};
|
||||||
|
const evHandler = () => {
|
||||||
|
console.log('document.readyState: ' + document.readyState);
|
||||||
|
if (!started && (document.readyState === 'complete' || document.readyState === 'interactive')) {
|
||||||
|
document.removeEventListener('readystatechange', evHandler);
|
||||||
|
started = !started;
|
||||||
|
starter();
|
||||||
|
} else if (!(document.readyState === 'complete' || document.readyState === 'interactive')) {
|
||||||
|
document.addEventListener('readystatechange', evHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
evHandler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -223,6 +223,13 @@ export default class CommonUtils {
|
|||||||
Log.info('CSS规则已添加', element);
|
Log.info('CSS规则已添加', element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public styleInject(rules: string): void {
|
||||||
|
const element = document.createElement("style");
|
||||||
|
element.setAttribute('type', 'text/css');
|
||||||
|
element.innerHTML = rules;
|
||||||
|
document.head.appendChild(element);
|
||||||
|
}
|
||||||
|
|
||||||
public static loading_gif_html(): string {
|
public static loading_gif_html(): string {
|
||||||
return LOADING_IMG_HTML;
|
return LOADING_IMG_HTML;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,11 +23,10 @@ export default class ItemHelper {
|
|||||||
'Glass of Beer': {
|
'Glass of Beer': {
|
||||||
itemName: '一杯啤酒',
|
itemName: '一杯啤酒',
|
||||||
itemInfo: '[译]Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you\'d get from a regular bottle of suds. Provides a moderate nerve increase when consumed.',
|
itemInfo: '[译]Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you\'d get from a regular bottle of suds. Provides a moderate nerve increase when consumed.',
|
||||||
itemInfoContent: "\n" +
|
itemInfoContent: "<div class='m-bottom10'>" +
|
||||||
" <div class='m-bottom10'>\n" +
|
"<span class=\"bold\">一杯啤酒</span> 是酒类物品" +
|
||||||
" <span class=\"bold\">一杯啤酒</span> 是酒类物品\n" +
|
"</div>" +
|
||||||
" </div>\n" +
|
"Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you'd get from a regular bottle of suds. Provides a moderate nerve increase when consumed." +
|
||||||
" Only savages drink beer straight out of the bottle. This glass of beer is obtained fresh from the keg, and provides the same level of drunken joy as you'd get from a regular bottle of suds. Provides a moderate nerve increase when consumed.\n" +
|
|
||||||
"<div class=\"t-green bold item-effect m-top10\">效果: 犯罪 + 2,增幅CD + 1h。</div>",
|
"<div class=\"t-green bold item-effect m-top10\">效果: 犯罪 + 2,增幅CD + 1h。</div>",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import toThousands from "../utils/toThousands";
|
import toThousands from "../utils/toThousands";
|
||||||
import CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import CITY_FINDER_CSS from "../../../static/css/city_finder.css";
|
import CITY_FINDER_CSS from "../../../static/css/city_finder.module.css";
|
||||||
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
import TornStyleBlock from "../../class/utils/TornStyleBlock";
|
||||||
import ItemHelper from "../../class/utils/ItemHelper";
|
import ItemHelper from "../../class/utils/ItemHelper";
|
||||||
import { Container } from "../../container/Container";
|
import { Container } from "../../container/Container";
|
||||||
@ -10,7 +10,7 @@ import { Container } from "../../container/Container";
|
|||||||
* @param _base
|
* @param _base
|
||||||
*/
|
*/
|
||||||
export default function cityFinder(_base: TornStyleBlock): void {
|
export default function cityFinder(_base: TornStyleBlock): void {
|
||||||
CommonUtils.addStyle(CITY_FINDER_CSS);
|
Container.factory(CommonUtils).styleInject(CITY_FINDER_CSS);
|
||||||
// 物品名与价格
|
// 物品名与价格
|
||||||
let items: {
|
let items: {
|
||||||
[k: number]: {
|
[k: number]: {
|
||||||
@ -18,43 +18,29 @@ export default function cityFinder(_base: TornStyleBlock): void {
|
|||||||
price: number
|
price: number
|
||||||
}
|
}
|
||||||
} = null;
|
} = null;
|
||||||
// const base = document.createElement('div');
|
|
||||||
// base.id = 'wh-city-finder';
|
|
||||||
// const container = document.createElement('div');
|
|
||||||
// container.id = 'wh-city-finder-cont';
|
|
||||||
const header = document.createElement('div');
|
const header = document.createElement('div');
|
||||||
// header.id = 'wh-city-finder-header';
|
|
||||||
header.innerHTML = '捡垃圾助手';
|
header.innerHTML = '捡垃圾助手';
|
||||||
const info = document.createElement('div');
|
const info = document.createElement('div');
|
||||||
info.innerHTML = '已找到物品:';
|
info.innerHTML = '已找到物品:';
|
||||||
// container.append(info);
|
|
||||||
// base.append(header);
|
|
||||||
// base.append(container);
|
|
||||||
|
|
||||||
_base.append(header, info);
|
_base.append(header, info);
|
||||||
document.body.classList.add('wh-city-finds');
|
document.body.classList.add('wh-city-finds');
|
||||||
|
|
||||||
// CommonUtils.COFetch('https://jjins.github.io/item_price_raw.json')
|
|
||||||
// .then(r => items = JSON.parse(r))
|
|
||||||
// .catch(err => {
|
|
||||||
// Log.error(err);
|
|
||||||
// items = undefined
|
|
||||||
// });
|
|
||||||
let itemHelper = Container.factory(ItemHelper);
|
let itemHelper = Container.factory(ItemHelper);
|
||||||
CommonUtils.elementReady('div.leaflet-marker-pane').then(elem => {
|
CommonUtils.elementReady('div.leaflet-marker-pane').then(elem => {
|
||||||
// document.querySelector('.content-wrapper').prepend(base);
|
|
||||||
|
|
||||||
// 发现的物品id与map img node
|
// 发现的物品id与map img node
|
||||||
const founds = [];
|
const founds = [];
|
||||||
elem.querySelectorAll('img.map-user-item-icon').forEach(node => {
|
elem.querySelectorAll('img.map-user-item-icon').forEach(node => {
|
||||||
const item_id = node.src.split('/')[5];
|
const item_id = node.src.split('/')[5];
|
||||||
const finder_item = document.createElement('span');
|
const finder_item = document.createElement('span');
|
||||||
// finder_item.id = 'wh-city-finder-item' + item_id;
|
|
||||||
finder_item.classList.add('wh-city-finder-item');
|
finder_item.classList.add('wh-city-finder-item');
|
||||||
finder_item.innerHTML = item_id;
|
finder_item.innerHTML = item_id;
|
||||||
founds.push({ 'id': item_id, 'node': finder_item, 'map_item': node });
|
founds.push({ 'id': item_id, 'node': finder_item, 'map_item': node });
|
||||||
// container.append(finder_item);
|
|
||||||
// _base.append(finder_item);
|
|
||||||
info.append(finder_item);
|
info.append(finder_item);
|
||||||
});
|
});
|
||||||
// 未发现物品 返回
|
// 未发现物品 返回
|
||||||
|
|||||||
@ -3,7 +3,7 @@ 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";
|
||||||
import DEPO_CSS from "../../../static/css/depo.css";
|
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";
|
||||||
@ -13,6 +13,7 @@ const fetchUtils = Container.factory(FetchUtils);
|
|||||||
export default function depoHelper() {
|
export default function depoHelper() {
|
||||||
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 href = window.location.href;
|
let href = window.location.href;
|
||||||
let channel: 'CMPY' | 'FAC';
|
let channel: 'CMPY' | 'FAC';
|
||||||
const selector = { 'CMPY': "div#funds div.deposit", 'FAC': "div#armoury-donate div.cash" };
|
const selector = { 'CMPY': "div#funds div.deposit", 'FAC': "div#armoury-donate div.cash" };
|
||||||
@ -53,7 +54,7 @@ export default function depoHelper() {
|
|||||||
// 存钱框浮动
|
// 存钱框浮动
|
||||||
if (localConfigWrapper.config.floatDepo && channel) {
|
if (localConfigWrapper.config.floatDepo && channel) {
|
||||||
document.body.classList.add('wh-depo-helper');
|
document.body.classList.add('wh-depo-helper');
|
||||||
CommonUtils.addStyle(DEPO_CSS);
|
commonUtils.styleInject(DEPO_CSS);
|
||||||
CommonUtils.elementReady(selector[channel]).then(node => {
|
CommonUtils.elementReady(selector[channel]).then(node => {
|
||||||
const close_btn = document.createElement('button');
|
const close_btn = document.createElement('button');
|
||||||
close_btn.addEventListener('click', () => {
|
close_btn.addEventListener('click', () => {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import Device from "../../enum/Device";
|
|||||||
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 CommonUtils from "../../class/utils/CommonUtils";
|
import CommonUtils from "../../class/utils/CommonUtils";
|
||||||
import TRAVEL_ALARM_CSS from "../../../static/css/travel_alarm.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";
|
||||||
@ -111,7 +111,7 @@ export default class TravelHelper {
|
|||||||
.replace('{{}}', dest_cn === '回城' ? dest_cn : '飞往' + dest_cn)
|
.replace('{{}}', dest_cn === '回城' ? dest_cn : '飞往' + dest_cn)
|
||||||
.replace('{{}}', wh_trv_alarm.enable ? 'checked ' : '')
|
.replace('{{}}', wh_trv_alarm.enable ? 'checked ' : '')
|
||||||
.replace('{{}}', wh_trv_alarm.alert_time || 30);
|
.replace('{{}}', wh_trv_alarm.alert_time || 30);
|
||||||
CommonUtils.addStyle(TRAVEL_ALARM_CSS);
|
this.commonUtils.styleInject(TRAVEL_ALARM_CSS);
|
||||||
document.body.append(wh_trv_alarm_node);
|
document.body.append(wh_trv_alarm_node);
|
||||||
// 报错dom
|
// 报错dom
|
||||||
const error_node = wh_trv_alarm_node.querySelector('#wh-trv-error') as HTMLElement;
|
const error_node = wh_trv_alarm_node.querySelector('#wh-trv-error') as HTMLElement;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
import { Container } from "./container/Container";
|
import { Container } from "./container/Container";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import Logger from "./class/Logger";
|
import Logger from "./class/Logger";
|
||||||
import EntryPoint from "./class/provider/EntryPoint";
|
import EntryPoint from "./class/provider/EntryPoint";
|
||||||
import "reflect-metadata";
|
|
||||||
|
|
||||||
@EntryPoint
|
@EntryPoint
|
||||||
class _ {
|
class _ {
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
<!--<script setup lang="ts">-->
|
|
||||||
<!--import { itemNameDict } from "../ts/dictionary/translation";-->
|
|
||||||
<!--</script>-->
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user