This commit is contained in:
woohoo 2022-07-11 17:30:54 +08:00
parent 597819af99
commit 7b18a8a38e

View File

@ -27,6 +27,7 @@
}) })
} }
// region 翻译字典
const titleDict = { const titleDict = {
'Home': '主页', 'Home': '主页',
'Estate Agents': '地产中介', 'Estate Agents': '地产中介',
@ -2725,36 +2726,6 @@
}; };
// 中文字符集正则 // 中文字符集正则
const CC_set = /[\u4e00-\u9fa5]/; const CC_set = /[\u4e00-\u9fa5]/;
// regexp test
String.prototype.contains = function contains(keywords) {
if ('string' === typeof keywords) {
return new RegExp(keywords).test(this);
}
if (keywords.test) {
return keywords.test(this);
}
};
// 原始fetch
const ori_fetch = window.fetch;
// 监听fetch
window.fetch = async (url, init) => {
if (url.contains('newsTickers')) {
// 阻止获取新闻横幅
return new Response('{}');
}
const res = await ori_fetch(url, init);
// mini profile 翻译
if (url.includes('profiles.php?step=getUserNameContextMenu') && getWhSettingObj()['transEnable']) {
setTimeout(() => miniprofTrans(), 200);
}
let clone = res.clone();
let text = await res.text();
log({ url, init, text });
return clone;
};
// const transDict = {}; // const transDict = {};
// transDict.titleDict = titleDict; // transDict.titleDict = titleDict;
// transDict.titleLinksDict = titleLinksDict; // transDict.titleLinksDict = titleLinksDict;
@ -2794,6 +2765,36 @@
// transDict.npcShopDict = npcShopDict; // transDict.npcShopDict = npcShopDict;
// transDict.calDict = calDict; // transDict.calDict = calDict;
// if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict)) // if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict))
// endregion
// regexp test
String.prototype.contains = function contains(keywords) {
if ('string' === typeof keywords) {
return new RegExp(keywords).test(this);
}
if (keywords.test) {
return keywords.test(this);
}
};
// 原始fetch
const ori_fetch = window.fetch;
// 监听fetch
window.fetch = async (url, init) => {
if (url.contains('newsTickers')) {
// 阻止获取新闻横幅
return new Response('{}');
}
const res = await ori_fetch(url, init);
// mini profile 翻译
if (url.includes('profiles.php?step=getUserNameContextMenu') && getWhSettingObj()['transEnable']) {
setTimeout(() => miniprofTrans(), 200);
}
let clone = res.clone();
let text = await res.text();
log({ url, init, text });
return clone;
};
const date = new Date(); const date = new Date();
// 伪enum 设备类型 PC MOBILE TABLET // 伪enum 设备类型 PC MOBILE TABLET
@ -2888,9 +2889,8 @@
if (typeof getWhSettingObj()[df.key] !== typeof df.val) setWhSetting(df.key, df.val); if (typeof getWhSettingObj()[df.key] !== typeof df.val) setWhSetting(df.key, df.val);
}); });
// 助手各项「设置」 // region 助手各项「设置」
let setting_list = []; let setting_list = [];
{
// 12月时加入圣诞小镇选项 // 12月时加入圣诞小镇选项
if (date.getMonth() === 11) { if (date.getMonth() === 11) {
setting_list.push({ setting_list.push({
@ -3282,11 +3282,9 @@
}, },
isHide: true, isHide: true,
}); });
} // endregion
// 菜单中的「选项」 // region 菜单中的「选项」
const menu_list = []; const menu_list = [];
{
// 测试日期
//const date = new Date(2022, 2, 4, 23); //const date = new Date(2022, 2, 4, 23);
// 欢迎 显示玩家id // 欢迎 显示玩家id
@ -4003,7 +4001,8 @@ color:black;
WHNotify('芜湖助手', { sysNotify: true, timeout: 1 }) WHNotify('芜湖助手', { sysNotify: true, timeout: 1 })
}, },
}); });
} // endregion
// 菜单node // 菜单node
const $zhongNode = initIcon(menu_list); const $zhongNode = initIcon(menu_list);
addStyle(` addStyle(`
@ -4220,7 +4219,7 @@ cursor:pointer;
(gonline) && (gonline.remove()); (gonline) && (gonline.remove());
} }
// 存钱CSS 不终止 // region 存钱CSS 不终止
let depo_channel; let depo_channel;
const depo_selector = { CMPY: "div#funds div.deposit", FAC: "div#armoury-donate div.cash" }; const depo_selector = { CMPY: "div#funds div.deposit", FAC: "div#armoury-donate div.cash" };
// 公司 // 公司
@ -4275,10 +4274,12 @@ z-index: 999999;}`);
node.prepend(close_btn); node.prepend(close_btn);
}); });
} }
// endregion
// 飞行页面
if (href.includes('index.php') && getSidebarData()['traveling']) {
// 飞行闹钟 // 飞行闹钟
if (href.includes('index.php') && !!document.querySelector('div.travelling h4') && if (device === Device.PC && getWhSettingObj()['trvAlarm'])
device === Device.PC && getWhSettingObj()['trvAlarm']) {
elementReady('#countrTravel.hasCountdown').then(node => { elementReady('#countrTravel.hasCountdown').then(node => {
const logo_node = document.querySelector('#tcLogo[title]'); const logo_node = document.querySelector('#tcLogo[title]');
let dest_cn = ''; let dest_cn = '';
@ -4503,7 +4504,7 @@ display:none;
}); });
} }
// 海外落地 // 海外落地页面
if (href.includes('index.php') && document.querySelector('#travel-home') !== null) { if (href.includes('index.php') && document.querySelector('#travel-home') !== null) {
// 添加回城按钮 // 添加回城按钮
addActionBtn('直接回城', getHome, $zhongNode); addActionBtn('直接回城', getHome, $zhongNode);
@ -4512,6 +4513,21 @@ display:none;
let c = 1; let c = 1;
setInterval(() => WHNotify(`警告:您已海外落地${c++ * 30}`, { timeout: 30, sysNotify: true }), 30000); setInterval(() => WHNotify(`警告:您已海外落地${c++ * 30}`, { timeout: 30, sysNotify: true }), 30000);
} }
// 解毒提醒
if (getSidebarData()['rehabilitation']) {
let page_title = document.querySelector('h4#skip-to-content');
let msg = document.createElement('div');
msg.innerHTML = `<div class="info-msg border-round">
<i class="info-icon"></i>
<div class="delimiter">
<div class="msg right-round" tabindex="0" role="alert">
<p><a href="/index.php?page=rehab"> 点击前往解毒</a></p>
</div>
</div>
</div>`;
msg.classList.add('info-msg-cont', 'green', 'border-round', 'm-bottom10');
page_title.before(msg);
}
} }
// 起飞提醒 // 起飞提醒
@ -5001,8 +5017,10 @@ display:inline-block;
}); });
} }
// 加入啤酒 // 啤酒
if (href.includes('shops.php?step=bitsnbobs')) { if (href.includes('shops.php?step=bitsnbobs')) {
// 加入啤酒
elementReady('ul.items-list').then(node => {
const add_btn_node = document.createElement('div'); const add_btn_node = document.createElement('div');
add_btn_node.id = 'wh-gym-info-cont'; add_btn_node.id = 'wh-gym-info-cont';
add_btn_node.innerHTML = `<button style="color:white;">👉添加啤酒商品</button><p>如果当前商店没有啤酒这个商品可以提前显示以省去刷新步骤,增加抢酒成功率。</p><p id="wh-msg"></p>`; add_btn_node.innerHTML = `<button style="color:white;">👉添加啤酒商品</button><p>如果当前商店没有啤酒这个商品可以提前显示以省去刷新步骤,增加抢酒成功率。</p><p id="wh-msg"></p>`;
@ -5088,8 +5106,18 @@ $<span class="total">1,000</span>
e.target.remove(); e.target.remove();
msg_node.innerHTML = '添加成功'; msg_node.innerHTML = '添加成功';
}); });
const node = await elementReady('ul.items-list');
document.querySelector('.content-wrapper').prepend(add_btn_node); document.querySelector('.content-wrapper').prepend(add_btn_node);
});
// 监听啤酒购买
$(document).ajaxComplete((_, xhr, settings) => {
log({ xhr, settings });
let { data } = settings, { responseText } = xhr;
let response = JSON.parse(responseText);
if (data.includes('step=buyShopItem') && data.includes('ID=180') && response['success']) {
WHNotify('已检测成功购买啤酒')
beer.skip_today();
}
});
} }
// 快速crime // 快速crime
@ -5123,43 +5151,43 @@ $<span class="total">1,000</span>
const trans = () => { const trans = () => {
const dom = `<div class="wh-translate"><div class="title-black" style="border-radius: 5px 5px 0 0;"><span>常用犯罪</span></div><div class="cont-gray" style="padding: 6px 0;border-radius: 0 0 5px 5px;"> const dom = `<div class="wh-translate"><div class="title-black" style="border-radius: 5px 5px 0 0;"><span>常用犯罪</span></div><div class="cont-gray" style="padding: 6px 0;border-radius: 0 0 5px 5px;">
<!--18-1--> <!--18-1-->
<form id="wh-translate-quick" action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="18"> <input name="nervetake" type="hidden" value="18">
<input name="crime" type="hidden" value="hackbank"> <input name="crime" type="hidden" value="hackbank">
<input style="-webkit-appearance:none;padding: 4px;background: #e91e63;border-radius: 5px;color: white;" type="submit" value="18-1" /> <input style="-webkit-appearance:none;padding: 4px;background: #e91e63;border-radius: 5px;color: white;" type="submit" value="18-1" />
</form> </form>
<!--15-3--> <!--15-3-->
<form id="wh-translate-quick" action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="15"> <input name="nervetake" type="hidden" value="15">
<input name="crime" type="hidden" value="napcop"> <input name="crime" type="hidden" value="napcop">
<input style="-webkit-appearance:none;padding: 4px;background: #e91e63;border-radius: 5px;color: white;" type="submit" value="15-3(慎)" /> <input style="-webkit-appearance:none;padding: 4px;background: #e91e63;border-radius: 5px;color: white;" type="submit" value="15-3(慎)" />
</form> </form>
<!--仓库--> <!--仓库-->
<form id="wh-translate-quick" action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="11"> <input name="nervetake" type="hidden" value="11">
<input name="crime" type="hidden" value="warehouse"> <input name="crime" type="hidden" value="warehouse">
<input style="-webkit-appearance:none;padding: 4px;background: #2196f3;border-radius: 5px;color: white;" type="submit" value="烧仓库" /> <input style="-webkit-appearance:none;padding: 4px;background: #2196f3;border-radius: 5px;color: white;" type="submit" value="烧仓库" />
</form> </form>
<!--7-2--> <!--7-2-->
<form id="wh-translate-quick" action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="7"> <input name="nervetake" type="hidden" value="7">
<input name="crime" type="hidden" value="thoroughrobbery"> <input name="crime" type="hidden" value="thoroughrobbery">
<input style="-webkit-appearance:none;padding: 4px;background: #2196f3;border-radius: 5px;color: white;" type="submit" value="7-2(仅过渡用)" /> <input style="-webkit-appearance:none;padding: 4px;background: #2196f3;border-radius: 5px;color: white;" type="submit" value="7-2(仅过渡用)" />
</form> </form>
<!--偷夹克--> <!--偷夹克-->
<form id="wh-translate-quick" action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime4" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="4"> <input name="nervetake" type="hidden" value="4">
<input name="crime" type="hidden" value="jacket"> <input name="crime" type="hidden" value="jacket">
<input style="-webkit-appearance:none;padding: 4px;background: #009688;border-radius: 5px;color: white;" type="submit" value="偷夹克" /> <input style="-webkit-appearance:none;padding: 4px;background: #009688;border-radius: 5px;color: white;" type="submit" value="偷夹克" />
</form> </form>
<!--卖碟3-1--> <!--卖碟3-1-->
<form id="wh-translate-quick" action="crimes.php?step=docrime2" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime2" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="3"> <input name="nervetake" type="hidden" value="3">
<input name="crime" type="hidden" value="cdrock"> <input name="crime" type="hidden" value="cdrock">
<input style="-webkit-appearance:none;padding: 4px;background: #009688;border-radius: 5px;color: white;" type="submit" value="卖碟" /> <input style="-webkit-appearance:none;padding: 4px;background: #009688;border-radius: 5px;color: white;" type="submit" value="卖碟" />
</form> </form>
<!--捡钱--> <!--捡钱-->
<form id="wh-translate-quick" action="crimes.php?step=docrime2" method="post" style="display: inline-block;margin: 0 5px"> <form action="crimes.php?step=docrime2" method="post" style="display: inline-block;margin: 0 5px">
<input name="nervetake" type="hidden" value="2"> <input name="nervetake" type="hidden" value="2">
<input name="crime" type="hidden" value="searchtrainstation"> <input name="crime" type="hidden" value="searchtrainstation">
<input style="-webkit-appearance:none;padding: 4px;background: #009688;border-radius: 5px;color: white;" type="submit" value="捡钱" /> <input style="-webkit-appearance:none;padding: 4px;background: #009688;border-radius: 5px;color: white;" type="submit" value="捡钱" />
@ -10162,7 +10190,6 @@ z-index:100001;
stop.innerHTML = '关闭'; stop.innerHTML = '关闭';
stop.disabled = true; stop.disabled = true;
self_target.innerHTML = '填入自己'; self_target.innerHTML = '填入自己';
// p.innerHTML = '状态:已关';
// 弹出窗口关闭时结束 // 弹出窗口关闭时结束
let popup_close = popup.close; let popup_close = popup.close;
popup.close = () => { popup.close = () => {
@ -10228,7 +10255,7 @@ z-index:100001;
}; };
updateRecordsDOM(); updateRecordsDOM();
}); });
}, 500); }, 900);
}); });
stop.addEventListener('click', () => { stop.addEventListener('click', () => {
@ -10275,5 +10302,10 @@ z-index:100001;
} }
} }
// 边栏信息
function getSidebarData() {
return JSON.parse(document.querySelector('#sidebar_data').innerHTML)
}
$zhongNode.initTimer.innerHTML = `助手加载时间 ${Date.now() - start_timestamp}ms`; $zhongNode.initTimer.innerHTML = `助手加载时间 ${Date.now() - start_timestamp}ms`;
}(); }();