// ==UserScript==
// @name ZcxJames's hornex wave script
// @namespace tampermonkey.net/
// @version 2.1
// @description Fetch and display JSON data from zcxjames.top/data.json on the right side of the screen with grid lines, text color change based on time value, lighter font weight, and toggle visibility with Tab key
// @author ZcxJames
// @match https://hornex.pro/*
// @grant GM_xmlhttpRequest
// @connect zcxjames.top
// @connect 103.193.151.90
// @license GPL
// ==/UserScript==
(function() {
'use strict';
let tableVisible = true;
const regions = ['as1', 'as2', 'eu1', 'eu2', 'us1', 'us2'];
function createTable(jsonData) {
const existingTable = document.getElementById('jsonDataTable');
if (existingTable) existingTable.remove();
const table = document.createElement('table');
table.id = 'jsonDataTable';
table.style.cssText = `
position: fixed;
top: 50%;
right: 0;
transform: translateY(-50%);
border: 1px solid black;
background-color: transparent;
z-index: 1000;
width: 200px;
border-collapse: collapse;
font-weight: lighter;
`;
table.innerHTML = `
<thead>
<tr><th></th><th>Super</th><th>Hyper</th></tr>
</thead>
<tbody>
${regions.map(region => `
<tr>
<td style="border: 1px solid black;">${region}</td>
${['Super', 'Hyper'].map(type => {
const key = `${region}_${type}`;
const data = jsonData[key] || {};
return `
<td style="border: 1px solid black; color: ${data.time === 1 ? '#FFA500' : 'black'};">
${data.progress || 'N/A'}
</td>
`;
}).join('')}
</tr>
`).join('')}
</tbody>
`;
document.body.appendChild(table);
table.style.display = tableVisible ? 'table' : 'none';
}
function fetchAndUpdateTable() {
GM_xmlhttpRequest({
method: 'GET',
url: 'https://zcxjames.top/data.json',
onload: response => createTable(JSON.parse(response.responseText)),
onerror: error => console.error('Error fetching JSON data:', error)
});
}
document.addEventListener('keydown', event => {
if (event.key === 'Tab') {
event.preventDefault();
tableVisible = !tableVisible;
const table = document.getElementById('jsonDataTable');
if (table) table.style.display = tableVisible ? 'table' : 'none';
}
});
setInterval(fetchAndUpdateTable, 1000);
const indicator = document.createElement('div');
indicator.style.cssText = 'position: fixed; bottom: 20px; right: 0; background-color: transparent; padding: 10px; z-index: 10000;';
document.body.appendChild(indicator);
let currentServer = '', currentZone = '', progress = '';
function updateIndicator() {
const servers = {
'eu1': 'rgb(166, 56, 237)',
'eu2': 'rgb(81, 121, 251)',
'as1': 'rgb(237, 61, 234)',
'us1': 'rgb(219, 130, 41)',
'us2': 'rgb(237, 236, 61)',
'as2': 'rgb(61, 179, 203)'
};
const zones = {
'Ultra': 'rgb(255, 43, 117)',
'Super': 'rgb(43, 255, 163)',
'Hyper': 'rgb(92, 116, 176)',
'Waveroom': 'rgb(126, 239, 109)'
};
currentServer = Object.keys(servers).find(server =>
document.querySelector(`div.btn.active[style="background-color: ${servers[server]};"]`)) || '';
currentZone = Object.keys(zones).find(zone =>
document.querySelector(`div.zone-name[stroke="${zone}"]`)) || '';
if (document.querySelector('div.zone-name[stroke="Waveroom"]')) currentZone = 'waveroom';
const waveSpan = document.querySelector('body > div.hud > div.zone > div.progress > span[stroke]');
const waveText = waveSpan ? waveSpan.getAttribute('stroke') : '';
const waveMatch = waveText.match(/Wave (\d+)/i);
const progressBars = document.querySelectorAll('div.bar');
progress = waveMatch ? 'Wave ' + waveMatch[1] : '0%';
progressBars.forEach(bar => {
const matches = bar.style.transform.match(/translate\(calc\(-(\d+\.\d+)% \+ \d+\.\d+em\), 0px\)/);
if (matches && matches[1]) {
const tempProgress = (100 - parseFloat(matches[1])).toFixed(4);
if (tempProgress > progress) progress = tempProgress + '%';
}
});
indicator.textContent = `${currentServer || 'Server not detected'} - ${currentZone || 'Zone not detected'} - Progress: ${progress}`;
}
function sendPost() {
const data = { server: currentServer, zone: currentZone, progress: progress };
GM_xmlhttpRequest({
method: "POST",
url: "http://103.193.151.90:5000",
data: JSON.stringify(data),
headers: { "Content-Type": "application/json" },
onload: () => console.log('Data sent:', data)
});
}
function animate() {
updateIndicator();
requestAnimationFrame(animate);
}
animate();
setInterval(sendPost, 1000);
const observerConfig = { attributes: true, subtree: true, attributeFilter: ['style', 'class'] };
const observer = new MutationObserver(updateIndicator);
observer.observe(document.querySelector('body > div.hud > div.zone > div.zone-name'), observerConfig);
observer.observe(document.querySelector('body > div.hud > div.zone > div.progress > div'), observerConfig);
observer.observe(document.querySelector('body > div.hud > div.zone > div.progress > span'), observerConfig);
observer.observe(document.querySelector('body > div.menu'), observerConfig);
})();