|
|
@@ -1,7 +1,7 @@
|
|
|
|
// ==UserScript==
|
|
|
|
// ==UserScript==
|
|
|
|
// @name Torn - Arrival Time Predictor
|
|
|
|
// @name Torn - Arrival Time Predictor
|
|
|
|
// @namespace http://tampermonkey.net/
|
|
|
|
// @namespace http://tampermonkey.net/
|
|
|
|
// @version 1.0
|
|
|
|
// @version 1.02
|
|
|
|
// @description Calculates and displays the exact local time you will land while traveling
|
|
|
|
// @description Calculates and displays the exact local time you will land while traveling
|
|
|
|
// @author You
|
|
|
|
// @author You
|
|
|
|
// @match https://www.torn.com/page.php?sid=travel
|
|
|
|
// @match https://www.torn.com/page.php?sid=travel
|
|
|
@@ -21,6 +21,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
.pulse-text {
|
|
|
|
.pulse-text {
|
|
|
|
animation: colorPulse 1s infinite ease-in-out;
|
|
|
|
animation: colorPulse 1s infinite ease-in-out;
|
|
|
|
|
|
|
|
font-size: 2rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
|
@@ -41,25 +42,20 @@
|
|
|
|
function initClockExtension(timerElement) {
|
|
|
|
function initClockExtension(timerElement) {
|
|
|
|
// Create a custom UI box to display our text safely without breaking Torn's CSS
|
|
|
|
// Create a custom UI box to display our text safely without breaking Torn's CSS
|
|
|
|
const travelRoot = document.querySelector("#travel-root");
|
|
|
|
const travelRoot = document.querySelector("#travel-root");
|
|
|
|
|
|
|
|
const parentContainer = travelRoot.querySelector('[class^="progressText"]');
|
|
|
|
// Remove travel fact
|
|
|
|
// Remove travel fact
|
|
|
|
travelRoot.querySelector('[class^="factWrapper"]').remove();
|
|
|
|
travelRoot.querySelector('[class^="factWrapper"]').remove();
|
|
|
|
// Remove flight scene
|
|
|
|
// Remove flight scene
|
|
|
|
travelRoot.querySelector('[class^="airspaceScene"]').remove();
|
|
|
|
travelRoot.querySelector('[class^="airspaceScene"]').remove();
|
|
|
|
const ogTimer = document.querySelector("#travel-root > div.viewport___cdEK9 > div.flightProgressSection___OEJoR > div.progressText___BEQ0k > div > span");
|
|
|
|
const ogTimer = document.querySelector("#travel-root > div.viewport___cdEK9 > div.flightProgressSection___OEJoR > div.progressText___BEQ0k > div > span");
|
|
|
|
if (ogTimer) {
|
|
|
|
var timerContainer = null;
|
|
|
|
ogTimer.style.cssText = 'font-weight: bold; font-size: 1.5rem;';
|
|
|
|
const timeDisplay = document.createElement('div');
|
|
|
|
ogTimer.innerText = 'Calculating landing time...';
|
|
|
|
timeDisplay.style.cssText = 'padding: 10px; margin-top: 10px; color: #fff; text-align: center; border-radius: 5px; font-weight: bold; border: 1px solid #444; transition: color 0.5s ease; font-weight: bold; font-size: 1.5rem;';
|
|
|
|
} else {
|
|
|
|
//timerElement.parentNode.insertBefore(timeDisplay, timerElement.nextSibling);
|
|
|
|
const timeDisplay = document.createElement('div');
|
|
|
|
parentContainer.insertAdjacentElement('beforebegin', timeDisplay);
|
|
|
|
timeDisplay.style.cssText = 'padding: 10px; margin-top: 10px; color: #fff; text-align: center; border-radius: 5px; font-weight: bold; border: 1px solid #444; transition: color 0.5s ease;';
|
|
|
|
timeDisplay.innerText = 'Calculating landing time...';
|
|
|
|
timerElement.parentNode.insertBefore(timeDisplay, timerElement.nextSibling);
|
|
|
|
timerContainer = timeDisplay;
|
|
|
|
}
|
|
|
|
|
|
|
|
//const info = document.querySelector("#travel-root > div.viewport___cdEK9.stage0 > div.factWrapper___LvERA > div");
|
|
|
|
|
|
|
|
//info.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Insert our box right below Torn's native countdown timer
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the landing time prediction every single second
|
|
|
|
// Update the landing time prediction every single second
|
|
|
|
setInterval(() => {
|
|
|
|
setInterval(() => {
|
|
|
|
const timeString = timerElement.innerText; // Grabs 'HH:MM:SS' from the page
|
|
|
|
const timeString = timerElement.innerText; // Grabs 'HH:MM:SS' from the page
|
|
|
@@ -75,21 +71,16 @@
|
|
|
|
const msRemaining = ((hours * 60 * 60) + (minutes * 60) + seconds) * 1000;
|
|
|
|
const msRemaining = ((hours * 60 * 60) + (minutes * 60) + seconds) * 1000;
|
|
|
|
// Blink the text if time left is < 2 minutes.
|
|
|
|
// Blink the text if time left is < 2 minutes.
|
|
|
|
if (msRemaining <= 120000) {
|
|
|
|
if (msRemaining <= 120000) {
|
|
|
|
//ogTimer.style.cssText += ' color: #aa0000;'
|
|
|
|
|
|
|
|
// Add the blinking class to the text.
|
|
|
|
// Add the blinking class to the text.
|
|
|
|
ogTimer.classList.add('pulse-text');
|
|
|
|
timerContainer.classList.add('pulse-text');
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add the flight duration to the current system date/time
|
|
|
|
// Add the flight duration to the current system date/time
|
|
|
|
const landingTime = new Date(Date.now() + msRemaining);
|
|
|
|
const landingTime = new Date(Date.now() + msRemaining);
|
|
|
|
|
|
|
|
|
|
|
|
// Remove OG timer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ogTimer.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Format the output neatly (e.g., "16:24:05")
|
|
|
|
// Format the output neatly (e.g., "16:24:05")
|
|
|
|
ogTimer.innerText = `Estimated Landing: ${landingTime.toLocaleTimeString()}`;
|
|
|
|
timerContainer.innerText = `Estimated Landing: ${landingTime.toLocaleTimeString()}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|