@@ -5505,8 +5515,12 @@ margin: 0 0 3px;
+
-
+
+
- 如果长时间不清空数据会有奇怪的bug
+
+
@@ -5539,71 +5553,82 @@ margin: 0 0 3px;
100% {background: #f2f2f2}
}
`;
- $($city_wrapper).before(insert_html);
- $wh_loot_container = $root.querySelector('#wh-loot-container');
+ $($ct_wrap).before(insert_html);
+ $wh_loot_container = $root.querySelector('#wh-loot-container');
+ }
+ const $audio = $wh_loot_container.querySelector('audio');
+ const $blink = $wh_loot_container.querySelector('#wh-loot-setting-blink');
+ alertSettings.blink = $blink.checked ? 'y' : 'n';
+ const $sound = $wh_loot_container.querySelector('#wh-loot-setting-sound');
+ alertSettings.sound = $sound.checked ? 'y' : 'n';
+ const $chest = $wh_loot_container.querySelector('#wh-loot-setting-chest');
+ alertSettings.chest = $chest.checked ? 'y' : 'n';
+ const $ex = $wh_loot_container.querySelector('#wh-loot-container-ex');
+ const $btn = $wh_loot_container.querySelector('#wh-loot-btn button');
+ const $clear_btn = $wh_loot_container.querySelector('#wh-hist-clear button');
+ const $tbody = $wh_loot_container.querySelector('tbody');
+ if ($btn.onclick === null) $btn.onclick = (e) => {
+ e.target.innerText = e.target.innerText === '设置' ? '收起' : '设置';
+ $($ex).toggleClass('wh-hide');
+ e.target.blur();
+ };
+ if ($clear_btn.onclick === null) $clear_btn.onclick = (e) => {
+ dropHist = {};
+ $tbody.innerHTML = '';
+ e.target.blur();
+ };
+ const nearby_arr = [];
+ const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
+ // 附近的所有物品
+ items.forEach(el => {
+ const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
+ 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);
+ nearby_arr.push(item_props);
+ });
+ 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;
+ $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 = '↓';
+ let isChest = false;
+ let item_name;
+ if (nearby_item.name === 'chests') {
+ chest_count++;
+ isChest = true;
+ item_name = chestTypeDict[nearby_item.type] + lootTypeDict[nearby_item.name];
+ $wh_loot_container_chests.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${item_name}
`
+ } else {
+ item_count++;
+ item_name = (nearby_item.name === 'keys' ? keyTypeDict[nearby_item.type] || '' : '') + lootTypeDict[nearby_item.name] || nearby_item.name;
+ $wh_loot_container_items.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${item_name}
`
}
- const $audio = $wh_loot_container.querySelector('audio');
- const $blink = $wh_loot_container.querySelector('#wh-loot-setting-blink');
- alertSettings.blink = $blink.checked ? 'y' : 'n';
- const $sound = $wh_loot_container.querySelector('#wh-loot-setting-sound');
- alertSettings.sound = $sound.checked ? 'y' : 'n';
- const $ex = $wh_loot_container.querySelector('#wh-loot-container-ex');
- const $btn = $wh_loot_container.querySelector('#wh-loot-btn button');
- const $tbody = $wh_loot_container.querySelector('tbody');
- if (!onClickBind) $btn.onclick = (e) => {
- e.target.innerText = e.target.innerText === '设置' ? '收起' : '设置';
- $($ex).toggleClass('wh-hide');
- onClickBind = true;
- e.target.blur();
- };
- const nearby_arr = [];
- const items = $root.querySelectorAll('div.grid-layer div.items-layer div.ct-item');
- // 附近的所有物品
- items.forEach(el => {
- const item_props = {x: 0, y: 0, name: '', type: '', url: '',};
- 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);
- nearby_arr.push(item_props);
- });
- 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;
- $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 = '↓';
- let item_name;
- if (nearby_item.name === 'chests') {
- chest_count++;
- item_name = chestTypeDict[nearby_item.type] + lootTypeDict[nearby_item.name];
- $wh_loot_container_chests.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${item_name}
`
+ // 确认地图坐标存在
+ if ($ct_title) {
+ const hist_key = `[${nearby_item.x},${nearby_item.y}]"${$ct_title.firstChild.nodeValue.trim()}"${item_name}`;
+ const el = dropHist[hist_key];
+ if (el) {
+ if (path === '=' && (nearby_item.name === 'keys' || nearby_item.name === 'gifts')) {
+ el.isPassed = true;
+ }
} else {
- item_count++;
- item_name = (nearby_item.name === 'keys' ? keyTypeDict[nearby_item.type] || '' : '') + lootTypeDict[nearby_item.name] || nearby_item.name;
- $wh_loot_container_items.innerHTML += `
${path}[${nearby_item.x},${nearby_item.y}] ${item_name}
`
- }
- if ($ct_title) {
- const now = new Date();
- const hist_key = `[${nearby_item.x},${nearby_item.y}]"${$ct_title.firstChild.nodeValue.trim()}"`;
- const el = dropHist[hist_key];
- if (el) {
- if (nearby_item.x === player_position.x && nearby_item.y === player_position.y && nearby_item.name !== ('chests' || 'combinationChest')) {
- el.isPassed = true;
- }
- el.last = `${now.getFullYear()}-${now.getMonth()}-${now.getDay()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
- } else {
+ // (() => {
+ if (!(isChest && $chest.checked)) {
+ const now = new Date();
dropHist[hist_key] = {
pos: `[${nearby_item.x},${nearby_item.y}]`,
map: $ct_title.firstChild.nodeValue.trim(),
@@ -5612,30 +5637,35 @@ margin: 0 0 3px;
id: Object.keys(dropHist).length,
};
}
+ // else {
+ // return;
+ // }
+ // })();
}
- });
- $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 {
- if ($blink.checked) $wh_loot_container.querySelector('#wh-loot-container-main').style.animation = 'lootFoundAlert 2s infinite';
- if ($sound.checked) $audio.play().then();
}
- $wh_loot_container.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
- if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
-
- const history = Object.keys(dropHist).map(key => dropHist[key]).sort((a, b) => a.id - b.id);
- let table_html = ``;
- history.forEach(e => {
- table_html += `
| ${e.pos} | ${e.map} | ${e.name} | ${e.last} | ${e.isPassed ? '已取得' : '不确定'} |
`;
- });
- $tbody.innerHTML = table_html;
-
- localStorage.setItem('wh-loot-store', JSON.stringify(dropHist));
- localStorage.setItem('wh-loot-setting', JSON.stringify(alertSettings));
+ });
+ $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 {
+ if ($blink.checked) $wh_loot_container.querySelector('#wh-loot-container-main').style.animation = 'lootFoundAlert 2s infinite';
+ if ($sound.checked) $audio.play().then();
}
- }, 1200);
+ $wh_loot_container.querySelector('#wh-loot-chest-count').innerText = `(${chest_count})`;
+ if (chest_count === 0) $wh_loot_container_chests.innerText = `暂无`;
+
+ const history = Object.keys(dropHist).map(key => dropHist[key]).sort((a, b) => a.id - b.id);
+ let table_html = '';
+ history.forEach(e => {
+ table_html += `
| ${e.pos} | ${e.map} | ${e.name} | ${e.last} | ${e.isPassed ? '已取得' : '不确定'} |
`;
+ });
+ $tbody.innerHTML = table_html;
+
+ localStorage.setItem('wh-loot-store', JSON.stringify(dropHist));
+ localStorage.setItem('wh-loot-setting', JSON.stringify(alertSettings));
+ });
+ getDOMOb.observe($root, {childList: true, subtree: true})
return;
}