From 058bbd8c8e1f25a9718c8c9b6f629c95345a4b71 Mon Sep 17 00:00:00 2001 From: woohoo Date: Tue, 21 Dec 2021 21:45:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=9C=A3=E8=AF=9E?= =?UTF-8?q?=E5=B0=8F=E9=95=87=E7=89=A9=E5=93=81=E6=8E=89=E8=90=BD=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=8D=E5=85=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 33 ++++++++++++++++++------------ torn-wh-show-loot-pos.user.js | 38 ++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index a84872a..09a5df0 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -1,8 +1,8 @@ // ==UserScript== -// @lastmodified 202112211252 +// @lastmodified 202112212145 // @name Torn翻译 // @namespace WOOH -// @version 0.1.1221a +// @version 0.1.1221b // @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.1221b', + date: '20211221', + cont: `修复了圣诞小镇物品掉落名称不全的问题`, + }, { ver: '0.1.1221a', date: '20211221', @@ -5450,7 +5455,8 @@ margin: 0 0 3px; // 宝箱检测 const chestTypeDict = {'1': '金', '2': '银', '3': '铜',}; const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',}; - const lootTypeDict = {'chests': '宝箱', 'gifts': '礼物箱',} + const lootTypeDict = {'chests': '钥匙箱', 'gifts': '礼物', 'combinationChest': '密码箱', 'keys': '钥匙',}; + const keyTypeDict = {'b': '铜', 's': '银', 'g': '金',}; const intervalID = window.setInterval(() => { const $city_wrapper = $root.querySelector('#ct-wrap'); if ($city_wrapper) { @@ -5475,6 +5481,7 @@ margin: 0 0 3px; } let item_list = []; const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item'); + // 附近的所有物品 items.forEach(e => { const item_props = {x: 0, y: 0, name: '', type: '', url: '',}; item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30; @@ -5493,25 +5500,25 @@ margin: 0 0 3px; item_list.forEach(e => { let path = '·'; if (e.x < player_position.x && e.y < player_position.y) path = '↙'; - if (e.x < player_position.x && e.y === player_position.y) path = '←'; - if (e.x < player_position.x && e.y > player_position.y) path = '↖'; - if (e.x === player_position.x && e.y > player_position.y) path = '↑'; - if (e.x > player_position.x && e.y > player_position.y) path = '↗'; - if (e.x > player_position.x && e.y === player_position.y) path = '→'; - if (e.x > player_position.x && e.y < player_position.y) path = '↘'; - if (e.x === player_position.x && e.y < player_position.y) path = '↓'; + else if (e.x < player_position.x && e.y === player_position.y) path = '←'; + else if (e.x < player_position.x && e.y > player_position.y) path = '↖'; + else if (e.x === player_position.x && e.y > player_position.y) path = '↑'; + else if (e.x > player_position.x && e.y > player_position.y) path = '↗'; + else if (e.x > player_position.x && e.y === player_position.y) path = '→'; + else if (e.x > player_position.x && e.y < player_position.y) path = '↘'; + else if (e.x === player_position.x && e.y < player_position.y) path = '↓'; if (e.name === 'chests') { chest_count++; $wh_loot_container_chests.innerHTML += `${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}` } else { item_count++; - $wh_loot_container_items.innerHTML += `${path}[${e.x},${e.y}] - ${lootTypeDict[e.name] || '?钥匙'}` + $wh_loot_container_items.innerHTML += `${path}[${e.x},${e.y}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}` } }); $root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`; - if (item_count === 0) $wh_loot_container_items.innerText = `暂未发现`; + if (item_count === 0) $wh_loot_container_items.innerText = `暂无`; $root.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`; - if (chest_count === 0) $wh_loot_container_chests.innerText = `暂未发现`; + if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`; } }, 1200); return; diff --git a/torn-wh-show-loot-pos.user.js b/torn-wh-show-loot-pos.user.js index cb85dd1..d17854d 100644 --- a/torn-wh-show-loot-pos.user.js +++ b/torn-wh-show-loot-pos.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Torn圣诞小镇掉落物品坐标显示 // @namespace WH -// @version 0.2 +// @version 0.2.1 // @description 在地图界面上方显示附近的宝箱、物品、钥匙坐标,兼容手机APP Torn PDA及Alook // @author Woohoo[2687093] // @match https://www.torn.com/* @@ -21,16 +21,17 @@ const $root = document.querySelector('#christmastownroot'); const chestTypeDict = {'1': '金', '2': '银', '3': '铜',}; const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',}; - const lootTypeDict = {'chests': '宝箱', 'gifts': '礼物箱',} + const lootTypeDict = {'chests': '钥匙箱', 'gifts': '礼物', 'combinationChest': '密码箱', 'keys': '钥匙',}; + const keyTypeDict = {'b': '铜', 's': '银', 'g': '金',}; const intervalID = window.setInterval(() => { const $city_wrapper = $root.querySelector('#ct-wrap'); if ($city_wrapper) { const $pos = $city_wrapper.querySelector('.map-title span[class^="position___"]') || $city_wrapper.querySelector('.status-title span[class^="position___"]'); - if(!$pos) return; + if (!$pos) return; const $pos_spl = $pos.innerText.trim().split(','); - const player_position={}; - player_position.x=parseInt($pos_spl[0]); - player_position.y=parseInt($pos_spl[1]); + const player_position = {}; + player_position.x = parseInt($pos_spl[0]); + player_position.y = parseInt($pos_spl[1]); const $wh_loot_container = $root.querySelector('#wh-loot-container'); if (!$wh_loot_container) { const insert_html = `
@@ -46,6 +47,7 @@ } let item_list = []; const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item'); + // 附近的所有物品 items.forEach(e => { const item_props = {x: 0, y: 0, name: '', type: '', url: '',}; item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30; @@ -62,27 +64,27 @@ if ($wh_loot_container_items) $wh_loot_container_items.innerHTML = ``; if ($wh_loot_container_chests) $wh_loot_container_chests.innerHTML = ``; item_list.forEach(e => { - let path='·'; - if (e.xplayer_position.y) path='↖'; - if (e.x===player_position.x&&e.y>player_position.y) path='↑'; - if (e.x>player_position.x&&e.y>player_position.y) path='↗'; - if (e.x>player_position.x&&e.y===player_position.y) path='→'; - if (e.x>player_position.x&&e.y player_position.y) path = '↖'; + else if (e.x === player_position.x && e.y > player_position.y) path = '↑'; + else if (e.x > player_position.x && e.y > player_position.y) path = '↗'; + else if (e.x > player_position.x && e.y === player_position.y) path = '→'; + else if (e.x > player_position.x && e.y < player_position.y) path = '↘'; + else if (e.x === player_position.x && e.y < player_position.y) path = '↓'; if (e.name === 'chests') { chest_count++; $wh_loot_container_chests.innerHTML += `${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}` } else { item_count++; - $wh_loot_container_items.innerHTML += `${path}[${e.x},${e.y}] - ${lootTypeDict[e.name] || '?钥匙'}` + $wh_loot_container_items.innerHTML += `${path}[${e.x},${e.y}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}` } }); $root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`; - if (item_count === 0) $wh_loot_container_items.innerText = `暂未发现`; + if (item_count === 0) $wh_loot_container_items.innerText = `暂无`; $root.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`; - if (chest_count === 0) $wh_loot_container_chests.innerText = `暂未发现`; + if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`; } }, 1200); }