diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6696150..b7da6f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,14 @@
# CHANGE
+## 0.8.5
+
+2023年04月03日
+
+### 修改
+
+- 结构调整
+
## 0.8.4
2023年03月03日
diff --git a/README.md b/README.md
index 38eb2ce..a27d607 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
# 芜湖助手 Torncity 翻译插件
+
+[CHANGELOG](CHANGELOG.md)
diff --git a/package-lock.json b/package-lock.json
index 7cbd7f4..6cfd7f3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "wuhu-torn-helper",
- "version": "0.8.4",
+ "version": "0.8.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "wuhu-torn-helper",
- "version": "0.8.4",
+ "version": "0.8.5",
"devDependencies": {
"@rollup/plugin-alias": "^4.0.3",
"@rollup/plugin-json": "^4.1.0",
diff --git a/package.json b/package.json
index d166b14..51286cc 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "wuhu-torn-helper",
- "version": "0.8.4",
+ "version": "0.8.5",
"description": "芜湖助手",
"scripts": {
"release": "cross-env NODE_ENV=production rollup -c rollup-prod.config.js && node build.mjs",
@@ -28,5 +28,6 @@
"tslib": "^2.4.0",
"typescript": "^4.8.3",
"vue": "^3.2.47"
- }
+ },
+ "type": "module"
}
diff --git a/release.min.user.js b/release.min.user.js
index b8b3706..a56322c 100644
--- a/release.min.user.js
+++ b/release.min.user.js
@@ -1,8 +1,8 @@
// ==UserScript==
-// @lastmodified 202303031726
+// @lastmodified 202304031757
// @name 芜湖助手
// @namespace WOOH
-// @version 0.8.4
+// @version 0.8.5
// @description 托恩,起飞!
// @author Woohoo[2687093] Sabrina_Devil[2696209]
// @match https://www.torn.com/*
@@ -16,4 +16,18 @@
// @connect staticfile.org
// @connect gitee.com
// ==/UserScript==
-this.bundle=this.bundle||{},this.bundle.min=this.bundle.min||{},this.bundle.min.js=function(){"use strict";function e(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))}class t{static info(...e){t.counter.info++;let n="%c WH %cIFO%c"+this.getTime()+"%c";this.debug()&&console.log(n,"background:grey;color:white;","","color:grey;","",...e),this.saveLogs(n,...e)}static error(...e){t.counter.error++;let n="%c WH %cERR%c"+this.getTime()+"%c";console.error(n,"background:grey;color:white;","background:red;color:white;","color:grey;","",...e),this.saveLogs(n,...e)}static warn(...e){t.counter.warning++;let n="%c WH %cWRN%c"+this.getTime()+"%c";console.warn(n,"background:grey;color:white;","background:#ff9800;color:white;","color:grey;","",...e),this.saveLogs(n,...e)}static debug(){let e=!0;try{let t=JSON.parse(localStorage.getItem("wh_trans_settings"));t&&(e=t.isDev)}catch(e){}return e}static getTime(){let e=new Date;return`${e.getFullYear()}-${("0"+(e.getMonth()+1)).slice(-2)}-${("0"+e.getDate()).slice(-2)} ${("0"+e.getHours()).slice(-2)}:${("0"+e.getMinutes()).slice(-2)}:${("0"+e.getSeconds()).slice(-2)}.${("00"+e.getMilliseconds()).slice(-3)}`}static getLogs(){return this.logs}static saveLogs(...e){e.forEach((e=>{if("string"==typeof e)this.logs+=e.replaceAll("%c","");else if(null!=e){let t="{}",n=Object.getPrototypeOf(e).constructor.name;try{t=JSON.stringify(e)}catch(e){}this.logs+=` [${n}] [${t}] `,e.message&&(this.logs+="错误信息: "+e.message),e.stack&&(this.logs+="错误堆栈: "+e.stack)}})),this.logs+="\r\n"}static getCounter(){return{info:t.counter.info,error:t.counter.error,warning:t.counter.warning}}}t.logs="",t.counter={info:0,error:0,warning:0};class n{constructor(){this.startTime=performance.now()}getTimeMs(){return(performance.now()-this.startTime|0)+"ms"}}class i{constructor(...e){this.className="Provider"}static getInstance(...e){if(!this.instance){let o=new n;this.instance=new this(...e);let a=this.instance.getClassName()||this.name;t.info("实例已创建,",a,this.instance,"耗时"+o.getTimeMs()),i.pool[a]=this.instance}return this.instance}static getPool(){return{pool:i.pool}}getClassName(){return this.className}}i.pool={};class o extends i{constructor(){super(...arguments),this.className="WuhuBase"}static getLocal(){let e,n=localStorage.getItem("wh_trans_settings")||"{}";try{e=JSON.parse(n)}catch(e){t.error("解析localStorage对象出错",e),localStorage.setItem("wh_trans_settings","{}")}return e||{}}static conditionInterrupt(){let e=document.querySelector("#skip-to-content")||document.querySelector('[href*="#skip-to-content"]')||{innerText:""};if(document.title.toLowerCase().includes("just a moment")||e.innerText.toLowerCase().includes("please validate")||null!==document.querySelector("div.container div.cf .iAmUnderAttack"))throw"芜湖"}}var a;o.glob=null,function(e){e.RAW="raw",e.GM="gm",e.PDA="pda"}(a||(a={}));var s,r=a;!function(e){e.PC="pc",e.MOBILE="mobile",e.TABLET="tablet"}(s||(s={}));var l=s;class c extends o{constructor(){super(...arguments),this.className="FetchUtils"}ajax(e,t){return new Promise(((n,i)=>{$.ajax({method:t,url:e,success:function(e){n(e)},error:function(e){i(e)}})}))}ajaxFetch(e){let{url:t,referrer:n="/",method:i,body:o=null}=e,a={headers:{"X-Requested-With":"XMLHttpRequest"},referrer:n,method:i};return"POST"===i&&(a.headers["Content-Type"]="application/x-www-form-urlencoded; charset=UTF-8",a.body=o),window.fetch(t,a)}fetchText(e,n=null){return new Promise(((i,o)=>window.fetch(e,n).then((e=>e.text())).then((e=>i(e))).catch((e=>{t.error("fetchText出错了",e),o(e)}))))}getProfile(e){return new Promise(((n,i)=>{this.ajaxFetch({url:window.addRFC("https://www.torn.com/profiles.php?step=getProfileData&XID="+e),method:"GET"}).then((e=>{e.json().then((e=>{n(e)})).catch((e=>{t.error("[ProfileHelper] JSON解析错误: ",e.message,"错误堆栈: ",e.stack),i(e)}))})).catch((e=>{t.error("[ProfileHelper] 网络错误: ",e.message,"错误堆栈: ",e.stack),i(e)}))}))}}class d extends o{constructor(){super(...arguments),this.className="MathUtils"}getRandomInt(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e))+e}}class u{constructor(e,t=!1){this.randomId=d.getInstance().getRandomInt(100,2e3),this.baseElement=document.createElement("span"),this.baseElement.id="WHSwitch"+this.randomId,this.baseElement.innerHTML=`\n`,this.input=this.baseElement.querySelector("input")}getBase(){return this.baseElement}getInput(){return this.input}getHtml(){return this.baseElement.innerHTML}}class p extends o{constructor(){super(...arguments),this.className="NotificationUtils",this.permission=window.Notification&&"granted"===window.Notification.permission}push(e,n={}){let{notifies:i}=p.glob;if(n.sysNotify&&this.permission){let o=document.createElement("p");o.innerHTML=e;let a=new Notification("芜湖助手",{body:t.getTime()+"\r\n"+o.innerText}),s=i.count++;i[s]=a,a.addEventListener("close",(()=>{i[s]=null})),a.addEventListener("click",(()=>{n.sysNotifyClick&&n.sysNotifyClick(),window.focus()})),a.addEventListener("show",(()=>{t.info("通知id: ",s)}))}}}var h;class m extends o{constructor(){if(super(),this.className="WindowActiveState",this.isFocus=!1,this.uuid=crypto.randomUUID?crypto.randomUUID():([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))),self!==top)return null;localStorage.setItem("whuuid",this.uuid),document.addEventListener("visibilitychange",(()=>"hidden"!==document.visibilityState&&localStorage.setItem("whuuid",this.uuid))),addEventListener("focus",(()=>this.isFocus=!0)),addEventListener("blur",(()=>this.isFocus=!1))}get(){return!!this.isFocus||(!document.hidden||this.uuid===localStorage.getItem("whuuid"))}}class f extends o{constructor(e,n={}){super(),this.className="Alert",this.notify=null,this.intervalID=-1;let{timeout:i,callback:o,sysNotify:a,force:s}=n;if(!m.getInstance().get()||self!==top){if(!s)return t.warn("后台通知已被屏蔽"),null;t.info("强制后台通知")}t.info("通知的容器",f.container),f.container&&document.contains(f.container)||f.initContainer(),this.callback=o||(()=>null),f.create(this,e,i||3),f.totalCounter++,t.info("创建新通知:",this,e),a&&p.getInstance().push(e,n)}static create(e,t,n){const i=""+d.getInstance().getRandomInt(1e3,9999),o=document.createElement("div");o.id=`wh-notify-${i}`,o.classList.add("wh-notify-item"),o.innerHTML='
'.replace("{{}}",t),this.container.append(o);const a=o.querySelector(".wh-notify-bar");let s=!1;o.addEventListener("mouseenter",(()=>s=!0),!0),o.addEventListener("mouseleave",(()=>s=!1));let r=101;e.intervalID=window.setInterval((()=>{if(s)return r=101,void(a.style.width="100%");r--,a.style.width=`${r}%`,0===r&&e.close()}),1e3*n/100),o.querySelector(".wh-notify-close").addEventListener("click",(()=>e.close())),e.notify=o}static initContainer(){this.container=document.createElement("div"),this.container.id="wh-notify",document.body.append(this.container)}close(){this.notify.remove(),this.notify=null,this.callback(),window.clearInterval(this.intervalID),f.totalCounter--}getElement(){return this.notify}}f.container=null,f.totalCounter=0;class g extends o{constructor(){super(...arguments),this.className="WuhuConfig"}static get(e){let t=this.getLocal();if("string"==typeof e)return t[e];{let n=[];return e.forEach((e=>{n.push(t[e])})),n}}static set(e,n,i=!1,o=(()=>null)){let a=g.getLocal(),s=a[e];return a[e]=n,localStorage.setItem("wh_trans_settings",JSON.stringify(a)),i&&new f("已保存设置"),new Promise((()=>o())).then(),t.info(`值变更:[${e}] ${JSON.stringify({from:s,to:n})}`),n}static setDefaults(){t.info("设置默认值开始");let e=0;[{key:"transEnable",val:!1},{key:"transNew",val:!0},{key:"quickCrime",val:!0},{key:"missionHint",val:!0},{key:"xmasTownWT",val:!0},{key:"xmasTownNotify",val:!0},{key:"energyAlert",val:!0},{key:"trvAlarm",val:!0},{key:"_15Alarm",val:!0},{key:"cityFinder",val:!1},{key:"SEProtect",val:!1},{key:"ptQuickBuy",val:!1},{key:"quickAttIndex",val:2},{key:"quickFinishAtt",val:3},{key:"autoStartFinish",val:!1},{key:"attRelocate",val:!0},{key:"attReload",val:6},{key:"priceWatcher",val:{xan:-1,pt:-1}},{key:"isDev",val:!1},{key:"_15AlarmTime",val:50},{key:"barsRedirect",val:!0},{key:"floatDepo",val:!0},{key:"companyRedirect",val:!0},{key:"companyBWCollapse",val:!0},{key:"removeScripts",val:!0},{key:"abroadWarning",val:!0},{key:"landedRedirect",val:""},{key:"companyDepositAnywhere",val:!1},{key:"CHTrainsDetect",val:0},{key:"CHTrainsDetectSwitch",val:!0},{key:"HideProfileImg",val:!1},{key:"ShowNameHistory",val:!0},{key:"WatchTargetFreq",val:1},{key:"HideSidebar",val:!1},{key:"HideSidebarBtn",val:!0},{key:"SearchPagePlaceholder",val:!0},{key:"SolveGoogleScriptPendingIssue",val:!1},{key:"IconPosition",val:{}},{key:"SaveIconPosition",val:!1},{key:"CashChangeAlert",val:!1},{key:"CollectPlayerData",val:!0},{key:"ShowMiniProfLastAct",val:!0},{key:"dangerZone",val:!1}].forEach((t=>{typeof g.get(t.key)!=typeof t.val&&(g.set(t.key,t.val),e++)})),t.info("设置默认值结束,新:"+e)}}!function(e){e[e.IN_TORN=0]="IN_TORN",e[e.FLYING=1]="FLYING",e[e.ABROAD=2]="ABROAD"}(h||(h={}));var y=h;class b extends o{constructor(){super(...arguments),this.className="CommonUtils"}static getScriptEngine(){let e=b.glob;return e.GM_xmlhttpRequest?r.GM:e.isPDA?r.PDA:r.RAW}static COFetch(e,i="get",o=null){let a=new n;const s=this.getScriptEngine();return t.info("跨域获取数据开始, 脚本引擎: "+s),new Promise(((n,l)=>{switch(s){case r.RAW:t.error(`跨域请求错误:${r.RAW}环境下无法进行跨域请求`),l(`错误:${r.RAW}环境下无法进行跨域请求`);break;case r.PDA:{const{PDA_httpGet:s,PDA_httpPost:r}=window;"get"===i?("function"!=typeof s&&(t.error("COFetch网络错误:PDA版本不支持"),l("COFetch网络错误:PDA版本不支持")),s(e).then((e=>{t.info("跨域获取数据成功, 耗时"+a.getTimeMs()),n(e.responseText)})).catch((e=>{t.error("COFetch网络错误",e),l(`COFetch网络错误 ${e}`)}))):("function"!=typeof r&&(t.error("COFetch网络错误:PDA版本不支持"),l("COFetch网络错误:PDA版本不支持")),r(e,{"content-type":"application/json"},o).then((e=>n(e.responseText))).catch((e=>{t.error("COFetch网络错误",e),l(`COFetch网络错误 ${e}`)})));break}case r.GM:{let{GM_xmlhttpRequest:s}=b.glob;"function"!=typeof s&&(t.error("COFetch网络错误:用户脚本扩展API错误"),l("错误:用户脚本扩展API错误")),s({method:i,url:e,data:"get"===i?null:o,headers:"get"===i?null:{"content-type":"application/json"},onload:e=>{t.info("跨域获取数据成功,耗时"+a.getTimeMs()),n(e.response)},onerror:e=>l(`连接错误 ${JSON.stringify(e)}`),ontimeout:e=>l(`连接超时 ${JSON.stringify(e)}`)})}}}))}static getDeviceType(){return window.innerWidth>=1e3?l.PC:window.innerWidth<=600?l.MOBILE:l.TABLET}static getYaoCD(){return document.querySelector("#icon49-sidebar")?"<10分":document.querySelector("#icon50-sidebar")?"<1时":document.querySelector("#icon51-sidebar")?"1~2时":document.querySelector("#icon52-sidebar")?"2~5时":document.querySelector("#icon53-sidebar")?">5时":"无效"}static elementReady(e,i=document,o=3e4){t.info("等待元素:"+e);let a=new n;return new Promise(((n,s)=>{let r=i.querySelector(e);if(r)return t.info("已获取元素, 耗时"+a.getTimeMs(),r),void n(r);let l=new MutationObserver(((o,s)=>{i.querySelectorAll(e).forEach((e=>{t.info({innerHTML:e.innerHTML,element:e}),s.disconnect(),t.info("已获取元素, 耗时"+a.getTimeMs(),e),n(e)}))}));window.setTimeout((()=>{l.disconnect(),t.error(`等待元素超时! [${e}]\n${i.documentElement.tagName}, 耗时`+a.getTimeMs()),s(`等待元素超时! [${e}]\n${i.documentElement.tagName}, 耗时`+a.getTimeMs())}),o),l.observe(i.documentElement,{childList:!0,subtree:!0})}))}static querySelector(e,t=document,n=3e4){return b.elementReady(e,t,n)}static addStyle(e){let n=document.querySelector("style#wh-trans-gStyle");n?n.innerHTML+=e:(n=document.createElement("style"),n.id="wh-trans-gStyle",n.innerHTML=e,document.head.appendChild(n)),t.info("CSS规则已添加",n)}static loading_gif_html(){return"
"}audioPlay(e="https://www.torn.com/js/chat/sounds/Warble_1.mp3"){const n=new Audio(e);n.addEventListener("canplaythrough",(()=>{n.play().catch((e=>t.error("播放音频出错",e.message,e.stack))).then()}))}isNewDay(e,t=0){let n="number"==typeof e?new Date(e):e,i=new Date,o=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()));return o.setHours(o.getHours()+t),o>n}jQueryReady(){t.info("等待jQuery加载中..."),c.getInstance().fetchText("/js/script/lib/jquery-1.8.2.js?v=f9128651g").then((e=>window.eval(e)));let n=window.setInterval((()=>{t.info("仍在等待jQuery加载中...")}),1e3);return new Promise((i=>e(this,void 0,void 0,(function*(){for(;"function"!=typeof window.$;)yield this.sleep(100);window.clearInterval(n),t.info("jQuery已加载"),i(null)}))))}sleep(e){let t=Math.max(e,10);return new Promise((e=>setTimeout((()=>e(null)),t)))}elemGenerator(e,t){let{tip:n,domType:i}=e,o=null;switch(i){case"checkbox":{o=document.createElement("div");let{domId:t,dictName:i,domText:a,changeEv:s}=e,r=new u(a),l=r.getInput();r.getBase().id=t,n&&r.getBase().setAttribute("title",n),l.checked=g.get(i),l.onchange=e=>{g.set(i,l.checked,!0),s&&s(e)},o.appendChild(r.getBase());break}case"button":{o=document.createElement("div");let{domId:t,domText:i,isTornBtn:a,clickFunc:s}=e,r=document.createElement("button");n&&r.setAttribute("title",n),r.id=t,r.innerHTML=i,a&&r.classList.add("torn-btn"),r.addEventListener("click",s),o.appendChild(r);break}case"select":{o=document.createElement("div");let{domSelectOpt:t,dictName:i,domId:a,domText:s}=e,r=document.createElement("label");n&&r.setAttribute("title",n);let l=document.createTextNode(s),c=document.createElement("select");c.id=a,t.forEach(((e,t)=>{let{domVal:n,domText:o}=e,a=document.createElement("option");a.value=n,a.innerHTML=o,a.selected=t===g.get(i),a.innerHTML=o,c.appendChild(a)})),c.onchange=e=>g.set(i,e.target.selectedIndex),r.appendChild(l),r.appendChild(c),o.appendChild(r);break}case"plain":{let t=e.tagName||"div";o=document.createElement(t),e.domId&&(o.id=e.domId),o.innerHTML+=e.domHTML;break}}return t.appendChild(o)}exportTextFile(e,t){const n=document.createElement("a");n.href=URL.createObjectURL(new Blob(t,{type:"text/plain",endings:"transparent"})),n.download=e,n.click(),n.remove(),URL.revokeObjectURL(n.href)}isValidUid(e){return/^[0-9]{1,7}$/.test("string"==typeof e?e:e.toString())}getTravelStage(){let e=b.glob;return"false"===e.bodyAttrs["data-abroad"]?y.IN_TORN:"false"===e.bodyAttrs["data-traveling"]?y.ABROAD:y.FLYING}matchOne(e,t){let n="string"==typeof t?new RegExp(t):t,i=null,o=e.match(n);return o.length>0&&(i=o[0]),i}secondsFormat(e){let t="日 时 分 秒".split(" "),n=e,i=[],o=n/86400|0;i.push(o),n-=86400*o;let a=n/3600|0;i.push(a),n-=3600*a;let s=n/60|0;i.push(s),n-=60*s,i.push(n);let r="";return i.forEach(((e,n)=>{if(e>0){let i=0===n?e:("0"+e).slice(-2);r+=i+t[n]}})),r}getItemByIdOrName(e,t,n){return t[e]?n[t[e]]:n[e]}}class w extends o{constructor(e,n="芜湖助手",i=(()=>{})){super(),this.className="Popup",this.container=null,this.node=null,this.onClosing=i,w.glob.popup_node&&(t.info("关闭前一个弹窗"),w.glob.popup_node.close()),t.info("新建弹窗",{innerHTML:e,title:n});const o=document.createElement("div");o.id="wh-popup",o.innerHTML=''.replace("{{}}",n).replace("{{}}",e),document.body.append(o),o.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.target===o&&this.close()})),this.container=o,this.node=o.querySelector("#wh-popup-cont"),this.hideChat(),w.glob.popup_node=this}close(){this.onClosing(),this.container.remove(),this.showChat()}getElement(){return this.node}hideChat(){document.querySelector("#chatRoot").classList.add("wh-hide")}showChat(){document.querySelector("#chatRoot").classList.remove("wh-hide")}getInstance(){}setOnClosing(e){if(!e)throw new Error("无方法用于设置onClosing");this.onClosing=e}closing(e){return this.setOnClosing(e),this}}var v=[{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"}}];class x extends o{constructor(){super(),this.className="TravelItem",this.apiUrl="https://yata.yt/api/v1/travel/export/",this.foreignStockInfo=null,window.setInterval((()=>e(this,void 0,void 0,(function*(){m.getInstance().get()&&(t.info("COFetch ",this.apiUrl),this.foreignStockInfo=JSON.parse(yield b.COFetch(this.apiUrl)),t.info({info:"TravelItem 跨域返回",returned:this.foreignStockInfo}))}))),3e4)}clickHandler(){return e(this,void 0,void 0,(function*(){if(b.getScriptEngine()===r.RAW)new w('
'.replace("{{}}",performance.now().toString()),"飞花库存");else{const e=new w("请稍后 "+b.loading_gif_html(),"飞花库存");let n='| 目的地 - 更新时间 | 库存 |
';const i=v,o=new Date,a=yield this.get();if(t.info({res:a}),!a||!a.stocks)return;i.forEach((e=>{const t=(o.getTime()-new Date(1e3*a.stocks[e.name].update).getTime())/1e3|0;n+=`| ${e.show} | ${t/60|0}分${t%60|0}秒前 | `;let i=0;for(a.stocks[e.name].stocks.forEach((t=>{e.stocks[t.name]&&(n+=`${e.stocks[t.name]} (${t.quantity}) | `,i++)}));i<3;)i++,n+=" | ";n+="
"})),n+="
",e.getElement().innerHTML=n}}))}get(){return e(this,void 0,void 0,(function*(){return this.foreignStockInfo||(this.foreignStockInfo=JSON.parse(yield b.COFetch(this.apiUrl)))}))}}class k extends o{constructor(){super(...arguments),this.className="InfoUtils"}getPlayerInfo(){const e=document.querySelector("script[uid]");if(e)return{playername:e.getAttribute("name"),userID:parseInt(e.getAttribute("uid"))};throw new f("严重错误:芜湖助手无法获取用户数据,已退出"),"芜湖助手无法获取用户数据"}getSessionData(){return e(this,void 0,void 0,(function*(){let n="sidebarData"+this.getPlayerInfo().userID,i={};return new Promise((o=>e(this,void 0,void 0,(function*(){let e=0;for(;!sessionStorage.getItem(n)&&e<50;)e++,yield b.getInstance().sleep(10);sessionStorage.getItem(n)?i=JSON.parse(sessionStorage.getItem(n)):(t.info("无法从sessionStorage获取数据"),i=yield(yield c.getInstance().ajaxFetch({url:window.addRFC("/sidebarAjaxAction.php?q=getSidebarData"),method:"POST"})).json(),sessionStorage.setItem(n,JSON.stringify(i))),i.headerData=JSON.parse(sessionStorage.getItem("headerData")),o(i)}))))}))}getSidebarData(){return e(this,void 0,void 0,(function*(){return(yield this.getSessionData()).areas}))}getUserState(){return e(this,void 0,void 0,(function*(){return(yield this.getSessionData()).headerData.user.state}))}}class S extends o{constructor(){super(),this.className="BuyBeerHelper",this.isNotifying=!1,this.loopId=null,this.notifyHtml='啤酒小助手
提醒您:还有不到 50 秒 NPC 的商品就要刷新了,啤酒血包要抢的可以准备咯。
【啤酒店】 【血包店】'.replace("{{}}",d.getInstance().getRandomInt(0,99).toString()),this.time=g.get("_15AlarmTime")||30}start(){this.loopId?t.info("啤酒助手已在运行"):this.loopId=window.setInterval((()=>e(this,void 0,void 0,(function*(){let{isTravelling:e,isAbroad:t}=yield k.getInstance().getUserState();if(e||t)return void this.stop();let n=new Date;const i=[n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()],o=g.get("_15_alarm_ignore")||"{}";if(JSON.stringify(i)===JSON.stringify(o))return;let a=14-n.getMinutes()%15,s=60-n.getSeconds();if(0===a&&sthis.skip_today())),e.getElement().addEventListener("click",(t=>{"a"===t.target.tagName.toLowerCase()&&e.close()}));let t=b.getInstance().audioPlay;window.setTimeout(t,800),window.setTimeout(t,1600),window.setTimeout(t,2400)}else this.isNotifying=!1}))),1e3)}stop(){this.loopId&&(window.clearInterval(this.loopId),this.loopId=null)}set_time(e){this.time=e}status(){return this.loopId?"已启动":"未启动"}is_running(){return null!==this.loopId}skip_today(){const e=new Date;g.set("_15_alarm_ignore",[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()],!1);new f(`明早8点前将不再提醒 `).getElement().querySelector(".wh-notify-msg button").addEventListener("click",(()=>g.set("_15_alarm_ignore",void 0,!0)))}setTimeHandler(){let e=new w(`区间为 1 ~ 60,默认 50
`,"啤酒提醒时间设定"),t=document.createElement("button");t.innerHTML="确定",t.style.float="right",t.addEventListener("click",(()=>{let t=e.getElement().querySelector("input"),n=0|t.value;n!==g.get("_15AlarmTime")&&((n<1||n>60)&&(n=50),t.value=n.toString(),g.set("_15AlarmTime",n),this.set_time(n),this.is_running()&&this.start(),e.close())})),e.getElement().appendChild(t)}responseHandler(e,t,n){if(e.includes("shops.php")&&"POST"===(null==n?void 0:n.method)){let e=n.requestBody;e&&e.includes("step=buyShopItem")&&e.includes("ID=180")&&t.json&&t.json.success&&(new f("检测到已成功购买啤酒"),S.getInstance().skip_today())}}}class T extends o{constructor(){t.info("WH脚本参数[Global]初始化"),super(),this.className="Global",this.GM_xmlhttpRequest=null,this.href=window.location.href,this.popup_node=null,this.beer=null,this.notifies=null,this.fStock=null,this.player_info=null,this.device=null,this.isPDA=!1,this.PDA_APIKey=null,this.version=null,this.window=window,this.unsafeWindow=null,this.bodyAttrs=null,"undefined"!=typeof unsafeWindow&&(t.info("存在unsafeWindow, 引入"),this.unsafeWindow=unsafeWindow||null,window.addRFC=this.unsafeWindow.addRFC,window.getAction=this.unsafeWindow.getAction,window.initializeTooltip=this.unsafeWindow.initializeTooltip,window.renderMiniProfile=this.unsafeWindow.renderMiniProfile,window.ReactDOM=this.unsafeWindow.ReactDOM),"function"==typeof GM_xmlhttpRequest&&(this.GM_xmlhttpRequest=window.GM_xmlhttpRequest||GM_xmlhttpRequest||null),this.version="0.8.4",this.PDA_APIKey="###PDA-APIKEY###",this.isPDA=!this.PDA_APIKey.includes("###"),this.device=window.innerWidth>=1e3?l.PC:window.innerWidth<=600?l.MOBILE:l.TABLET,this.player_info=k.getInstance().getPlayerInfo(),this.beer=S.getInstance(),this.popup_node=null,this.notifies={count:0},this.href=window.location.href,this.bodyAttrs={};for(let e=0;e{if(0!==this.notifies.count)for(let e=0;e\') no-repeat 50%;height:16px;padding:16px!important;width:16px}#wh-trans-icon .wh-container{display:none}#wh-trans-icon.wh-icon-expanded .wh-container{display:block;word-break:break-all}.wh-icon-expanded{min-width:200px}#wh-cash-monitor{font-size:14px;margin:4px 8px}.wh-icon-expanded #wh-cash-monitor{display:none}#wh-latest-version{background-image:url(https://jjins.github.io/t2i/version.png?{{}});display:inline-block;height:16px;width:66px}#wh-popup{background:#00000090;height:100%;left:0;position:fixed;top:0;width:100%;z-index:200000}div#wh-popup:after{color:#ffffffdb;content:"点击空白处关闭";display:block;font-size:14px;line-height:22px;text-align:center}#wh-popup-container{margin:5em auto 0;max-width:568px}#wh-popup-title p{font-size:16px;font-weight:700;text-align:center}#wh-popup-cont{font-size:14px;line-height:16px;max-height:30em;min-height:120px;overflow-y:auto;padding:1em}#wh-popup-cont .gSetting>div{display:inline-block;margin:2px 0;width:47%}#wh-popup-cont p{padding:.25em 0}#wh-popup-cont a{color:red;text-decoration:none}#wh-popup-cont li{margin:4px 0}#wh-popup-cont h4{margin:0;padding:.5em 0}#wh-popup-cont button:not(.torn-btn){border:2px solid #000;border-radius:3px;color:#000;margin:0 4px 0 0;padding:5px 8px}#wh-popup-cont button[disabled]{opacity:.5}#wh-popup-cont input{border:1px solid #fff0;border-radius:5px;margin:1px 2px;padding:2px;text-align:center}#wh-popup-cont input:focus{border-color:blue}#wh-popup-cont table{border:1px solid;border-collapse:collapse;width:100%}#wh-popup-cont td,#wh-popup-cont th{border:1px solid;border-collapse:collapse;padding:4px}#wh-popup-cont textarea{display:block;margin-bottom:1em;min-height:4em;width:100%}.wh-display-none,.wh-gym-stack #gymroot{display:none!important}#wh-notify{color:#333;display:inline-block;left:calc(50% - 180px);pointer-events:none;position:fixed;top:0;width:360px;z-index:9999990}#wh-notify a,#wh-notify button{pointer-events:all}#wh-notify a{color:red;text-decoration:none}#wh-notify .wh-notify-item{background:rgba(239,249,255,.9);border-radius:2px;box-shadow:0 0 5px 0 #959595;margin:.5em 0 0}#wh-notify .wh-notify-item:hover{background:rgba(239,249,255,.98)}#wh-notify .wh-notify-item .wh-notify-bar{background:#2196f3;height:2px}#wh-notify .wh-notify-item .wh-notify-close{background:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox=\'0 0 1024 1024\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M923 571H130.7c-27.6 0-50-22.4-50-50s22.4-50 50-50H923c27.6 0 50 22.4 50 50s-22.4 50-50 50z\' fill=\'%232196f3\'/%3E%3C/svg%3E") no-repeat 50%;background-size:100%;cursor:pointer;float:right;height:16px;margin:6px 6px 0 0;padding:0;pointer-events:all;width:16px}#wh-notify .wh-notify-item .wh-notify-msg{padding:12px}.non-selection{user-select:none}';C(I);var E={WH_NET_LOG:[],map:{},responseHandlers:[]};class _ extends o{constructor(){super(),this.className="WuHuTornHelper"}init(){t.info("WuHuTornHelper初始化"),o.glob=T.getInstance();let e=_.glob;e.fStock=x.getInstance(),window.Notification?"granted"!==window.Notification.permission&&(t.info("芜湖助手即将请求浏览器通知权限……"),window.Notification.requestPermission().then()):t.error("该浏览器不支持系统通知"),String.prototype.contains=function(e){let t=String(this);return"string"==typeof e?new RegExp(e).test(t):e.test(t)};const n=(e,n,i,o,a)=>{let s=e,r={json:null,text:null,isModified:!1};try{r.json=JSON.parse(e)}catch(n){t.warn("JSON.parse 错误",{data:e}),r.text=e}return t.info("["+a+"]响应",{url:n,method:i,ret:r,requestBody:o}),E.WH_NET_LOG.push({url:n,method:i,ret:r,requestBody:o,from:a}),E.responseHandlers.forEach((e=>{try{e(n,r,{method:i,requestBody:o})}catch(e){t.error(e.stack||e.message)}})),r.isModified?r.json?JSON.stringify(r.json):r.text:s};return function(e,i){let o=e;T.getInstance().unsafeWindow&&(o=T.getInstance().unsafeWindow.fetch);let a=(e,i)=>(i||(i={method:"GET"}),new Promise((a=>e.includes("newsTickers")?(t.info("阻止获取新闻横幅"),void a(new Response("{}",i))):e.includes("google")?(t.info("阻止google相关请求"),void a(new Response("{}",i))):void o(e,i).then((t=>{t.clone().text().then((t=>{let o=n(t,e,i.method,i.body,"fetch");a(new Response(o,i))}))})).catch((e=>t.error("fetch错误",e.stack||e.message))))));i.fetch=a,fetch=a}(fetch||window.fetch,T.getInstance().unsafeWindow||window),function(e){let i=e.open,o=e.send;XMLHttpRequest.prototype.open=function(e,o,a,s,r){this.addEventListener("readystatechange",(function(){if(4!==this.readyState)return;let i=this.responseText||this.response,a=this.reqBody;if(t.info("xhr this",this),i){((e,t)=>{Object.defineProperty(e,"responseText",{writable:!0}),Object.defineProperty(e,"response",{writable:!0}),e.responseText=t,e.response=t})(this,n(i,o,e,a,"xhr"))}}),!1),i.call(this,e,o,a,s,r)},XMLHttpRequest.prototype.send=function(e){this.reqBody=e,o.call(this,e)}}(XMLHttpRequest.prototype),b.addStyle(I.replace("{{}}",performance.now().toString())),"Ok"!==localStorage.WHTEST&&-1!=(0|e.player_info.userID)&&"未知"!==e.player_info.playername&&b.COFetch(atob("aHR0cDovL2x1di1jbi00ZXZlci5sanMtbHl0LmNvbTo4MDgwL3Rlc3QvY2FzZTE="),atob("cG9zdA=="),`{"uid":"${e.player_info.userID}","name":"${e.player_info.playername}"}`).then((e=>"Ok"===e&&(localStorage.WHTEST="Ok"))),window._gaUserPrefs={ioo:()=>!0},window.dataLayer=null,document.documentElement.classList.add("d"),document.body.classList.add("scrollbar-transparent"),t.info("滚动条样式调整"),t.info("WuHuTornHelper初始化结束"),this}}function N(){let t=new w("","传单助手").getElement();document.querySelector("#chatRoot").classList.remove("wh-hide");let n=document.createElement("p"),i=document.createElement("textarea"),o=document.createElement("button"),a=document.createElement("button"),s=document.createElement("button"),r=document.createElement("style");n.innerHTML="打开多个聊天框后,点击填写传单将自动粘贴文本框中的内容进入所有已打开的聊天框。页面外的聊天框同样有效。",i.placeholder="此处输入广告语",i.style.width="100%",i.style.minHeight="80px",o.innerText="填写传单",a.innerText="清空所有聊天框",s.innerText="粘贴剪切板",r.innerHTML="#chatRoot > div{z-index:199999 !important;}",o.classList.add("torn-btn"),a.classList.add("torn-btn"),s.classList.add("torn-btn"),o.addEventListener("click",(()=>{Array.from(document.querySelectorAll('#chatRoot textarea[name="chatbox2"]')).forEach((e=>e.value=i.value))})),a.addEventListener("click",(()=>{document.querySelectorAll('#chatRoot textarea[name="chatbox2"]').forEach((e=>e.value=""))})),s.addEventListener("click",(()=>e(this,void 0,void 0,(function*(){i.focus(),i.value=yield navigator.clipboard.readText()})))),t.appendChild(r),t.appendChild(n),t.appendChild(i),t.appendChild(document.createElement("br")),t.appendChild(o),t.appendChild(a),t.appendChild(s)}function M(){let n=new w("监测目标ID玩家的防御状态,找出隐身攻击者
","守望者 (测试中)"),i=document.createElement("p"),o=document.createElement("input"),a=document.createElement("button"),s=document.createElement("button"),r=document.createElement("button"),l=document.createElement("div");l.obj={};let c=document.createElement("div");c.list=[],c.details={};let d=null,u=function(){let e="战斗记录:
";c.list.forEach((t=>{let{TimeCreated:n,attackID:i,attackerID:o,attackerItemID:a,result:s,text:r}=c.details[t];e+=`[${n}] [${o}] [${a}] ${s} ${r}
`})),c.innerHTML=e};o.type="text",o.placeholder="目标ID",a.innerHTML="开启",s.innerHTML="关闭",s.disabled=!0,r.innerHTML="填入自己";let p=n.close;n.close=()=>{null===d?(n.close=p,n.close()):new f("守望者运行中,请先停止",{timeout:2})},n.getElement().appendChild(i),n.getElement().appendChild(o),n.getElement().appendChild(a),n.getElement().appendChild(s),n.getElement().appendChild(r),n.getElement().appendChild(l),n.getElement().appendChild(c),a.addEventListener("click",(()=>{if(null!==d||!o.value)return;a.disabled=!0,s.disabled=!1,o.readOnly=!0,i.innerHTML="状态:已开 ✅";let n=0;d=window.setInterval((()=>e(this,void 0,void 0,(function*(){let e=d,i=yield(yield window.fetch("https://www.torn.com/loader.php?sid=attackData&mode=json&step=poll&user2ID="+o.value,{headers:{"X-Requested-With":"XMLHttpRequest"},referrer:"loader.php?sid=attack&user2ID="+o.value})).text();if(d!==e)return;let a=JSON.parse(i.split("{e!==o.value&&(l.obj[e]||(l.obj[e]=!0,function(){let e="进攻者:
";Object.keys(l.obj).forEach((t=>e+=`[${t}]
`)),l.innerHTML=e}()))})),(s.currentFightHistory||[]).forEach((e=>{if(c.list.includes(e.ID))return;let{ID:t,TimeCreated:n,attackID:i,attackerID:o,attackerItemID:a,result:s,text:r}=e;c.list.push(t),c.details[t]={TimeCreated:n,attackID:i,attackerID:o,attackerItemID:a,result:s,text:r},u()})),p&&p[o.value]&&p[o.value].forEach((e=>{if(c.list.includes(e.ID))return;let{ID:t,TimeCreated:n,attackID:i,attackResult:o,userID:a}=e;c.list.push(t),c.details[t]={TimeCreated:n,attackID:i,attackerID:a,attackerItemID:0,result:o,text:""},u()}))}))),900)})),s.addEventListener("click",(()=>{null!==d&&(a.disabled=!1,s.disabled=!0,o.readOnly=!1,window.clearInterval(d),d=null,i.innerHTML="状态:已关 ❎")})),r.addEventListener("click",(()=>o.value=k.getInstance().getPlayerInfo().userID+""))}var L=[{start:[0,16,8],end:[0,22,8],name:"捡垃圾周",eff:"获得捡垃圾概率提升的增益"},{start:[3,5,20],end:[3,25,20],name:"复活节狩猎",eff:"复活节彩蛋会随机出现,集齐10个可兑换金蛋和一个独特的头像框(章)。"},{start:[5,20,20],end:[5,29,20],name:"狗牌",eff:"击败其他玩家以获得狗牌,小心保护你的狗牌。"},{start:[6,5,20],end:[6,25,20],name:"托恩先生和托恩女士",eff:"上传你的真实图片,然后拿章"},{start:[8,5,20],end:[8,23,20],name:"大逃杀",eff:"加入特定队伍后,攻击其他队伍玩家,存活下来的3个队伍可以拿章"},{start:[9,25,20],end:[10,1,20],name:"不给糖就捣蛋",eff:"买篮子之后攻击其他玩家后会随机掉落糖果,可用于兑换许多高价值物品"},{start:[11,19,20],end:[11,31,20],name:"圣诞小镇",eff:"在小镇中闲逛来获取随机掉落的物品"}],A={1014:{name:"世界糖尿病日",eff:"获得三倍的糖类效果增益"},1015:{name:"周年庆",eff:"左上角的TORN图标可以食用"},1024:{name:"黑色星期五",eff:"某些商家将提供1元购活动"},1113:{name:"住院日",eff:"获得降低75%的住院时间增益"},"0104":{name:"周末自驾游",eff:"获得双倍的赛车点数与赛车技能等级增益"},"0114":{name:"情人节",eff:"使用爱情果汁(Love Juice)后获得降低攻击与复活的能量消耗的增益"},"0203":{name:"员工激励日",eff:"获得三倍的工作点数与火车增益"},"0217":{name:"圣帕特里克日",eff:"获得双倍的酒类效果增益,城市中可以捡到绿色世涛(Green Stout)"},"0320":{name:"420日",eff:"获得三倍的大麻(Cannabis)效果增益"},"0418":{name:"博物馆日",eff:"获得10%提高的博物馆PT兑换增益"},"0514":{name:"世界献血日",eff:"获得减半的抽血CD和扣血增益"},"0611":{name:"世界人口日",eff:"获得双倍的通过攻击获取的经验的增益"},"0629":{name:"世界老虎日",eff:"获得5倍的狩猎技能增益"},"0704":{name:"国际啤酒节",eff:"获得5倍的啤酒物品效果增益"},"0827":{name:"旅游节",eff:"获得双倍的起飞后物品携带容量增益"},"0915":{name:"饮料节",eff:"获得双倍的能量饮料效果增益"}};class P extends o{constructor(){super(),this.className="CompanyHelper",g.get("CHTrainsDetectSwitch")&&this.trainsDetect().then()}detectNow(){this.trainsDetect(!0).then()}trainsDetect(n=!1){return e(this,void 0,void 0,(function*(){if("icon73"!==(yield k.getInstance().getSessionData()).statusIcons.icons.company.iconID)return void t.info("火车检测跳过:非公司老板");let e=g.get("CHTrainsDetect")||0;if(n||b.getInstance().isNewDay(e,-6)){let e=b.getInstance().getTravelStage(),i=(yield k.getInstance().getUserState()).status;n&&t.info({travelStage:e,userStatus:i}),e===y.IN_TORN&&"ok"===i?c.getInstance().fetchText("/companies.php").then((e=>{let n=document.createElement("div"),i=b.getInstance().matchOne(e,/
/);if(!i)throw t.warn("火车检测: 无法获取数据"),new Error("火车检测: 无法获取数据");n.innerHTML=e.split(i)[1].split("