优化了小镇掉落物品的显示样式
This commit is contained in:
parent
8d794d8c66
commit
96713042fe
@ -1,8 +1,8 @@
|
||||
// ==UserScript==
|
||||
// @lastmodified 202112181703
|
||||
// @lastmodified 202112191659
|
||||
// @name Torn翻译
|
||||
// @namespace WOOH
|
||||
// @version 0.1.1218a
|
||||
// @version 0.1.1219a
|
||||
// @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.1219a',
|
||||
date: '20211219',
|
||||
cont: `优化了小镇掉落物品的显示样式`,
|
||||
},
|
||||
{
|
||||
ver: '0.1.1218a',
|
||||
date: '20211218',
|
||||
@ -5132,6 +5137,7 @@
|
||||
contentTitleLinksTransReact();
|
||||
});
|
||||
const $city_wrapper = $root.querySelectorAll('div[class^="core-layout__"]');
|
||||
// 解密攻略
|
||||
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">
|
||||
@ -5431,47 +5437,72 @@ margin: 0 0 3px;
|
||||
});
|
||||
}
|
||||
});
|
||||
// 宝箱检测
|
||||
const chestTypeDict = {'1': '金', '2': '银', '3': '铜',};
|
||||
const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',};
|
||||
const lootTypeDict = {'chests': '宝箱', 'gifts': '礼物箱',}
|
||||
window.setInterval(() => {
|
||||
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;
|
||||
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 $wh_loot_container = $root.querySelector('#wh-loot-container');
|
||||
if (!$wh_loot_container) {
|
||||
const insert_html = `<div id="wh-loot-container" class="m-bottom10">
|
||||
<div class="title-black"><span>附近物品</span></div>
|
||||
<div id="wh-loot-container-main" class="cont-gray" style="padding: 0.5em">
|
||||
<b>物品</b>
|
||||
<div id="wh-loot-container-items"></div>
|
||||
<b>箱子</b>
|
||||
<div id="wh-loot-container-chests"></div>
|
||||
<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>
|
||||
<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>
|
||||
</div>`;
|
||||
$($city_wrapper).before(insert_html);
|
||||
}
|
||||
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;
|
||||
item_props.y = -parseInt(e.style.top.replaceAll('px', '')) / 30;
|
||||
const srcSpl = e.firstElementChild.src.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;
|
||||
});
|
||||
const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
|
||||
const $wh_loot_container_chests = $root.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='↙';
|
||||
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.name === 'chests') {
|
||||
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>`
|
||||
} else {
|
||||
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>`
|
||||
}
|
||||
});
|
||||
$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})`;
|
||||
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂未发现`;
|
||||
}
|
||||
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
|
||||
let item_list = [];
|
||||
items.forEach(e => {
|
||||
const item_props = {x: 0, y: 0, name: '', type: ''};
|
||||
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.name = srcSpl[6];
|
||||
item_props.type = srcSpl[8].slice(0, 1);
|
||||
item_list[item_list.length] = item_props;
|
||||
});
|
||||
const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
|
||||
const $wh_loot_container_chests = $root.querySelector('#wh-loot-container-chests');
|
||||
$wh_loot_container_items.innerHTML = ``;
|
||||
$wh_loot_container_chests.innerHTML = ``;
|
||||
item_list.forEach(e => {
|
||||
if (e.name === 'chests') {
|
||||
$wh_loot_container_chests.innerHTML += `<span>[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}</span><br/>`
|
||||
} else {
|
||||
$wh_loot_container_items.innerHTML += `<span>[${e.x},${e.y}] - ${lootTypeDict[e.name] || '?钥匙'}</span><br/>`
|
||||
}
|
||||
});
|
||||
}, 1200);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Torn圣诞小镇掉落物品坐标显示
|
||||
// @namespace WH
|
||||
// @version 0.1
|
||||
// @version 0.2
|
||||
// @description 在地图界面上方显示附近的宝箱、物品、钥匙坐标,兼容手机APP Torn PDA及Alook
|
||||
// @author Woohoo[2687093]
|
||||
// @match https://www.torn.com/*
|
||||
@ -12,7 +12,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
const ___window___ = window || window.unsafeWindow;
|
||||
if (___window___.WHLOOTPOS) return;
|
||||
if (___window___.WHLOOTPOS||___window___.WHTRANS) return;
|
||||
___window___.WHLOOTPOS = true;
|
||||
|
||||
const $ = ___window___.jQuery;
|
||||
@ -20,46 +20,70 @@
|
||||
if (/christmas_town\.php/.test(window.location.href)) {
|
||||
const $root = document.querySelector('#christmastownroot');
|
||||
const chestTypeDict = {'1': '金', '2': '银', '3': '铜',};
|
||||
const chestTypeColorDict = {'1': 'gold', '2': 'silver', '3': 'sandybrown',};
|
||||
const lootTypeDict = {'chests': '宝箱', 'gifts': '礼物箱',}
|
||||
window.setInterval(() => {
|
||||
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;
|
||||
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 $wh_loot_container = $root.querySelector('#wh-loot-container');
|
||||
if (!$wh_loot_container) {
|
||||
const insert_html = `<div id="wh-loot-container" class="m-bottom10">
|
||||
<div class="title-black"><span>附近物品</span></div>
|
||||
<div id="wh-loot-container-main" class="cont-gray" style="padding: 0.5em">
|
||||
<b>物品</b>
|
||||
<div id="wh-loot-container-items"></div>
|
||||
<b>箱子</b>
|
||||
<div id="wh-loot-container-chests"></div>
|
||||
<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>
|
||||
<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>
|
||||
</div>`;
|
||||
$($city_wrapper).before(insert_html);
|
||||
}
|
||||
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;
|
||||
item_props.y = -parseInt(e.style.top.replaceAll('px', '')) / 30;
|
||||
const srcSpl = e.firstElementChild.src.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;
|
||||
});
|
||||
const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
|
||||
const $wh_loot_container_chests = $root.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='↙';
|
||||
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.name === 'chests') {
|
||||
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>`
|
||||
} else {
|
||||
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>`
|
||||
}
|
||||
});
|
||||
$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})`;
|
||||
if (chest_count === 0) $wh_loot_container_chests.innerText = `暂未发现`;
|
||||
}
|
||||
const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
|
||||
let item_list = [];
|
||||
items.forEach(e => {
|
||||
const item_props = {x: 0, y: 0, name: '', type: ''};
|
||||
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.name = srcSpl[6];
|
||||
item_props.type = srcSpl[8].slice(0, 1);
|
||||
item_list[item_list.length] = item_props;
|
||||
});
|
||||
const $wh_loot_container_items = $root.querySelector('#wh-loot-container-items');
|
||||
const $wh_loot_container_chests = $root.querySelector('#wh-loot-container-chests');
|
||||
$wh_loot_container_items.innerHTML = ``;
|
||||
$wh_loot_container_chests.innerHTML = ``;
|
||||
item_list.forEach(e => {
|
||||
if (e.name === 'chests') {
|
||||
$wh_loot_container_chests.innerHTML += `<span>[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}</span><br/>`
|
||||
} else {
|
||||
$wh_loot_container_items.innerHTML += `<span>[${e.x},${e.y}] - ${lootTypeDict[e.name] || '?钥匙'}</span><br/>`
|
||||
}
|
||||
});
|
||||
}, 1200);
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
const ___window___ = window || window.unsafeWindow;
|
||||
if (___window___.WHXMAS) return;
|
||||
if (___window___.WHXMAS||___window___.WHTRANS) return;
|
||||
___window___.WHXMAS = true;
|
||||
|
||||
const $ = ___window___.jQuery;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user