Zeigt zusätzliche Informationen in der Karten-Popup an: Ankunftszeiten für alle Einheiten, letzte Adelung, geschätzte Zustimmung und Adelsreichweite
Size
18.4 KB
Version
1.0.1
Created
Dec 4, 2025
Updated
9 days ago
1// ==UserScript==
2// @name Die Stämme Erweiterte Kartenansicht
3// @description Zeigt zusätzliche Informationen in der Karten-Popup an: Ankunftszeiten für alle Einheiten, letzte Adelung, geschätzte Zustimmung und Adelsreichweite
4// @version 1.0.1
5// @match https://*.de248.die-staemme.de/*
6// @icon https://dsde.innogamescdn.com/asset/ae6c0149/graphic/favicon-32x32.webp
7// ==/UserScript==
8(function () {
9function $6a49e4c969cec444$export$2e2bcd8739ae039(obj, key, value) {
10 if (key in obj) Object.defineProperty(obj, key, {
11 value: value,
12 enumerable: true,
13 configurable: true,
14 writable: true
15 });
16 else obj[key] = value;
17 return obj;
18}
19
20
21function $f1e9793517c51c58$export$2e2bcd8739ae039(target) {
22 for(var i = 1; i < arguments.length; i++){
23 var source = arguments[i] != null ? arguments[i] : {
24 };
25 var ownKeys = Object.keys(source);
26 if (typeof Object.getOwnPropertySymbols === 'function') ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
27 return Object.getOwnPropertyDescriptor(source, sym).enumerable;
28 }));
29 ownKeys.forEach(function(key) {
30 $6a49e4c969cec444$export$2e2bcd8739ae039(target, key, source[key]);
31 });
32 }
33 return target;
34}
35
36function $b1520df0e3a4699c$export$2e2bcd8739ae039(source, excluded) {
37 if (source == null) return {
38 };
39 var target = {
40 };
41 var sourceKeys = Object.keys(source);
42 var key, i;
43 for(i = 0; i < sourceKeys.length; i++){
44 key = sourceKeys[i];
45 if (excluded.indexOf(key) >= 0) continue;
46 target[key] = source[key];
47 }
48 return target;
49}
50
51
52function $f26b272b176e5476$export$2e2bcd8739ae039(source, excluded) {
53 if (source == null) return {
54 };
55 var target = $b1520df0e3a4699c$export$2e2bcd8739ae039(source, excluded);
56 var key, i;
57 if (Object.getOwnPropertySymbols) {
58 var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
59 for(i = 0; i < sourceSymbolKeys.length; i++){
60 key = sourceSymbolKeys[i];
61 if (excluded.indexOf(key) >= 0) continue;
62 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
63 target[key] = source[key];
64 }
65 }
66 return target;
67}
68
69
70
71function $70df79293cae00de$export$2e2bcd8739ae039(dirtyNumber) {
72 if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) return NaN;
73 var number = Number(dirtyNumber);
74 if (isNaN(number)) return number;
75 return number < 0 ? Math.ceil(number) : Math.floor(number);
76}
77
78
79
80function $14473fdd7558f621$export$2e2bcd8739ae039(required, args) {
81 if (args.length < required) throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
82}
83
84
85function $cef0ab118a15bdd4$export$2e2bcd8739ae039(argument) {
86 $14473fdd7558f621$export$2e2bcd8739ae039(1, arguments);
87 var argStr = Object.prototype.toString.call(argument);
88 if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]')
89 return new Date(argument.getTime());
90 else if (typeof argument === 'number' || argStr === '[object Number]') return new Date(argument);
91 else {
92 if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
93 console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule");
94 console.warn(new Error().stack);
95 }
96 return new Date(NaN);
97 }
98}
99
100
101
102function $b214e0d241adf6d7$export$2e2bcd8739ae039(dirtyDate, dirtyAmount) {
103 $14473fdd7558f621$export$2e2bcd8739ae039(2, arguments);
104 var timestamp = $cef0ab118a15bdd4$export$2e2bcd8739ae039(dirtyDate).getTime();
105 var amount = $70df79293cae00de$export$2e2bcd8739ae039(dirtyAmount);
106 return new Date(timestamp + amount);
107}
108
109
110
111var $76d93d3ec05eed83$var$MILLISECONDS_IN_MINUTE = 60000;
112function $76d93d3ec05eed83$export$2e2bcd8739ae039(dirtyDate, dirtyAmount) {
113 $14473fdd7558f621$export$2e2bcd8739ae039(2, arguments);
114 var amount = $70df79293cae00de$export$2e2bcd8739ae039(dirtyAmount);
115 return $b214e0d241adf6d7$export$2e2bcd8739ae039(dirtyDate, amount * $76d93d3ec05eed83$var$MILLISECONDS_IN_MINUTE);
116}
117
118
119const $f2fe9362d0defd49$var$translations = {
120 pl_PL: {
121 ennobledAt: 'Podbita o',
122 never: 'Nigdy',
123 possibleLoyalty: 'Prawdopodobne poparcie',
124 canSendNoble: 'Można wysłać szlachcica',
125 yes: 'Tak',
126 no: 'Nie'
127 },
128 en_DK: {
129 ennobledAt: 'Ennobled at',
130 never: 'Never',
131 possibleLoyalty: 'Possible loyalty',
132 canSendNoble: 'Can send noble',
133 yes: 'Yes',
134 no: 'No'
135 },
136 de_DE: {
137 ennobledAt: 'Adelung bei',
138 never: 'Nie',
139 possibleLoyalty: 'Mögliche Zustimmung',
140 canSendNoble: 'Kann Adelsgeschlecht senden',
141 yes: 'Ja',
142 no: 'Nein'
143 }
144};
145var $f2fe9362d0defd49$export$2e2bcd8739ae039 = ()=>$f2fe9362d0defd49$var$translations[window.game_data.locale] || $f2fe9362d0defd49$var$translations.en_DK
146;
147
148
149const $902f167bfdc7b30b$export$fb18762d0c18fa09 = 'https://api.tribalwarshelp.com/graphql';
150var $902f167bfdc7b30b$export$2e2bcd8739ae039 = ({ query: query , variables: variables = {
151} } = {
152})=>{
153 return fetch($902f167bfdc7b30b$export$fb18762d0c18fa09, {
154 method: 'POST',
155 body: JSON.stringify({
156 query: query,
157 variables: variables
158 }),
159 headers: {
160 'Content-Type': 'application/json'
161 }
162 }).then((res)=>{
163 return res.json();
164 }).then(({ data: data , errors: errors })=>{
165 if (errors && Array.isArray(errors) && errors.length > 0) throw new Error(errors[0].message);
166 return new Promise((resolve)=>resolve(data)
167 );
168 });
169};
170
171
172const $ca7593443ca49f96$export$17201263355d526a = (d = new Date(), tz = 'UTC')=>{
173 return new Date(new Date(d).toLocaleString('en-US', {
174 timeZone: tz
175 }));
176};
177const $ca7593443ca49f96$export$6a20e8f386d90a85 = (d = new Date())=>{
178 return $ca7593443ca49f96$export$17201263355d526a(d);
179};
180const $ca7593443ca49f96$export$3ae94a2503e890a1 = (date, options)=>{
181 return new Date(date).toLocaleDateString(undefined, options ? options : {
182 year: 'numeric',
183 month: '2-digit',
184 day: '2-digit',
185 hour: '2-digit',
186 minute: '2-digit',
187 second: '2-digit'
188 });
189};
190
191
192var $9412d55e353d4b8b$export$2e2bcd8739ae039 = ()=>window.location.host.split('.')[0]
193;
194
195
196const $8f952366ce71d0fe$export$6e378131ceaf17af = (x1, y1, x2, y2)=>{
197 const a = x1 - x2;
198 const b = y1 - y2;
199 return Math.sqrt(a * a + b * b);
200};
201
202
203const $db1dd60e5389e0c9$export$7345792e21cfc457 = (id)=>{
204 return window.location.origin + TribalWars.buildURL('', {
205 screen: 'info_ally',
206 id: id
207 });
208};
209const $db1dd60e5389e0c9$export$3df7b9b48f38839e = (id)=>{
210 return window.location.origin + TribalWars.buildURL('', {
211 screen: 'info_player',
212 id: id
213 });
214};
215const $db1dd60e5389e0c9$export$e537a41a0fc85cc5 = (id)=>{
216 return window.location.origin + TribalWars.buildURL('', {
217 screen: 'info_village',
218 id: id
219 });
220};
221const $db1dd60e5389e0c9$export$c6f77ec2633c38b1 = (n = '', x = 500, y = 500)=>{
222 const continent = 'K' + String(y)[0] + String(x)[0];
223 return `${n} (${x}|${y}) ${continent}`;
224};
225const $db1dd60e5389e0c9$export$893530ca1c0f63a2 = (distance, baseSpeed)=>{
226 return Math.round(distance * baseSpeed);
227};
228const $db1dd60e5389e0c9$export$8b4b6650247854da = (img)=>{
229 return image_base + img;
230};
231
232
233var $3cc0f054d48dddd4$export$2e2bcd8739ae039 = (unit)=>{
234 return $db1dd60e5389e0c9$export$8b4b6650247854da(`unit/unit_${unit}.png`);
235};
236
237
238const $362bcac9fa8968ec$export$f92dfeb71e9bb569 = (key, d = {
239})=>{
240 const json = localStorage.getItem(key);
241 let obj = d;
242 if (json) obj = JSON.parse(json);
243 return obj;
244};
245const $362bcac9fa8968ec$export$8a8216c44337cd5 = (key, payload)=>{
246 localStorage.setItem(key, JSON.stringify(payload));
247};
248
249
250
251
252
253function $0efd46ae48a1111f$export$2e2bcd8739ae039(dirtyDateLeft, dirtyDateRight) {
254 $14473fdd7558f621$export$2e2bcd8739ae039(2, arguments);
255 var dateLeft = $cef0ab118a15bdd4$export$2e2bcd8739ae039(dirtyDateLeft);
256 var dateRight = $cef0ab118a15bdd4$export$2e2bcd8739ae039(dirtyDateRight);
257 return dateLeft.getTime() - dateRight.getTime();
258}
259
260
261
262var $d8d089e636d25180$var$MILLISECONDS_IN_MINUTE = 60000;
263function $d8d089e636d25180$export$2e2bcd8739ae039(dirtyDateLeft, dirtyDateRight) {
264 $14473fdd7558f621$export$2e2bcd8739ae039(2, arguments);
265 var diff = $0efd46ae48a1111f$export$2e2bcd8739ae039(dirtyDateLeft, dirtyDateRight) / $d8d089e636d25180$var$MILLISECONDS_IN_MINUTE;
266 return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
267}
268
269
270const $8e88e9cb6c51e781$var$calcLoyalty = (ennobledAt, speed)=>{
271 let loyalty = 25 + Math.abs($d8d089e636d25180$export$2e2bcd8739ae039(ennobledAt, new Date())) * (speed / 60);
272 if (loyalty > 100) loyalty = 100;
273 return Math.floor(loyalty);
274};
275var $8e88e9cb6c51e781$export$2e2bcd8739ae039 = $8e88e9cb6c51e781$var$calcLoyalty;
276
277
278const $0037f5ff61114eb0$var$SERVER = $9412d55e353d4b8b$export$2e2bcd8739ae039();
279const $0037f5ff61114eb0$var$CURR_SERVER_CONFIG = `
280 query server($key: String!) {
281 server(key: $key) {
282 config {
283 speed
284 unitSpeed
285 snob {
286 maxDist
287 }
288 }
289 unitConfig {
290 spear {
291 speed
292 }
293 sword {
294 speed
295 }
296 axe {
297 speed
298 }
299 archer {
300 speed
301 }
302 spy {
303 speed
304 }
305 light {
306 speed
307 }
308 marcher {
309 speed
310 }
311 heavy {
312 speed
313 }
314 ram {
315 speed
316 }
317 catapult {
318 speed
319 }
320 knight {
321 speed
322 }
323 snob {
324 speed
325 }
326 }
327 }
328 }
329`;
330const $0037f5ff61114eb0$var$LAST_CONQUER_QUERY = `
331 query ennoblements($server: String!, $filter: EnnoblementFilter!, $sort: [String!], $limit: Int) {
332 ennoblements(server: $server, filter: $filter, sort: $sort, limit: $limit) {
333 items {
334 ennobledAt
335 village {
336 id
337 }
338 }
339 }
340 }
341`;
342const $0037f5ff61114eb0$var$SERVER_CONFIG_LOCAL_STORAGE_KEY = 'kiszkowaty_extended_map_popup_server_cfg';
343const $0037f5ff61114eb0$var$translations = $f2fe9362d0defd49$export$2e2bcd8739ae039();
344const $0037f5ff61114eb0$var$loadConfigFromLocalStorage = ()=>{
345 return $362bcac9fa8968ec$export$f92dfeb71e9bb569($0037f5ff61114eb0$var$SERVER_CONFIG_LOCAL_STORAGE_KEY);
346};
347const $0037f5ff61114eb0$var$cacheServerConfig = (data = {
348})=>{
349 $362bcac9fa8968ec$export$8a8216c44337cd5($0037f5ff61114eb0$var$SERVER_CONFIG_LOCAL_STORAGE_KEY, data);
350};
351const $0037f5ff61114eb0$var$isConfigExpired = (date)=>{
352 return Math.abs(date.getTime() - new Date().getTime()) > 86400000;
353};
354const $0037f5ff61114eb0$var$loadConfig = async ()=>{
355 let data = $0037f5ff61114eb0$var$loadConfigFromLocalStorage();
356 if (!data || !data.server || $0037f5ff61114eb0$var$isConfigExpired(new Date(data.loadedAt)) || !data.server.config || !data.server.config.speed || !data.server.config.snob || !data.server.config.snob.maxDist || !data.server.config.unitSpeed || !data.server.unitConfig) {
357 data = await $902f167bfdc7b30b$export$2e2bcd8739ae039({
358 query: $0037f5ff61114eb0$var$CURR_SERVER_CONFIG,
359 variables: {
360 key: $0037f5ff61114eb0$var$SERVER
361 }
362 });
363 data.loadedAt = new Date();
364 $0037f5ff61114eb0$var$cacheServerConfig(data);
365 }
366 return data && data.server && data.server.config ? {
367 config: data.server.config,
368 unitConfig: data.server.unitConfig
369 } : {
370 };
371};
372const $0037f5ff61114eb0$var$loadVillageData = async (id, { cacheOnly: cacheOnly = false } = {
373})=>{
374 if (!id) return;
375 if (cacheOnly || TWMap.popup.extendedMapPopupCache[id]) return TWMap.popup.extendedMapPopupCache[id];
376 try {
377 const data = await $902f167bfdc7b30b$export$2e2bcd8739ae039({
378 query: $0037f5ff61114eb0$var$LAST_CONQUER_QUERY,
379 variables: {
380 server: $0037f5ff61114eb0$var$SERVER,
381 sort: [
382 'ennobledAt DESC'
383 ],
384 filter: {
385 villageID: [
386 id
387 ]
388 },
389 limit: 1
390 }
391 });
392 TWMap.popup.extendedMapPopupCache[id] = data;
393 return data;
394 } catch (error) {
395 console.log('loadVillageData', error);
396 }
397};
398const $0037f5ff61114eb0$var$getAvailableUnits = (unitCfg = {
399})=>{
400 const units = [];
401 for(let unit in unitCfg)if (unitCfg[unit].speed !== 0) units.push($f1e9793517c51c58$export$2e2bcd8739ae039({
402 }, unitCfg[unit], {
403 name: unit,
404 img: $3cc0f054d48dddd4$export$2e2bcd8739ae039(unit)
405 }));
406 return units;
407};
408const $0037f5ff61114eb0$var$getUnitTdBgColor = (index)=>index % 2 === 0 ? '#f8f4e8' : '#ded3b9;'
409;
410const $0037f5ff61114eb0$var$buildUnitHeader = (unit, index)=>{
411 return `
412 <td style="padding: 2px; background-color: ${$0037f5ff61114eb0$var$getUnitTdBgColor(index)};">
413 <img
414 src="${unit.img}"
415 title="${unit.name}"
416 alt="${unit.name}"
417 />
418 </td>
419 `;
420};
421const $0037f5ff61114eb0$var$buildUnitArrivalInfo = (t, index)=>{
422 return `
423 <td style="padding: 2px; background-color: ${$0037f5ff61114eb0$var$getUnitTdBgColor(index)};">
424 ${$ca7593443ca49f96$export$3ae94a2503e890a1($76d93d3ec05eed83$export$2e2bcd8739ae039(Timing.getCurrentServerTime(), t))}
425 </td>
426 `;
427};
428const $0037f5ff61114eb0$var$renderAdditionalInfo = (id, data, { config: config , unitConfig: unitConfig })=>{
429 const coords = TWMap.CoordByXY(TWMap.villageKey[id]);
430 const distance = $8f952366ce71d0fe$export$6e378131ceaf17af(coords[0], coords[1], window.game_data.village.x, window.game_data.village.y);
431 const ennoblement = data && data.ennoblements && data.ennoblements.items && data.ennoblements.items.length > 0 ? data.ennoblements.items[0] : undefined;
432 const parent = document.querySelector('#map_popup #info_content tbody');
433 let unitsEl = parent.querySelector('#units');
434 if (!unitsEl) {
435 unitsEl = document.createElement('tr');
436 unitsEl.id = 'units';
437 parent.appendChild(unitsEl);
438 }
439 const units = $0037f5ff61114eb0$var$getAvailableUnits(unitConfig);
440 unitsEl.innerHTML = `
441 <td colspan="2">
442 <table style="border: 1px solid #ded3b9; max-width: 450px;"
443 width="100%"
444 cellpadding="0"
445 cellspacing="0">
446 <tbody>
447 <tr class="center">
448 ${units.map($0037f5ff61114eb0$var$buildUnitHeader).join('')}
449 </tr>
450 <tr class="center">
451 ${units.map((unit, index)=>{
452 return $0037f5ff61114eb0$var$buildUnitArrivalInfo($db1dd60e5389e0c9$export$893530ca1c0f63a2(distance, unit.speed), index);
453 }).join('')}
454 </tr>
455 </tbody>
456 </table>
457 </td>
458 `;
459 let lastEnnobledAt = parent.querySelector('#lastEnnobledAt');
460 if (!lastEnnobledAt) {
461 lastEnnobledAt = document.createElement('tr');
462 lastEnnobledAt.id = 'lastEnnobledAt';
463 parent.appendChild(lastEnnobledAt);
464 }
465 lastEnnobledAt.innerHTML = `
466 <td>
467 ${$0037f5ff61114eb0$var$translations.ennobledAt}:
468 </td>
469 <td>
470 ${ennoblement ? $ca7593443ca49f96$export$3ae94a2503e890a1(ennoblement.ennobledAt) : $0037f5ff61114eb0$var$translations.never}
471 </td>
472 `;
473 let loyalty = parent.querySelector('#loyalty');
474 if (!loyalty) {
475 loyalty = document.createElement('tr');
476 loyalty.id = 'loyalty';
477 parent.appendChild(loyalty);
478 }
479 loyalty.innerHTML = `
480 <td>
481 ${$0037f5ff61114eb0$var$translations.possibleLoyalty}:
482 </td>
483 <td>
484 ${ennoblement ? $8e88e9cb6c51e781$export$2e2bcd8739ae039(new Date(ennoblement.ennobledAt), config.speed) : 100}
485 </td>
486 `;
487 let canSendNoble = parent.querySelector('#canSendNoble');
488 if (!canSendNoble) {
489 canSendNoble = document.createElement('tr');
490 canSendNoble.id = 'canSendNoble';
491 parent.appendChild(canSendNoble);
492 }
493 canSendNoble.innerHTML = `
494 <td>
495 ${$0037f5ff61114eb0$var$translations.canSendNoble}:
496 </td>
497 <td>
498 ${distance < config.snob.maxDist ? $0037f5ff61114eb0$var$translations.yes : $0037f5ff61114eb0$var$translations.no}
499 </td>
500 `;
501};
502const $0037f5ff61114eb0$var$createLoadVillageHandler = (cfg)=>async (e)=>{
503 TWMap.popup._loadVillage(e);
504 const data = await $0037f5ff61114eb0$var$loadVillageData(parseInt(e));
505 if (data) $0037f5ff61114eb0$var$renderAdditionalInfo(parseInt(e), data, cfg);
506 }
507;
508const $0037f5ff61114eb0$var$createDisplayForVillageHandler = (cfg)=>async (e, a, t)=>{
509 TWMap.popup._displayForVillage(e, a, t);
510 const data = await $0037f5ff61114eb0$var$loadVillageData(parseInt(e.id), {
511 cacheOnly: window.game_data.features.Premium.active
512 });
513 if (data) $0037f5ff61114eb0$var$renderAdditionalInfo(parseInt(e.id), data, cfg);
514 }
515;
516(async function() {
517 try {
518 console.log('Extended Map Popup: Initialisierung gestartet');
519 const configs = await $0037f5ff61114eb0$var$loadConfig();
520 console.log('Extended Map Popup: Konfiguration geladen', configs);
521 TWMap.popup.extendedMapPopupCache = {
522 };
523 TWMap.popup._loadVillage = TWMap.popup.loadVillage;
524 TWMap.popup.loadVillage = $0037f5ff61114eb0$var$createLoadVillageHandler(configs);
525 TWMap.popup._displayForVillage = TWMap.popup.displayForVillage;
526 TWMap.popup.displayForVillage = $0037f5ff61114eb0$var$createDisplayForVillageHandler(configs);
527 console.log('Extended Map Popup: Erfolgreich aktiviert');
528 } catch (error) {
529 console.error('Extended Map Popup Fehler:', error);
530 }
531})();
532
533})();