src/extendedMapPopup.js - fix distance formula | src/dailyAchievements.js - should show the same data for all timezones

This commit is contained in:
Dawid Wysokiński 2021-01-01 16:55:56 +01:00
parent bc0c7abcfb
commit 210a70b56c
7 changed files with 2900 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -675,7 +675,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
// @namespace https://github.com/tribalwarshelp/scripts
// @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
// @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
// @version 0.6.2
// @version 0.6.3
// @description Extended map popup
// @author Kichiyaki http://dawid-wysokinski.pl/
// @match *://*/game.php*screen=map*
@ -793,7 +793,7 @@ const renderAdditionalInfo = (id, data, _ref) => {
const units = getAvailableUnits(unitConfig);
unitsEl.innerHTML = "\n <td colspan=\"2\">\n <table style=\"border: 1px solid #ded3b9; max-width: 450px;\"\n width=\"100%\"\n cellpadding=\"0\"\n cellspacing=\"0\">\n <tbody>\n <tr class=\"center\">\n ".concat(units.map(buildUnitHeader).join(''), "\n </tr>\n <tr class=\"center\">\n ").concat(units.map((unit, index) => {
return buildUnitArrivalInfo((0, _tribalwars.calcAttackDuration)(distance, config.unitSpeed, unit.speed), index);
return buildUnitArrivalInfo((0, _tribalwars.calcAttackDuration)(distance, config.unitSpeed * config.speed, unit.speed), index);
}).join(''), "\n </tr>\n </tbody>\n </table>\n </td>\n ");
let lastEnnobledAt = parent.querySelector('#lastEnnobledAt');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,15 +1,17 @@
import format from 'date-fns/format';
import requestCreator from './libs/requestCreator';
import getTranslations from './i18n/dailyAchievments';
import { setItem, getItem } from './utils/localStorage';
import { formatPlayerURL } from './utils/tribalwars';
import getCurrentServer from './utils/getCurrentServer';
import { inTZ } from './utils/date';
// ==UserScript==
// @name Daily achievements
// @namespace https://github.com/tribalwarshelp/scripts
// @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/dailyAchievements.js
// @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/dailyAchievements.js
// @version 0.4.1
// @version 0.4.2
// @description Daily achievements
// @author Kichiyaki http://dawid-wysokinski.pl/
// @match *://*/game.php*screen=info_player&mode=awards*
@ -23,6 +25,9 @@ const SERVER_QUERY = `
server(key: $server) {
key
historyUpdatedAt
version {
timezone
}
}
}
`;
@ -85,12 +90,13 @@ const loadData = async () => {
},
});
if (data.server) {
const d = inTZ(data.server.historyUpdatedAt, data.server.version.timezone);
const dailyStatsData = await requestCreator({
query: DAILY_STATS_QUERY,
variables: {
server: SERVER,
createDateGTE:
data.server.historyUpdatedAt.split('T')[0] + 'T00:00:00Z',
format(d, 'yyyy-MM-dd') + 'T' + format(d, 'HH:mm:ss') + 'Z',
},
});
data = {

View File

@ -14,7 +14,7 @@ import countLoyalty from './utils/countLoyalty';
// @namespace https://github.com/tribalwarshelp/scripts
// @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
// @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedMapPopup.js
// @version 0.6.2
// @version 0.6.3
// @description Extended map popup
// @author Kichiyaki http://dawid-wysokinski.pl/
// @match *://*/game.php*screen=map*
@ -228,7 +228,7 @@ const renderAdditionalInfo = (id, data, { config, unitConfig }) => {
return buildUnitArrivalInfo(
calcAttackDuration(
distance,
config.unitSpeed,
config.unitSpeed * config.speed,
unit.speed
),
index

7
src/utils/date.js Normal file
View File

@ -0,0 +1,7 @@
export const inTZ = (d = new Date(), tz = 'UTC') => {
return new Date(new Date(d).toLocaleString('en-US', { timeZone: tz }));
};
export const inUTC = (d = new Date()) => {
return inTZ(d);
};