修复价格监视bug,修改css样式

This commit is contained in:
woohoo 2022-03-09 00:29:51 +08:00
parent c818730095
commit 5fb2133ce0

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @lastmodified 202203081723 // @lastmodified 202203090029
// @name 芜湖助手 // @name 芜湖助手
// @namespace WOOH // @namespace WOOH
// @version 0.3.24 // @version 0.3.25
// @description 托恩,起飞! // @description 托恩,起飞!
// @author Woohoo[2687093] Sabrina_Devil[2696209] // @author Woohoo[2687093] Sabrina_Devil[2696209]
// @match https://www.torn.com/* // @match https://www.torn.com/*
@ -23,13 +23,18 @@
if (window.WHTRANS) return; if (window.WHTRANS) return;
window.WHTRANS = true; window.WHTRANS = true;
// 版本 // 版本
const version = '0.3.24'; const version = '0.3.25';
// 修改历史 // 修改历史
const changelist = [ const changelist = [
{ {
todo: true, todo: true,
cont: `翻译baza npc商店、imarket、imarket搜索结果`, cont: `翻译baza npc商店、imarket、imarket搜索结果`,
}, },
{
ver: '0.3.25',
date: '20220309',
cont: `修复价格监视bug修改css样式`,
},
{ {
ver: '0.3.24', ver: '0.3.24',
date: '20220308', date: '20220308',
@ -3836,6 +3841,7 @@ height:30px;
domText: '价格监视', domText: '价格监视',
clickFunc: function () { clickFunc: function () {
const watcher_conf = getWhSettingObj()['priceWatcher']; const watcher_conf = getWhSettingObj()['priceWatcher'];
const pre_str = JSON.stringify(watcher_conf);
const html = `<style> const html = `<style>
#wh-popup-cont input{width:12em;} #wh-popup-cont input{width:12em;}
#wh-popup-cont input[type="number"]{width:8em;} #wh-popup-cont input[type="number"]{width:8em;}
@ -3847,14 +3853,16 @@ height:30px;
</p> </p>
<p><b>PT</b><label> $ <input type="number" value="${watcher_conf['pt'] || -1}" /></label></p> <p><b>PT</b><label> $ <input type="number" value="${watcher_conf['pt'] || -1}" /></label></p>
<p><b>XAN</b><label> $ <input type="number" value="${watcher_conf['xan'] || -1}" /></label></p> <p><b>XAN</b><label> $ <input type="number" value="${watcher_conf['xan'] || -1}" /></label></p>
<p><button>确定</button></p>
`; `;
const popup = popupMsg(html, '价格监视设置', () => { const popup = popupMsg(html, '价格监视设置');
const pre_str = JSON.stringify(watcher_conf); popup.querySelector('button').onclick = () => {
const [pt_node, xan_node] = popup.querySelectorAll('input[type="number"]'); const [pt_node, xan_node] = popup.querySelectorAll('input[type="number"]');
watcher_conf.pt = pt_node.value | 0; watcher_conf.pt = pt_node.value | 0;
watcher_conf.xan = xan_node.value | 0; watcher_conf.xan = xan_node.value | 0;
if (JSON.stringify(watcher_conf) !== pre_str) setWhSetting('priceWatcher', watcher_conf) if (JSON.stringify(watcher_conf) !== pre_str) setWhSetting('priceWatcher', watcher_conf);
}); popup.close();
};
} }
}); });
// 危险行为开关⚠️ // 危险行为开关⚠️
@ -4154,6 +4162,7 @@ max-width: 12em;
font-size: 12px; font-size: 12px;
line-height: 14px; line-height: 14px;
} }
#wh-gSettings .wh-tip:hover{display:none !important;}
#wh-trans-icon .wh-container{ #wh-trans-icon .wh-container{
margin:0; margin:0;
padding:0 16px 16px; padding:0 16px 16px;
@ -6710,7 +6719,7 @@ margin: 0 0 3px;
} }
// 弹出窗口 // 弹出窗口
function popupMsg(innerHTML, title = '芜湖助手', callback = doNothing) { function popupMsg(innerHTML, title = '芜湖助手') {
if (hasPopup()) return null; if (hasPopup()) return null;
const popup = document.createElement('div'); const popup = document.createElement('div');
popup.id = 'wh-popup'; popup.id = 'wh-popup';
@ -6719,18 +6728,12 @@ margin: 0 0 3px;
<div id="wh-popup-cont">${innerHTML}</div> <div id="wh-popup-cont">${innerHTML}</div>
</div>`; </div>`;
document.body.append(popup); document.body.append(popup);
const rt = popup.querySelector('#wh-popup-cont');
rt.close = () => popup.remove();
popup.addEventListener('click', e => { popup.addEventListener('click', e => {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
if (e.target === popup) { if (e.target === popup) rt.close();
popup.remove();
callback();
}
}); });
const rt = popup.querySelector('#wh-popup-cont')
rt.close = () => {
popup.remove();
callback();
};
return rt; return rt;
} }