diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js
index 7bd22ae..6db269d 100644
--- a/torn-trans-zhcn.user.js
+++ b/torn-trans-zhcn.user.js
@@ -1,8 +1,8 @@
// ==UserScript==
-// @lastmodified 202112220130
+// @lastmodified 202112221455
// @name Torn翻译
// @namespace WOOH
-// @version 0.1.1222a
+// @version 0.1.1222b
// @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.1222b',
+ date: '20211222',
+ cont: `添加了圣诞小镇有掉落物时的声音效果`,
+ },
{
ver: '0.1.1222a',
date: '20211222',
@@ -5472,69 +5477,78 @@ margin: 0 0 3px;
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');
+ let $wh_loot_container = $root.querySelector('#wh-loot-container');
if (!$wh_loot_container) {
const insert_html = `
+
附近物品
-
-`;
+}
+`;
$($city_wrapper).before(insert_html);
+ $wh_loot_container = $root.querySelector('#wh-loot-container');
}
- let item_list = [];
+ const $audio = $wh_loot_container.querySelector('audio');
+ const nearby_arr = [];
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
// 附近的所有物品
- items.forEach(e => {
+ items.forEach(el => {
const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
- item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30;
- item_props.y = -parseInt(e.style.top.replaceAll('px', '')) / 30;
- const srcSpl = e.firstElementChild.src.trim().split('/');
+ item_props.x = parseInt(el.style.left.replaceAll('px', '')) / 30;
+ item_props.y = -parseInt(el.style.top.replaceAll('px', '')) / 30;
+ item_props.url = el.firstElementChild.src;
+ const srcSpl = item_props.url.trim().split('/');
item_props.name = srcSpl[6];
item_props.type = srcSpl[8].slice(0, 1);
- item_props.url = e.firstElementChild.src;
- item_list[item_list.length] = item_props;
+ nearby_arr.push(item_props);
});
- const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
- const $wh_loot_container_chests = $root.querySelector('#wh-loot-container-chests');
+ const $wh_loot_container_items = $wh_loot_container.querySelector('#wh-loot-container-items');
+ const $wh_loot_container_chests = $wh_loot_container.querySelector('#wh-loot-container-chests');
let item_count = 0, chest_count = 0;
- 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.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') {
+ $wh_loot_container_items.innerHTML = ``;
+ $wh_loot_container_chests.innerHTML = ``;
+ nearby_arr.forEach(nearby_item => {
+ let path = '=';
+ 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 = '↖';
+ 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 = '→';
+ 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 = '↓';
+ if (nearby_item.name === 'chests') {
chest_count++;
- $wh_loot_container_chests.innerHTML += `
${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}
`
+ $wh_loot_container_chests.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${chestTypeDict[nearby_item.type]}${lootTypeDict[nearby_item.name]}
`
} else {
item_count++;
- $wh_loot_container_items.innerHTML += `
${path}[${e.x},${e.y}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}
`
+ $wh_loot_container_items.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${nearby_item.name === 'keys' ? keyTypeDict[nearby_item.type] || '' : ''}${lootTypeDict[nearby_item.name] || nearby_item.name}
`
}
});
- $root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
+ $wh_loot_container.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
if (item_count === 0) {
$wh_loot_container_items.innerText = `暂无`;
- $root.querySelector('#wh-loot-container-main').style.animation ='';
+ $wh_loot_container.querySelector('#wh-loot-container-main').style.animation = '';
} else {
- $root.querySelector('#wh-loot-container-main').style.animation = 'lootFoundAlert 2s infinite';
+ $wh_loot_container.querySelector('#wh-loot-container-main').style.animation = 'lootFoundAlert 2s infinite';
+ $audio.play().then();
}
- $root.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
+ $wh_loot_container.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
}
}, 1200);
diff --git a/torn-wh-show-loot-pos.user.js b/torn-wh-show-loot-pos.user.js
index d17854d..896c507 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.1
+// @version 0.2.2
// @description 在地图界面上方显示附近的宝箱、物品、钥匙坐标,兼容手机APP Torn PDA及Alook
// @author Woohoo[2687093]
// @match https://www.torn.com/*
@@ -32,58 +32,78 @@
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');
+ let $wh_loot_container = $root.querySelector('#wh-loot-container');
if (!$wh_loot_container) {
const insert_html = `
+`;
$($city_wrapper).before(insert_html);
+ $wh_loot_container = $root.querySelector('#wh-loot-container');
}
- let item_list = [];
+ const $audio = $wh_loot_container.querySelector('audio');
+ const nearby_arr = [];
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
// 附近的所有物品
- items.forEach(e => {
+ items.forEach(el => {
const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
- item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30;
- item_props.y = -parseInt(e.style.top.replaceAll('px', '')) / 30;
- const srcSpl = e.firstElementChild.src.trim().split('/');
+ item_props.x = parseInt(el.style.left.replaceAll('px', '')) / 30;
+ item_props.y = -parseInt(el.style.top.replaceAll('px', '')) / 30;
+ item_props.url = el.firstElementChild.src;
+ const srcSpl = item_props.url.trim().split('/');
item_props.name = srcSpl[6];
item_props.type = srcSpl[8].slice(0, 1);
- item_props.url = e.firstElementChild.src;
- item_list[item_list.length] = item_props;
+ nearby_arr.push(item_props);
});
- const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
- const $wh_loot_container_chests = $root.querySelector('#wh-loot-container-chests');
+ const $wh_loot_container_items = $wh_loot_container.querySelector('#wh-loot-container-items');
+ const $wh_loot_container_chests = $wh_loot_container.querySelector('#wh-loot-container-chests');
let item_count = 0, chest_count = 0;
- 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.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') {
+ $wh_loot_container_items.innerHTML = ``;
+ $wh_loot_container_chests.innerHTML = ``;
+ nearby_arr.forEach(nearby_item => {
+ let path = '=';
+ 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 = '↖';
+ 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 = '→';
+ 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 = '↓';
+ if (nearby_item.name === 'chests') {
chest_count++;
- $wh_loot_container_chests.innerHTML += `
${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}
`
+ $wh_loot_container_chests.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${chestTypeDict[nearby_item.type]}${lootTypeDict[nearby_item.name]}
`
} else {
item_count++;
- $wh_loot_container_items.innerHTML += `
${path}[${e.x},${e.y}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}
`
+ $wh_loot_container_items.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${nearby_item.name === 'keys' ? keyTypeDict[nearby_item.type] || '' : ''}${lootTypeDict[nearby_item.name] || nearby_item.name}
`
}
});
- $root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
- if (item_count === 0) $wh_loot_container_items.innerText = `暂无`;
- $root.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
+ $wh_loot_container.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
+ if (item_count === 0) {
+ $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();
+ }
+ $wh_loot_container.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
}
}, 1200);