增加了小镇提示选项和历史记录
This commit is contained in:
parent
8e2c250b1d
commit
dcefc6b164
@ -1,8 +1,8 @@
|
||||
// ==UserScript==
|
||||
// @lastmodified 202112221455
|
||||
// @lastmodified 202112232309
|
||||
// @name Torn翻译
|
||||
// @namespace WOOH
|
||||
// @version 0.1.1222b
|
||||
// @version 0.1.1223a
|
||||
// @description Torn UI翻译
|
||||
// @author Woohoo-[2687093] sabrina_devil[2696209]
|
||||
// @match https://www.torn.com/*
|
||||
@ -23,6 +23,11 @@
|
||||
todo: true,
|
||||
cont: `baza npc商店 imarket及imarket搜索结果`,
|
||||
},
|
||||
{
|
||||
ver: '0.1.1223a',
|
||||
date: '20211223',
|
||||
cont: `增加了小镇提示选项和历史记录`,
|
||||
},
|
||||
{
|
||||
ver: '0.1.1222b',
|
||||
date: '20211222',
|
||||
@ -5166,7 +5171,7 @@
|
||||
// 解密攻略
|
||||
const insert_html = `<div id="wh-xmas-cont">
|
||||
<div class="title-black"><span>水晶球解密地图攻略</span><span><button style="color: white">[隐藏]</button></span></div>
|
||||
<div class="cont-gray">
|
||||
<div class="cont-gray select-wrap dropdown-new dropdown-default">
|
||||
<select>
|
||||
<option value="None">未选择</option>
|
||||
<option value="Christmas Town">Christmas Town</option>
|
||||
@ -5468,9 +5473,18 @@ margin: 0 0 3px;
|
||||
const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',};
|
||||
const lootTypeDict = {'chests': '钥匙箱', 'gifts': '礼物', 'combinationChest': '密码箱', 'keys': '钥匙',};
|
||||
const keyTypeDict = {'b': '铜', 's': '银', 'g': '金',};
|
||||
const dropHist = localStorage.getItem('wh-loot-store')
|
||||
? JSON.parse(localStorage.getItem('wh-loot-store'))
|
||||
: {};
|
||||
const alertSettings = localStorage.getItem('wh-loot-setting')
|
||||
? JSON.parse(localStorage.getItem('wh-loot-setting'))
|
||||
: {blink: 'y', sound: 'y'};
|
||||
let onClickBind = false;
|
||||
|
||||
const intervalID = window.setInterval(() => {
|
||||
const $city_wrapper = $root.querySelector('#ct-wrap');
|
||||
if ($city_wrapper) {
|
||||
const $ct_title = $city_wrapper.querySelector('.status-title');
|
||||
const $pos = $city_wrapper.querySelector('.map-title span[class^="position___"]') || $city_wrapper.querySelector('.status-title span[class^="position___"]');
|
||||
if (!$pos) return;
|
||||
const $pos_spl = $pos.innerText.trim().split(',');
|
||||
@ -5488,12 +5502,37 @@ margin: 0 0 3px;
|
||||
<b>箱子</b><span id="wh-loot-chest-count"></span>
|
||||
<div id="wh-loot-container-chests"></div>
|
||||
</div>
|
||||
<div id="wh-loot-container-ex" class="cont-gray wh-hide">
|
||||
<div><input type="checkbox" id="wh-loot-setting-blink" ${alertSettings.blink === 'y' ? 'checked' : ''} /><label for="wh-loot-setting-blink">闪烁提示</label></div>
|
||||
<div><input type="checkbox" id="wh-loot-setting-sound" ${alertSettings.sound === 'y' ? 'checked' : ''} /><label for="wh-loot-setting-sound">声音提示(不支持iOS)</label></div>
|
||||
<div>
|
||||
<table><thead><tr><th colspan="5">历史记录</th></tr><tr><th>坐标</th><th>地图</th><th>类型</th><th>时间</th><th>获取</th></tr></thead><tbody></tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="wh-loot-btn" class="cont-gray"><button>设置</button></div>
|
||||
</div>
|
||||
<style>
|
||||
#wh-loot-container-main{padding: 0.5em;}
|
||||
#wh-loot-container-main div{overflow-x: auto;overflow-y: hidden;white-space: nowrap;min-height: 4em;}
|
||||
#wh-loot-container-main div span{display: inline-block;background-color: #2e8b57;color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;}
|
||||
#wh-loot-container-main div span img{height: 1em; width: 1em;}
|
||||
#wh-loot-container-ex{padding: 0.5em;}
|
||||
#wh-loot-container-ex.wh-hide{display: none;}
|
||||
#wh-loot-container-ex table {margin-top: 0.5em;}
|
||||
#wh-loot-container-ex table, #wh-loot-container-ex th, #wh-loot-container-ex td {
|
||||
padding: 5px;
|
||||
border: 1px solid black;
|
||||
height: auto;
|
||||
}
|
||||
#wh-loot-container-ex th:nth-child(1) {min-width: 5em;}
|
||||
#wh-loot-container-ex th:nth-child(2) {min-width: 8em;}
|
||||
#wh-loot-container-ex th:nth-child(3) {min-width: 4em;}
|
||||
#wh-loot-container-ex th:nth-child(4) {min-width: 9em;}
|
||||
#wh-loot-container-ex th:nth-child(5) {min-width: 3em;}
|
||||
#wh-loot-container-ex thead {
|
||||
background-color: #2e8b57;
|
||||
color: white;
|
||||
}
|
||||
@keyframes lootFoundAlert {
|
||||
0% {background: #f2f2f2}
|
||||
50% {background: #2e8b57}
|
||||
@ -5504,6 +5543,19 @@ margin: 0 0 3px;
|
||||
$wh_loot_container = $root.querySelector('#wh-loot-container');
|
||||
}
|
||||
const $audio = $wh_loot_container.querySelector('audio');
|
||||
const $blink = $wh_loot_container.querySelector('#wh-loot-setting-blink');
|
||||
alertSettings.blink = $blink.checked ? 'y' : 'n';
|
||||
const $sound = $wh_loot_container.querySelector('#wh-loot-setting-sound');
|
||||
alertSettings.sound = $sound.checked ? 'y' : 'n';
|
||||
const $ex = $wh_loot_container.querySelector('#wh-loot-container-ex');
|
||||
const $btn = $wh_loot_container.querySelector('#wh-loot-btn button');
|
||||
const $tbody = $wh_loot_container.querySelector('tbody');
|
||||
if (!onClickBind) $btn.onclick = (e) => {
|
||||
e.target.innerText = e.target.innerText === '设置' ? '收起' : '设置';
|
||||
$($ex).toggleClass('wh-hide');
|
||||
onClickBind = true;
|
||||
e.target.blur();
|
||||
};
|
||||
const nearby_arr = [];
|
||||
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
|
||||
// 附近的所有物品
|
||||
@ -5532,12 +5584,34 @@ margin: 0 0 3px;
|
||||
else if (nearby_item.x > player_position.x && nearby_item.y === player_position.y) path = '→';
|
||||
else if (nearby_item.x > player_position.x && nearby_item.y < player_position.y) path = '↘';
|
||||
else if (nearby_item.x === player_position.x && nearby_item.y < player_position.y) path = '↓';
|
||||
let item_name;
|
||||
if (nearby_item.name === 'chests') {
|
||||
chest_count++;
|
||||
$wh_loot_container_chests.innerHTML += `<span style="background-color: ${chestTypeColorDict[nearby_item.type] || 'silver'};">${path}[${nearby_item.x},${nearby_item.y}] ${chestTypeDict[nearby_item.type]}${lootTypeDict[nearby_item.name]}<img src="${nearby_item.url}" /></span>`
|
||||
item_name = chestTypeDict[nearby_item.type] + lootTypeDict[nearby_item.name];
|
||||
$wh_loot_container_chests.innerHTML += `<span style="background-color: ${chestTypeColorDict[nearby_item.type] || 'silver'};">${path}[${nearby_item.x},${nearby_item.y}] ${item_name}<img src="${nearby_item.url}" /></span>`
|
||||
} else {
|
||||
item_count++;
|
||||
$wh_loot_container_items.innerHTML += `<span>${path}[${nearby_item.x},${nearby_item.y}] ${nearby_item.name === 'keys' ? keyTypeDict[nearby_item.type] || '' : ''}${lootTypeDict[nearby_item.name] || nearby_item.name}<img src="${nearby_item.url}" /></span>`
|
||||
item_name = (nearby_item.name === 'keys' ? keyTypeDict[nearby_item.type] || '' : '') + lootTypeDict[nearby_item.name] || nearby_item.name;
|
||||
$wh_loot_container_items.innerHTML += `<span>${path}[${nearby_item.x},${nearby_item.y}] ${item_name}<img src="${nearby_item.url}" /></span>`
|
||||
}
|
||||
if ($ct_title) {
|
||||
const now = new Date();
|
||||
const hist_key = `[${nearby_item.x},${nearby_item.y}]"${$ct_title.firstChild.nodeValue.trim()}"`;
|
||||
const el = dropHist[hist_key];
|
||||
if (el) {
|
||||
if (nearby_item.x === player_position.x && nearby_item.y === player_position.y && nearby_item.name !== ('chests' || 'combinationChest')) {
|
||||
el.isPassed = true;
|
||||
}
|
||||
el.last = `${now.getFullYear()}-${now.getMonth()}-${now.getDay()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
|
||||
} else {
|
||||
dropHist[hist_key] = {
|
||||
pos: `[${nearby_item.x},${nearby_item.y}]`,
|
||||
map: $ct_title.firstChild.nodeValue.trim(),
|
||||
last: `${now.getFullYear()}-${now.getMonth()}-${now.getDay()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`,
|
||||
name: item_name,
|
||||
id: Object.keys(dropHist).length,
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
$wh_loot_container.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
|
||||
@ -5545,11 +5619,21 @@ margin: 0 0 3px;
|
||||
$wh_loot_container_items.innerText = `暂无`;
|
||||
$wh_loot_container.querySelector('#wh-loot-container-main').style.animation = '';
|
||||
} else {
|
||||
$wh_loot_container.querySelector('#wh-loot-container-main').style.animation = 'lootFoundAlert 2s infinite';
|
||||
$audio.play().then();
|
||||
if ($blink.checked) $wh_loot_container.querySelector('#wh-loot-container-main').style.animation = 'lootFoundAlert 2s infinite';
|
||||
if ($sound.checked) $audio.play().then();
|
||||
}
|
||||
$wh_loot_container.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
|
||||
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
|
||||
|
||||
const history = Object.keys(dropHist).map(key => dropHist[key]).sort((a, b) => a.id - b.id);
|
||||
let table_html = ``;
|
||||
history.forEach(e => {
|
||||
table_html += `<tr><td>${e.pos}</td><td>${e.map}</td><td>${e.name}</td><td>${e.last}</td><td>${e.isPassed ? '已取得' : '不确定'}</td></tr>`;
|
||||
});
|
||||
$tbody.innerHTML = table_html;
|
||||
|
||||
localStorage.setItem('wh-loot-store', JSON.stringify(dropHist));
|
||||
localStorage.setItem('wh-loot-setting', JSON.stringify(alertSettings));
|
||||
}
|
||||
}, 1200);
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user