添加了圣诞小镇有掉落物时的声音效果
This commit is contained in:
parent
4e78d137df
commit
8e2c250b1d
@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @lastmodified 202112220130
|
// @lastmodified 202112221455
|
||||||
// @name Torn翻译
|
// @name Torn翻译
|
||||||
// @namespace WOOH
|
// @namespace WOOH
|
||||||
// @version 0.1.1222a
|
// @version 0.1.1222b
|
||||||
// @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.1222b',
|
||||||
|
date: '20211222',
|
||||||
|
cont: `添加了圣诞小镇有掉落物时的声音效果`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ver: '0.1.1222a',
|
ver: '0.1.1222a',
|
||||||
date: '20211222',
|
date: '20211222',
|
||||||
@ -5472,69 +5477,78 @@ margin: 0 0 3px;
|
|||||||
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');
|
let $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">
|
||||||
|
<audio src="https://www.torn.com/js/chat/sounds/Chirp_3.mp3" style="display:none"></audio>
|
||||||
<div class="title-black"><span>附近物品</span></div>
|
<div class="title-black"><span>附近物品</span></div>
|
||||||
<div id="wh-loot-container-main" class="cont-gray" style="">
|
<div id="wh-loot-container-main" class="cont-gray">
|
||||||
<b>物品</b><span id="wh-loot-item-count"></span>
|
<b>物品</b><span id="wh-loot-item-count"></span>
|
||||||
<div id="wh-loot-container-items" style="overflow-x: auto;overflow-y: hidden;white-space: nowrap;min-height: 4em;"></div>
|
<div id="wh-loot-container-items"></div>
|
||||||
<b>箱子</b><span id="wh-loot-chest-count"></span>
|
<b>箱子</b><span id="wh-loot-chest-count"></span>
|
||||||
<div id="wh-loot-container-chests" style="overflow-x: auto;overflow-y: hidden;white-space: nowrap;min-height: 4em;"></div>
|
<div id="wh-loot-container-chests"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<style>#wh-loot-container-main{padding: 0.5em;}
|
<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;}
|
||||||
@keyframes lootFoundAlert {
|
@keyframes lootFoundAlert {
|
||||||
0% {background: #f2f2f2}
|
0% {background: #f2f2f2}
|
||||||
50% {background: #2e8b57}
|
50% {background: #2e8b57}
|
||||||
100% {background: #f2f2f2}
|
100% {background: #f2f2f2}
|
||||||
}</style>`;
|
}
|
||||||
|
</style>`;
|
||||||
$($city_wrapper).before(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');
|
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: '',};
|
const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
|
||||||
item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30;
|
item_props.x = parseInt(el.style.left.replaceAll('px', '')) / 30;
|
||||||
item_props.y = -parseInt(e.style.top.replaceAll('px', '')) / 30;
|
item_props.y = -parseInt(el.style.top.replaceAll('px', '')) / 30;
|
||||||
const srcSpl = e.firstElementChild.src.trim().split('/');
|
item_props.url = el.firstElementChild.src;
|
||||||
|
const srcSpl = item_props.url.trim().split('/');
|
||||||
item_props.name = srcSpl[6];
|
item_props.name = srcSpl[6];
|
||||||
item_props.type = srcSpl[8].slice(0, 1);
|
item_props.type = srcSpl[8].slice(0, 1);
|
||||||
item_props.url = e.firstElementChild.src;
|
nearby_arr.push(item_props);
|
||||||
item_list[item_list.length] = item_props;
|
|
||||||
});
|
});
|
||||||
const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
|
const $wh_loot_container_items = $wh_loot_container.querySelector('#wh-loot-container-items');
|
||||||
const $wh_loot_container_chests = $root.querySelector('#wh-loot-container-chests');
|
const $wh_loot_container_chests = $wh_loot_container.querySelector('#wh-loot-container-chests');
|
||||||
let item_count = 0, chest_count = 0;
|
let item_count = 0, chest_count = 0;
|
||||||
if ($wh_loot_container_items) $wh_loot_container_items.innerHTML = ``;
|
$wh_loot_container_items.innerHTML = ``;
|
||||||
if ($wh_loot_container_chests) $wh_loot_container_chests.innerHTML = ``;
|
$wh_loot_container_chests.innerHTML = ``;
|
||||||
item_list.forEach(e => {
|
nearby_arr.forEach(nearby_item => {
|
||||||
let path = '·';
|
let path = '=';
|
||||||
if (e.x < player_position.x && e.y < player_position.y) path = '↙';
|
if (nearby_item.x < player_position.x && nearby_item.y < player_position.y) path = '↙';
|
||||||
else if (e.x < player_position.x && e.y === player_position.y) path = '←';
|
else if (nearby_item.x < player_position.x && nearby_item.y === player_position.y) path = '←';
|
||||||
else if (e.x < player_position.x && e.y > player_position.y) path = '↖';
|
else if (nearby_item.x < player_position.x && nearby_item.y > player_position.y) path = '↖';
|
||||||
else if (e.x === player_position.x && e.y > player_position.y) path = '↑';
|
else if (nearby_item.x === player_position.x && nearby_item.y > player_position.y) path = '↑';
|
||||||
else if (e.x > player_position.x && e.y > player_position.y) path = '↗';
|
else if (nearby_item.x > player_position.x && nearby_item.y > player_position.y) path = '↗';
|
||||||
else if (e.x > player_position.x && e.y === player_position.y) path = '→';
|
else if (nearby_item.x > player_position.x && nearby_item.y === player_position.y) path = '→';
|
||||||
else if (e.x > player_position.x && e.y < player_position.y) path = '↘';
|
else if (nearby_item.x > player_position.x && nearby_item.y < player_position.y) path = '↘';
|
||||||
else if (e.x === player_position.x && e.y < player_position.y) path = '↓';
|
else if (nearby_item.x === player_position.x && nearby_item.y < player_position.y) path = '↓';
|
||||||
if (e.name === 'chests') {
|
if (nearby_item.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="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>`
|
||||||
} 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}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`
|
$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>`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$root.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
|
$wh_loot_container.querySelector('#wh-loot-item-count').innerText = `(${item_count})`;
|
||||||
if (item_count === 0) {
|
if (item_count === 0) {
|
||||||
$wh_loot_container_items.innerText = `暂无`;
|
$wh_loot_container_items.innerText = `暂无`;
|
||||||
$root.querySelector('#wh-loot-container-main').style.animation ='';
|
$wh_loot_container.querySelector('#wh-loot-container-main').style.animation = '';
|
||||||
} else {
|
} 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 = `暂无`;
|
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
|
||||||
}
|
}
|
||||||
}, 1200);
|
}, 1200);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Torn圣诞小镇掉落物品坐标显示
|
// @name Torn圣诞小镇掉落物品坐标显示
|
||||||
// @namespace WH
|
// @namespace WH
|
||||||
// @version 0.2.1
|
// @version 0.2.2
|
||||||
// @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/*
|
||||||
@ -32,58 +32,78 @@
|
|||||||
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');
|
let $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">
|
||||||
|
<audio src="https://www.torn.com/js/chat/sounds/Chirp_3.mp3" style="display:none"></audio>
|
||||||
<div class="title-black"><span>附近物品</span></div>
|
<div class="title-black"><span>附近物品</span></div>
|
||||||
<div id="wh-loot-container-main" class="cont-gray" style="padding: 0.5em">
|
<div id="wh-loot-container-main" class="cont-gray">
|
||||||
<b>物品</b><span id="wh-loot-item-count"></span>
|
<b>物品</b><span id="wh-loot-item-count"></span>
|
||||||
<div id="wh-loot-container-items" style="overflow-x: auto;overflow-y: hidden;white-space: nowrap;min-height: 4em;"></div>
|
<div id="wh-loot-container-items"></div>
|
||||||
<b>箱子</b><span id="wh-loot-chest-count"></span>
|
<b>箱子</b><span id="wh-loot-chest-count"></span>
|
||||||
<div id="wh-loot-container-chests" style="overflow-x: auto;overflow-y: hidden;white-space: nowrap;min-height: 4em;"></div>
|
<div id="wh-loot-container-chests"></div>
|
||||||
</div>
|
</div>
|
||||||
</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;}
|
||||||
|
@keyframes lootFoundAlert {
|
||||||
|
0% {background: #f2f2f2}
|
||||||
|
50% {background: #2e8b57}
|
||||||
|
100% {background: #f2f2f2}
|
||||||
|
}
|
||||||
|
</style>`;
|
||||||
$($city_wrapper).before(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');
|
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: '',};
|
const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
|
||||||
item_props.x = parseInt(e.style.left.replaceAll('px', '')) / 30;
|
item_props.x = parseInt(el.style.left.replaceAll('px', '')) / 30;
|
||||||
item_props.y = -parseInt(e.style.top.replaceAll('px', '')) / 30;
|
item_props.y = -parseInt(el.style.top.replaceAll('px', '')) / 30;
|
||||||
const srcSpl = e.firstElementChild.src.trim().split('/');
|
item_props.url = el.firstElementChild.src;
|
||||||
|
const srcSpl = item_props.url.trim().split('/');
|
||||||
item_props.name = srcSpl[6];
|
item_props.name = srcSpl[6];
|
||||||
item_props.type = srcSpl[8].slice(0, 1);
|
item_props.type = srcSpl[8].slice(0, 1);
|
||||||
item_props.url = e.firstElementChild.src;
|
nearby_arr.push(item_props);
|
||||||
item_list[item_list.length] = item_props;
|
|
||||||
});
|
});
|
||||||
const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
|
const $wh_loot_container_items = $wh_loot_container.querySelector('#wh-loot-container-items');
|
||||||
const $wh_loot_container_chests = $root.querySelector('#wh-loot-container-chests');
|
const $wh_loot_container_chests = $wh_loot_container.querySelector('#wh-loot-container-chests');
|
||||||
let item_count = 0, chest_count = 0;
|
let item_count = 0, chest_count = 0;
|
||||||
if ($wh_loot_container_items) $wh_loot_container_items.innerHTML = ``;
|
$wh_loot_container_items.innerHTML = ``;
|
||||||
if ($wh_loot_container_chests) $wh_loot_container_chests.innerHTML = ``;
|
$wh_loot_container_chests.innerHTML = ``;
|
||||||
item_list.forEach(e => {
|
nearby_arr.forEach(nearby_item => {
|
||||||
let path = '·';
|
let path = '=';
|
||||||
if (e.x < player_position.x && e.y < player_position.y) path = '↙';
|
if (nearby_item.x < player_position.x && nearby_item.y < player_position.y) path = '↙';
|
||||||
else if (e.x < player_position.x && e.y === player_position.y) path = '←';
|
else if (nearby_item.x < player_position.x && nearby_item.y === player_position.y) path = '←';
|
||||||
else if (e.x < player_position.x && e.y > player_position.y) path = '↖';
|
else if (nearby_item.x < player_position.x && nearby_item.y > player_position.y) path = '↖';
|
||||||
else if (e.x === player_position.x && e.y > player_position.y) path = '↑';
|
else if (nearby_item.x === player_position.x && nearby_item.y > player_position.y) path = '↑';
|
||||||
else if (e.x > player_position.x && e.y > player_position.y) path = '↗';
|
else if (nearby_item.x > player_position.x && nearby_item.y > player_position.y) path = '↗';
|
||||||
else if (e.x > player_position.x && e.y === player_position.y) path = '→';
|
else if (nearby_item.x > player_position.x && nearby_item.y === player_position.y) path = '→';
|
||||||
else if (e.x > player_position.x && e.y < player_position.y) path = '↘';
|
else if (nearby_item.x > player_position.x && nearby_item.y < player_position.y) path = '↘';
|
||||||
else if (e.x === player_position.x && e.y < player_position.y) path = '↓';
|
else if (nearby_item.x === player_position.x && nearby_item.y < player_position.y) path = '↓';
|
||||||
if (e.name === 'chests') {
|
if (nearby_item.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="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>`
|
||||||
} 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}] - ${e.name === 'keys' ? keyTypeDict[e.type] || '' : ''}${lootTypeDict[e.name] || e.name}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`
|
$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>`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$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 = `暂无`;
|
if (item_count === 0) {
|
||||||
$root.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
|
$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 = `暂无`;
|
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
|
||||||
}
|
}
|
||||||
}, 1200);
|
}, 1200);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user