修复了圣诞小镇物品掉落名称不全的问题

This commit is contained in:
woohoo 2021-12-21 21:45:52 +08:00
parent 9d0b1c4c14
commit 058bbd8c8e
2 changed files with 40 additions and 31 deletions

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @lastmodified 202112211252 // @lastmodified 202112212145
// @name Torn翻译 // @name Torn翻译
// @namespace WOOH // @namespace WOOH
// @version 0.1.1221a // @version 0.1.1221b
// @description Torn UI翻译 // @description Torn UI翻译
// @author Woohoo-[2687093] sabrina_devil[2696209] // @author Woohoo-[2687093] sabrina_devil[2696209]
// @match https://www.torn.com/* // @match https://www.torn.com/*
@ -23,6 +23,11 @@
todo: true, todo: true,
cont: `baza npc商店 imarket及imarket搜索结果`, cont: `baza npc商店 imarket及imarket搜索结果`,
}, },
{
ver: '0.1.1221b',
date: '20211221',
cont: `修复了圣诞小镇物品掉落名称不全的问题`,
},
{ {
ver: '0.1.1221a', ver: '0.1.1221a',
date: '20211221', date: '20211221',
@ -5450,7 +5455,8 @@ margin: 0 0 3px;
// 宝箱检测 // 宝箱检测
const chestTypeDict = {'1': '金', '2': '银', '3': '铜',}; const chestTypeDict = {'1': '金', '2': '银', '3': '铜',};
const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',}; 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 intervalID = window.setInterval(() => {
const $city_wrapper = $root.querySelector('#ct-wrap'); const $city_wrapper = $root.querySelector('#ct-wrap');
if ($city_wrapper) { if ($city_wrapper) {
@ -5475,6 +5481,7 @@ margin: 0 0 3px;
} }
let item_list = []; let item_list = [];
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item'); const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
// 附近的所有物品
items.forEach(e => { items.forEach(e => {
const item_props = {x: 0, y: 0, name: '', type: '', url: '',}; const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30; item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30;
@ -5493,25 +5500,25 @@ margin: 0 0 3px;
item_list.forEach(e => { item_list.forEach(e => {
let path = '·'; 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 = '←'; else 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 = '↖';
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.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.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.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.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') { if (e.name === 'chests') {
chest_count++; chest_count++;
$wh_loot_container_chests.innerHTML += `<span style="display: inline-block;background-color: ${chestTypeColorDict[e.type] || 'silver'};color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>` $wh_loot_container_chests.innerHTML += `<span style="display: inline-block;background-color: ${chestTypeColorDict[e.type] || 'silver'};color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`
} else { } else {
item_count++; item_count++;
$wh_loot_container_items.innerHTML += `<span style="display: inline-block;background-color: #2e8b57;color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${lootTypeDict[e.name] || '?钥匙'}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>` $wh_loot_container_items.innerHTML += `<span style="display: inline-block;background-color: #2e8b57;color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`
} }
}); });
$root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`; $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})`; $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); }, 1200);
return; return;

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Torn圣诞小镇掉落物品坐标显示 // @name Torn圣诞小镇掉落物品坐标显示
// @namespace WH // @namespace WH
// @version 0.2 // @version 0.2.1
// @description 在地图界面上方显示附近的宝箱、物品、钥匙坐标兼容手机APP Torn PDA及Alook // @description 在地图界面上方显示附近的宝箱、物品、钥匙坐标兼容手机APP Torn PDA及Alook
// @author Woohoo[2687093] // @author Woohoo[2687093]
// @match https://www.torn.com/* // @match https://www.torn.com/*
@ -21,16 +21,17 @@
const $root = document.querySelector('#christmastownroot'); const $root = document.querySelector('#christmastownroot');
const chestTypeDict = {'1': '金', '2': '银', '3': '铜',}; const chestTypeDict = {'1': '金', '2': '银', '3': '铜',};
const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',}; 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 intervalID = window.setInterval(() => {
const $city_wrapper = $root.querySelector('#ct-wrap'); const $city_wrapper = $root.querySelector('#ct-wrap');
if ($city_wrapper) { if ($city_wrapper) {
const $pos = $city_wrapper.querySelector('.map-title span[class^="position___"]') || $city_wrapper.querySelector('.status-title span[class^="position___"]'); 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 $pos_spl = $pos.innerText.trim().split(',');
const player_position={}; const player_position = {};
player_position.x=parseInt($pos_spl[0]); player_position.x = parseInt($pos_spl[0]);
player_position.y=parseInt($pos_spl[1]); player_position.y = parseInt($pos_spl[1]);
const $wh_loot_container = $root.querySelector('#wh-loot-container'); const $wh_loot_container = $root.querySelector('#wh-loot-container');
if (!$wh_loot_container) { if (!$wh_loot_container) {
const insert_html = `<div id="wh-loot-container" class="m-bottom10"> const insert_html = `<div id="wh-loot-container" class="m-bottom10">
@ -46,6 +47,7 @@
} }
let item_list = []; let item_list = [];
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item'); const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
// 附近的所有物品
items.forEach(e => { items.forEach(e => {
const item_props = {x: 0, y: 0, name: '', type: '', url: '',}; const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30; 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_items) $wh_loot_container_items.innerHTML = ``;
if ($wh_loot_container_chests) $wh_loot_container_chests.innerHTML = ``; if ($wh_loot_container_chests) $wh_loot_container_chests.innerHTML = ``;
item_list.forEach(e => { item_list.forEach(e => {
let path='·'; 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='←'; else 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 = '↖';
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.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.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.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.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') { if (e.name === 'chests') {
chest_count++; chest_count++;
$wh_loot_container_chests.innerHTML += `<span style="display: inline-block;background-color: ${chestTypeColorDict[e.type] || 'silver'};color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>` $wh_loot_container_chests.innerHTML += `<span style="display: inline-block;background-color: ${chestTypeColorDict[e.type] || 'silver'};color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`
} else { } else {
item_count++; item_count++;
$wh_loot_container_items.innerHTML += `<span style="display: inline-block;background-color: #2e8b57;color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${lootTypeDict[e.name] || '?钥匙'}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>` $wh_loot_container_items.innerHTML += `<span style="display: inline-block;background-color: #2e8b57;color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`
} }
}); });
$root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`; $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})`; $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); }, 1200);
} }