Added settings of timeshift, fixed undefined behavior after anomaly times
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name IITC plugin: ResTools BB Watch Reloaded
|
// @name IITC plugin: ResTools BB Watch Reloaded
|
||||||
// @namespace https://git.martinvylet.cz/vykend/ResTools-BB-Watch-Reloaded
|
// @namespace https://git.martinvylet.cz/vykend/ResTools-BB-Watch-Reloaded
|
||||||
// @version 0.4
|
// @version 0.5
|
||||||
// @description Scan window for BBs on ornamented portals, then check results
|
// @description Scan window for BBs on ornamented portals, then check results
|
||||||
// @author vikend
|
// @author vikend
|
||||||
// @icon
|
// @icon
|
||||||
@@ -28,6 +28,7 @@ function wrapper(plugin_info)
|
|||||||
window.plugin.restoolsBBWatchReloaded.LAYERGROUP = null;
|
window.plugin.restoolsBBWatchReloaded.LAYERGROUP = null;
|
||||||
window.plugin.restoolsBBWatchReloaded.BB_STORAGE = 'plugin-restools-bbwatch-reloaded';
|
window.plugin.restoolsBBWatchReloaded.BB_STORAGE = 'plugin-restools-bbwatch-reloaded';
|
||||||
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = [[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]]];
|
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = [[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]]];
|
||||||
|
window.plugin.restoolsBBWatchReloaded.timezone = 0;
|
||||||
//struct of WAVE_PORTALS: [ wave: [ ornamented[], results[] ] ]
|
//struct of WAVE_PORTALS: [ wave: [ ornamented[], results[] ] ]
|
||||||
|
|
||||||
//edit this with start times according to YOUR local times (ie. as seen in COMM)
|
//edit this with start times according to YOUR local times (ie. as seen in COMM)
|
||||||
@@ -79,9 +80,13 @@ function wrapper(plugin_info)
|
|||||||
|
|
||||||
// --- HELPER
|
// --- HELPER
|
||||||
window.plugin.restoolsBBWatchReloaded.getCurrentWaveNo = function() {
|
window.plugin.restoolsBBWatchReloaded.getCurrentWaveNo = function() {
|
||||||
|
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
const currentTimeString = currentTime.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
const timezoneOffsetHours = window.plugin.restoolsBBWatchReloaded.timezone; // Assuming the offset is stored in hours
|
||||||
const currentTimePlus5Minutes = (new Date(currentTime.getTime() + 5 * 60000)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });// Adding 20 minutes in milliseconds
|
const offsetMilliseconds = timezoneOffsetHours * 60 * 60 * 1000; // Convert offset to milliseconds
|
||||||
|
const currentTimeWithOffset = new Date(currentTime.getTime() + offsetMilliseconds);
|
||||||
|
const currentTimeString = currentTimeWithOffset.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||||
|
const currentTimePlus5Minutes = (new Date(currentTimeWithOffset.getTime() + 5 * 60000)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||||
|
|
||||||
let currentWave = 0;
|
let currentWave = 0;
|
||||||
let battleOver = false;
|
let battleOver = false;
|
||||||
@@ -149,6 +154,10 @@ function wrapper(plugin_info)
|
|||||||
console.log("BBWatchReloaded: According to timetable anomaly haven't started yet, skipping");
|
console.log("BBWatchReloaded: According to timetable anomaly haven't started yet, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (waveNo > 7) {
|
||||||
|
console.log("BBWatchReloaded: According to timetable anomaly already ended, skipping");
|
||||||
|
return;
|
||||||
|
}
|
||||||
let portalsToBeAdded = [];
|
let portalsToBeAdded = [];
|
||||||
for (let i in wavePortals)
|
for (let i in wavePortals)
|
||||||
{
|
{
|
||||||
@@ -250,7 +259,7 @@ function wrapper(plugin_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.restoolsBBWatchReloaded.loadStorage = function() {
|
window.plugin.restoolsBBWatchReloaded.loadStorage = function() {
|
||||||
if (JSON.parse(localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE]) != null) {
|
if (localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE] != undefined) {
|
||||||
return JSON.parse(localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE]);
|
return JSON.parse(localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -272,6 +281,8 @@ function wrapper(plugin_info)
|
|||||||
|
|
||||||
let htmlBegin = `
|
let htmlBegin = `
|
||||||
<div class="restoolsBBWatchReloadedDialog">
|
<div class="restoolsBBWatchReloadedDialog">
|
||||||
|
<a onclick="window.plugin.restoolsBBWatchReloaded.openPreferences()" title="Settings">Settings</a>
|
||||||
|
|
||||||
<table class="styled-table">
|
<table class="styled-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -318,8 +329,8 @@ function wrapper(plugin_info)
|
|||||||
let htmlEnd = `
|
let htmlEnd = `
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>` + bestScore + bestScoreVolatiles + `
|
</table>` + bestScore + bestScoreVolatiles + `
|
||||||
<a onclick="window.plugin.restoolsBBWatchReloaded.resetStorage()" title="Reset local storage (deletes data saved in your browser, do this prior to anomaly, refresh windown for it to take effect)">Reset local storage (refresh window after)</a>
|
<a onclick="window.plugin.restoolsBBWatchReloaded.resetStorage()" title="Reset local storage (deletes data saved in your browser, do this prior to anomaly, fully refresh window for it to take effect)">Reset local storage (fully refresh window after)</a>
|
||||||
<a style="float: right;" onclick="window.plugin.restoolsBBWatchReloaded.getCurrentState()" title="Refresh this dialog window">Refresh this window</a>
|
<a style="float: right;" onclick="window.plugin.restoolsBBWatchReloaded.getCurrentState()" title="Refresh this dialog window">Refresh this dialog</a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
let html = htmlBegin + htmlBody + htmlEnd;
|
let html = htmlBegin + htmlBody + htmlEnd;
|
||||||
@@ -333,6 +344,41 @@ function wrapper(plugin_info)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.plugin.restoolsBBWatchReloaded.openPreferences = function() {
|
||||||
|
var html =
|
||||||
|
'<div>' +
|
||||||
|
'<table>';
|
||||||
|
|
||||||
|
html +=
|
||||||
|
'<tr>' +
|
||||||
|
'<td>' +
|
||||||
|
'Your timezone shift against local anomaly time: ' +
|
||||||
|
'</td>' +
|
||||||
|
'<td>' +
|
||||||
|
'<input id="timezone_input" size="10" type="number" value="'+ window.plugin.restoolsBBWatchReloaded.timezone + '"/>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' ;
|
||||||
|
|
||||||
|
html +=
|
||||||
|
'</table>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="text-align:center">' +
|
||||||
|
'<button type="button" onclick="window.plugin.restoolsBBWatchReloaded.saveTimezone()">Save</button>' +
|
||||||
|
'</div>';
|
||||||
|
dialog({
|
||||||
|
html: html,
|
||||||
|
id: 'plugin_restoolsBBWatchReloaded',
|
||||||
|
title: 'ResTools BB Watch Reloaded - Settings',
|
||||||
|
width: 'auto'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
window.plugin.restoolsBBWatchReloaded.saveTimezone = function() {
|
||||||
|
window.plugin.restoolsBBWatchReloaded.timezone = $('#timezone_input').val();
|
||||||
|
localStorage['window.plugin.restoolsBBWatchReloaded.timezone'] = JSON.stringify(window.plugin.restoolsBBWatchReloaded.timezone);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- SETUP ---
|
// --- SETUP ---
|
||||||
var setup = function()
|
var setup = function()
|
||||||
@@ -342,6 +388,9 @@ function wrapper(plugin_info)
|
|||||||
// Automatic update
|
// Automatic update
|
||||||
setTimeout(window.plugin.restoolsBBWatchReloaded.updateCurrentState, 10 * 1000);
|
setTimeout(window.plugin.restoolsBBWatchReloaded.updateCurrentState, 10 * 1000);
|
||||||
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = window.plugin.restoolsBBWatchReloaded.loadStorage();
|
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = window.plugin.restoolsBBWatchReloaded.loadStorage();
|
||||||
|
if (localStorage['window.plugin.restoolsBBWatchReloaded.timezone'] != undefined) {
|
||||||
|
window.plugin.restoolsBBWatchReloaded.timezone = JSON.parse(localStorage['window.plugin.restoolsBBWatchReloaded.timezone']);
|
||||||
|
}
|
||||||
console.log("BBWatchReloaded: Loaded previous state");
|
console.log("BBWatchReloaded: Loaded previous state");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user