This commit is contained in:
Liwanyi 2022-09-07 18:04:07 +08:00
parent 482c50a237
commit e854c4351d
12 changed files with 559 additions and 338 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

15
.idea/codeStyles/Project.xml generated Normal file
View File

@ -0,0 +1,15 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JSCodeStyleSettings version="0">
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
<option name="SPACES_WITHIN_IMPORTS" value="true" />
<option name="SPACES_WITHIN_INTERPOLATION_EXPRESSIONS" value="true" />
</JSCodeStyleSettings>
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

View File

@ -0,0 +1,66 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AliAccessStaticViaInstance" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AliDeprecation" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AliEqualsAvoidNull" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AliMissingOverrideAnnotation" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AliWrapperTypeEquality" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaAbstractClassShouldStartWithAbstractNaming" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidApacheBeanUtilsCopy" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidCallStaticSimpleDateFormat" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidCommentBehindStatement" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidComplexCondition" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidConcurrentCompetitionRandom" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidDoubleOrFloatEqualCompare" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidManuallyCreateThread" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidMissUseOfMathRandom" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidNegationOperator" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidNewDateGetTime" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidPatternCompileInMethod" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidReturnInFinally" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidStartWithDollarAndUnderLineNaming" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaAvoidUseTimer" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaBigDecimalAvoidDoubleConstructor" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaBooleanPropertyShouldNotStartWithIs" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaClassCastExceptionWithSubListToArrayList" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaClassCastExceptionWithToArray" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaClassMustHaveAuthor" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaClassNamingShouldBeCamel" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaCollectionInitShouldAssignCapacity" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaCommentsMustBeJavadocFormat" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaConcurrentExceptionWithModifyOriginSubList" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaConstantFieldShouldBeUpperCase" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaCountDownShouldInFinally" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaDontModifyInForeachCircle" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaEnumConstantsMustHaveComment" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaExceptionClassShouldEndWithException" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaIbatisMethodQueryForList" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaLockShouldWithTryFinally" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaLowerCamelCaseVariableNaming" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaMethodReturnWrapperType" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaMethodTooLong" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaPackageNaming" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaPojoMustOverrideToString" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaPojoMustUsePrimitiveField" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaPojoNoDefaultValue" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaRemoveCommentedCode" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaServiceOrDaoClassShouldEndWithImpl" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaStringConcat" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaSwitchStatement" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaTestClassShouldEndWithTestNaming" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaThreadLocalShouldRemove" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaThreadPoolCreation" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="AlibabaThreadShouldSetName" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaTransactionMustHaveRollback" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaUndefineMagicConstant" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaUnsupportedExceptionWithModifyAsList" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="AlibabaUseQuietReferenceNotation" enabled="false" level="MAJOR" enabled_by_default="false" />
<inspection_tool class="AlibabaUseRightCaseForDateFormat" enabled="false" level="CRITICAL" enabled_by_default="false" />
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="false" level="CRITICAL" enabled_by_default="false" />
</profile>
</component>

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{Node.js Core}" />
</component>
</project>

6
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="Python 3.8 (fstock)" project-jdk-type="Python SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/torncity-zhcn-translate.iml" filepath="$PROJECT_DIR$/.idea/torncity-zhcn-translate.iml" />
</modules>
</component>
</project>

6
.idea/smartfox_info.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SmartFoxProjectConfig">
<option name="projectInspectionClosed" value="true" />
</component>
</project>

9
.idea/torncity-zhcn-translate.iml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "wuhu-torn-helper",
"version": "0.4.6",
"version": "0.4.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,8 +1,11 @@
!async function () {
async function main() {
'use strict';
const start_timestamp = Date.now();
if (document.title.toLowerCase().includes('just a moment')) return;
const UWCopy = window.unsafeWindow;
let UWCopy;
if (window.hasOwnProperty('unsafeWindow')) {
UWCopy = window.unsafeWindow;
}
try {
window = UWCopy || window;
} catch {
@ -18,7 +21,7 @@
const isPDA = PDA_APIKey.slice(-1) !== '#';
log.error = (...o) => (isDev()) && (console.error('[WH]', ...o));
log.warm = (...o) => (isDev()) && (console.warm('[WH]', ...o));
log.info = (...o) => (isDev()) && (console.info('[WH]', ...o));
// 通知权限
if (window.Notification) {
@ -3976,8 +3979,32 @@ background-size: 100% auto !important;
});
// 更新历史
menu_list.push({
domType: 'button', domId: '', domText: '🐞 更新历史', clickFunc: () => {
popupMsg('更新历史现已迁移:<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>', '更新历史');
domType: 'button', domId: '', domText: '🐞 更新历史', clickFunc: async () => {
let popup = popupMsg(
'更新历史:<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/>',
'更新历史'
);
let progressBar = document.createElement('div');
progressBar.style.height = '2px';
progressBar.style.width = '1%';
progressBar.style.backgroundColor = 'red';
let progressText = document.createElement('p');
progressText.innerText = '加载更新文件……';
progressText.style.textAlign = 'center';
popup.append(progressBar, progressText);
let update = await COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md?' + Date.now());
progressBar.style.width = '60%';
progressText.innerText = '解析中……';
let md = mdParse(update);
popup.append(md);
progressBar.style.width = '100%';
progressText.innerText = '加载完成';
setTimeout(() => {
progressBar.remove();
progressText.remove()
}, 3000);
},
});
// 助手设置
@ -4028,8 +4055,9 @@ color:black;
domType: 'button',
domId: '',
domText: '📐️ 测试',
clickFunc: function () {
WHNotify('芜湖助手', {sysNotify: true, timeout: 15})
clickFunc: async function () {
let res = await COFetch('https://gitlab.com/JJins/wuhu-torn-helper/-/raw/dev/CHANGELOG.md')
log(mdParse(res))
},
});
// endregion
@ -4242,12 +4270,10 @@ cursor:pointer;
// 清除多余的脚本
if (getWhSettingObj()['removeScripts']) {
let goog = document.querySelector('script[src*="google"]');
(goog) && (goog.remove());
let goog2 = document.querySelector('#gtm_tag');
(goog2) && (goog2.remove());
let gonline = document.querySelector('script[src*="chat/gonline"]');
(gonline) && (gonline.remove());
document.querySelectorAll('script[src*="google"]').forEach(item => item.remove());
document.querySelectorAll('#gtm_tag').forEach(item => item.remove());
document.querySelectorAll('script[src*="chat/gonline"]').forEach(item => item.remove());
document.querySelectorAll('head script[nonce]').forEach(item => item.remove());
}
// region 存钱 不终止
@ -10535,22 +10561,28 @@ z-index:100001;
let sessionKeys = Object.keys(sessionStorage);
if (sessionKeys.length < 2) {
// dom获取
const sidebar_menu_list = document.querySelectorAll('#sidebar a span[class*="linkName___"]');
sidebar_menu_list.forEach(node => ret[node.innerHTML.trim().toLowerCase()] = true);
sidebar_menu_list.forEach(node => ret[node.innerHTML.trim().toLowerCase().replaceAll(' ', '_')] = true);
} else {
for (let key in sessionKeys) {
if (key.startsWith('sidebarData') && key.length < 20) {
// session storage获取
for (let key of sessionKeys) {
if (key.startsWith('sidebarData')) {
sidebar_id = JSON.parse(sessionStorage.getItem(key));
break;
}
}
if (sidebar_id !== null) {
for (let area in Object.keys(sidebar_id['areas'])) {
// Object.keys(sidebar_id['areas']).forEach(area => ret[area] = true);
for (let area of Object.keys(sidebar_id['areas'])) {
ret[area] = true;
}
}
}
if (Object.keys(ret).length === 0) WHNotify('无法获取数据,建议刷新重试');
log({ ret, sidebar_id, sessionKeys })
if (Object.keys(ret).length === 0) {
WHNotify('无法获取数据,建议刷新重试');
}
return ret;
}
@ -10620,5 +10652,59 @@ z-index:100001;
return fetch(url, req_params);
}
/**
* 解析 Markdown 内容
* @param {String} from
* @returns {HTMLDivElement}
*/
function mdParse(from) {
const base = document.createElement('div');
let lines = from.split('\n');
let prev = '';
let child_cont;
lines.forEach(line => {
if (line.trim() === '') return;
let node;
let spl = line.split(' ');
let md_flag = spl[0];
switch (md_flag) {
// 标题
case '#':
case '##':
case '###':
if (prev === 'li') {
child_cont = null;
}
prev = 'h' + (md_flag.length + 1);
node = document.createElement(prev);
node.innerText = line.slice(md_flag.length + 1);
base.append(node);
return;
// 列表
case '-':
if (prev !== 'li') {
child_cont = document.createElement('ul');
if (!base.contains(child_cont)) base.append(child_cont);
}
prev = 'li';
node = document.createElement(prev);
node.innerText = line.slice(2);
child_cont.append(node);
return;
}
prev = 'p';
node = document.createElement(prev);
node.innerText = line.trim();
base.append(node);
})
return base;
}
$zhongNode.initTimer.innerHTML = `助手加载时间 ${ Date.now() - start_timestamp }ms`;
}
!function () {
main().then()
}();