2020-07-18 10:38:26 +00:00
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
parcelRequire = ( function ( modules , cache , entry , globalName ) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof parcelRequire === 'function' && parcelRequire ;
var nodeRequire = typeof require === 'function' && require ;
function newRequire ( name , jumped ) {
if ( ! cache [ name ] ) {
if ( ! modules [ name ] ) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof parcelRequire === 'function' && parcelRequire ;
if ( ! jumped && currentRequire ) {
return currentRequire ( name , true ) ;
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if ( previousRequire ) {
return previousRequire ( name , true ) ;
}
// Try the node require function if it exists.
if ( nodeRequire && typeof name === 'string' ) {
return nodeRequire ( name ) ;
}
var err = new Error ( 'Cannot find module \'' + name + '\'' ) ;
err . code = 'MODULE_NOT_FOUND' ;
throw err ;
}
localRequire . resolve = resolve ;
localRequire . cache = { } ;
var module = cache [ name ] = new newRequire . Module ( name ) ;
modules [ name ] [ 0 ] . call ( module . exports , localRequire , module , module . exports , this ) ;
}
return cache [ name ] . exports ;
function localRequire ( x ) {
return newRequire ( localRequire . resolve ( x ) ) ;
}
function resolve ( x ) {
return modules [ name ] [ 1 ] [ x ] || x ;
}
}
function Module ( moduleName ) {
this . id = moduleName ;
this . bundle = newRequire ;
this . exports = { } ;
}
newRequire . isParcelRequire = true ;
newRequire . Module = Module ;
newRequire . modules = modules ;
newRequire . cache = cache ;
newRequire . parent = previousRequire ;
newRequire . register = function ( id , exports ) {
modules [ id ] = [ function ( require , module ) {
module . exports = exports ;
} , { } ] ;
} ;
var error ;
for ( var i = 0 ; i < entry . length ; i ++ ) {
try {
newRequire ( entry [ i ] ) ;
} catch ( e ) {
// Save first error but execute all entries
if ( ! error ) {
error = e ;
}
}
}
if ( entry . length ) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire ( entry [ entry . length - 1 ] ) ;
// CommonJS
if ( typeof exports === "object" && typeof module !== "undefined" ) {
module . exports = mainExports ;
// RequireJS
} else if ( typeof define === "function" && define . amd ) {
define ( function ( ) {
return mainExports ;
} ) ;
// <script>
} else if ( globalName ) {
this [ globalName ] = mainExports ;
}
}
// Override the current require with this new one
parcelRequire = newRequire ;
if ( error ) {
// throw error from earlier, _after updating parcelRequire_
throw error ;
}
return newRequire ;
} ) ( { "Ph2E" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = exports . API _URI = void 0 ;
const API _URI = 'https://api.tribalwarshelp.com/graphql' ;
exports . API _URI = API _URI ;
var _default = function _default ( ) {
let {
query ,
variables = { }
} = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
2020-07-20 12:07:57 +00:00
return fetch ( API _URI , {
2020-07-18 10:38:26 +00:00
method : 'POST' ,
body : JSON . stringify ( {
query ,
variables
} ) ,
headers : {
'Content-Type' : 'application/json'
}
} ) . then ( res => {
return res . json ( ) ;
} ) . then ( ( _ref ) => {
let {
data ,
errors
} = _ref ;
if ( errors && Array . isArray ( errors ) && errors . length > 0 ) {
throw new Error ( errors [ 0 ] . message ) ;
}
return new Promise ( resolve => resolve ( data ) ) ;
} ) ;
} ;
2020-07-22 14:19:44 +00:00
exports . default = _default ;
} , { } ] , "LNef" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
const translations = {
pl _PL : {
2020-08-07 13:50:26 +00:00
loaded : 'Załadowano' ,
pop : 'Populacja' ,
mySupport : 'Moje wsparcie' ,
allySupport : 'Wsparcie plemienia' ,
total : 'Łącznie' ,
2020-08-13 09:28:03 +00:00
possibleLoyalty : 'Prawdopodobne poparcie' ,
ennobledAt : 'Podbita o' ,
2020-08-13 15:25:22 +00:00
never : 'Nigdy' ,
2020-07-22 14:19:44 +00:00
action : {
2021-01-14 16:51:10 +00:00
linkToTWHelp : 'Akta wioski (TWHelp)' ,
2020-08-07 13:50:26 +00:00
showEnnoblements : 'Pokaż przejęcia' ,
countIncomingSupport : 'Policz nadchodzące wsparcie'
2020-07-22 14:19:44 +00:00
}
} ,
en _DK : {
2020-08-07 13:50:26 +00:00
loaded : 'Loaded' ,
pop : 'Pop' ,
mySupport : 'My support' ,
allySupport : 'Ally support' ,
total : 'Total' ,
2020-08-13 09:28:03 +00:00
possibleLoyalty : 'Possible loyalty' ,
2020-08-13 15:25:22 +00:00
never : 'Never' ,
2020-08-13 09:28:03 +00:00
ennobledAt : 'Ennobled at' ,
2020-07-22 14:19:44 +00:00
action : {
2021-01-14 16:51:10 +00:00
linkToTWHelp : 'Village file (TWHelp)' ,
2020-08-07 13:50:26 +00:00
showEnnoblements : 'Show ennoblements' ,
countIncomingSupport : 'Count incoming support'
2020-07-22 14:19:44 +00:00
}
2021-05-08 07:56:55 +00:00
} ,
de _DE : {
loaded : 'Geladen' ,
pop : 'Pop' ,
mySupport : 'Meine Unterstützung' ,
allySupport : 'Verbündete Unterstützung' ,
total : 'Total' ,
possibleLoyalty : 'Mögliche Zustimmung' ,
never : 'Niemals' ,
ennobledAt : 'Geadelt am' ,
action : {
linkToTWHelp : 'Dorfakte (TWHelp)' ,
showEnnoblements : 'Zeige Adelungen' ,
countIncomingSupport : 'Zähle ankommende Unterstützung'
}
2020-07-22 14:19:44 +00:00
}
} ;
var _default = ( ) => translations [ window . game _data . locale ] || translations . en _DK ;
2020-07-18 10:38:26 +00:00
exports . default = _default ;
} , { } ] , "fCHX" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . generatePaginationItems = exports . calcNumberOfPages = exports . getPage = exports . setPage = exports . getContainerStyles = void 0 ;
const ATTRIBUTE = 'data-page' ;
const getContainerStyles = ( ) => {
return 'display: flex; flex-direction: row; flex-wrap: wrap;' ;
} ;
exports . getContainerStyles = getContainerStyles ;
const setPage = function setPage ( el ) {
let page = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 1 ;
if ( ! el instanceof HTMLElement ) {
throw new Error ( 'Expected HTMLElement as the first argument' ) ;
}
page = parseInt ( page ) ;
if ( typeof page !== 'number' || isNaN ( page ) ) {
throw new Error ( 'Expected number or string as the second argument' ) ;
}
el . setAttribute ( ATTRIBUTE , page + '' ) ;
} ;
exports . setPage = setPage ;
const getPage = el => {
if ( ! el instanceof HTMLElement ) {
return 0 ;
}
return parseInt ( el . getAttribute ( ATTRIBUTE ) ) ;
} ;
exports . getPage = getPage ;
const calcNumberOfPages = ( total , limit ) => {
if ( typeof total !== 'number' ) {
throw new Error ( 'Expected number as the first argument' ) ;
}
if ( typeof limit !== 'number' ) {
throw new Error ( 'Expected number as the second argument' ) ;
}
return total > 0 ? Math . ceil ( total / limit ) : 1 ;
} ;
exports . calcNumberOfPages = calcNumberOfPages ;
const generatePaginationItems = function generatePaginationItems ( ) {
let {
total ,
limit ,
marginRight = 3 ,
currentPage = 0
} = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
const numberOfPages = calcNumberOfPages ( total , limit ) ;
const paginationItems = [ ] ;
for ( let i = 1 ; i <= numberOfPages ; i ++ ) {
if ( i === currentPage ) {
paginationItems . push ( "<strong style=\"margin-right: " . concat ( marginRight , "px\">>" ) . concat ( i , "<</strong>" ) ) ;
} else {
paginationItems . push ( "<a style=\"margin-right: " . concat ( marginRight , "px\" href=\"#\" " ) . concat ( ATTRIBUTE , "=\"" ) . concat ( i , "\">" ) . concat ( i , "</a>" ) ) ;
}
}
return paginationItems ;
} ;
exports . generatePaginationItems = generatePaginationItems ;
} , { } ] , "DMkL" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _default = ( ) => window . location . host . split ( '.' ) [ 0 ] ;
exports . default = _default ;
} , { } ] , "tQUs" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _default = url => parseInt ( new URLSearchParams ( url ) . get ( 'id' ) ) ;
2020-07-20 13:37:38 +00:00
exports . default = _default ;
2020-08-07 13:50:26 +00:00
} , { } ] , "fHHP" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
2021-01-03 12:13:05 +00:00
exports . buildImgURL = exports . calcAttackDuration = exports . buildVillageName = exports . buildVillageURL = exports . buildPlayerURL = exports . buildTribeURL = void 0 ;
2020-08-07 13:50:26 +00:00
2021-01-03 12:13:05 +00:00
const buildTribeURL = id => {
2020-08-07 13:50:26 +00:00
return window . location . origin + TribalWars . buildURL ( '' , {
screen : 'info_ally' ,
id
} ) ;
} ;
2021-01-03 12:13:05 +00:00
exports . buildTribeURL = buildTribeURL ;
2020-08-07 13:50:26 +00:00
2021-01-03 12:13:05 +00:00
const buildPlayerURL = id => {
2020-08-07 13:50:26 +00:00
return window . location . origin + TribalWars . buildURL ( '' , {
screen : 'info_player' ,
id
} ) ;
} ;
2021-01-03 12:13:05 +00:00
exports . buildPlayerURL = buildPlayerURL ;
2020-08-07 13:50:26 +00:00
2021-01-03 12:13:05 +00:00
const buildVillageURL = id => {
2020-08-07 13:50:26 +00:00
return window . location . origin + TribalWars . buildURL ( '' , {
screen : 'info_village' ,
id
} ) ;
} ;
2021-01-03 12:13:05 +00:00
exports . buildVillageURL = buildVillageURL ;
2020-08-07 13:50:26 +00:00
2021-01-03 12:13:05 +00:00
const buildVillageName = function buildVillageName ( ) {
2020-08-07 13:50:26 +00:00
let n = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
let x = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 500 ;
let y = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 500 ;
const continent = 'K' + String ( y ) [ 0 ] + String ( x ) [ 0 ] ;
return "" . concat ( n , " (" ) . concat ( x , "|" ) . concat ( y , ") " ) . concat ( continent ) ;
} ;
2021-01-03 12:13:05 +00:00
exports . buildVillageName = buildVillageName ;
2020-08-07 13:50:26 +00:00
2021-01-03 12:13:05 +00:00
const calcAttackDuration = ( distance , baseSpeed ) => {
return Math . round ( distance * baseSpeed ) ;
2020-08-07 13:50:26 +00:00
} ;
exports . calcAttackDuration = calcAttackDuration ;
const buildImgURL = img => {
return image _base + img ;
} ;
exports . buildImgURL = buildImgURL ;
} , { } ] , "KX6P" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _tribalwars = require ( "./tribalwars" ) ;
var _default = unit => {
return ( 0 , _tribalwars . buildImgURL ) ( "unit/unit_" . concat ( unit , ".png" ) ) ;
} ;
exports . default = _default ;
2021-01-17 15:21:47 +00:00
} , { "./tribalwars" : "fHHP" } ] , "ZbyX" : [ function ( require , module , exports ) {
2020-08-13 07:47:25 +00:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
2021-01-17 15:21:47 +00:00
exports . formatDate = exports . inUTC = exports . inTZ = void 0 ;
const inTZ = function inTZ ( ) {
let d = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : new Date ( ) ;
let tz = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 'UTC' ;
return new Date ( new Date ( d ) . toLocaleString ( 'en-US' , {
timeZone : tz
} ) ) ;
} ;
2020-08-13 07:47:25 +00:00
2021-01-17 15:21:47 +00:00
exports . inTZ = inTZ ;
const inUTC = function inUTC ( ) {
let d = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : new Date ( ) ;
return inTZ ( d ) ;
} ;
exports . inUTC = inUTC ;
const formatDate = ( date , options ) => {
return new Date ( date ) . toLocaleDateString ( undefined , options ? options : {
2020-08-13 07:47:25 +00:00
year : 'numeric' ,
month : '2-digit' ,
day : '2-digit' ,
hour : '2-digit' ,
minute : '2-digit' ,
second : '2-digit'
} ) ;
} ;
2021-01-17 15:21:47 +00:00
exports . formatDate = formatDate ;
2020-08-13 07:47:25 +00:00
} , { } ] , "oUdd" : [ function ( require , module , exports ) {
2020-08-07 13:50:26 +00:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _default = t => new Promise ( resolve => setTimeout ( resolve , t ) ) ;
exports . default = _default ;
} , { } ] , "KWxH" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . setItem = exports . getItem = void 0 ;
const getItem = function getItem ( key ) {
let d = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
const json = localStorage . getItem ( key ) ;
let obj = d ;
if ( json ) {
obj = JSON . parse ( json ) ;
}
return obj ;
} ;
exports . getItem = getItem ;
const setItem = ( key , payload ) => {
localStorage . setItem ( key , JSON . stringify ( payload ) ) ;
} ;
exports . setItem = setItem ;
2020-08-13 07:47:25 +00:00
} , { } ] , "kK6Q" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = requiredArgs ;
function requiredArgs ( required , args ) {
if ( args . length < required ) {
throw new TypeError ( required + ' argument' + ( required > 1 ? 's' : '' ) + ' required, but only ' + args . length + ' present' ) ;
}
}
} , { } ] , "KYJg" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = toDate ;
var _index = _interopRequireDefault ( require ( "../_lib/requiredArgs/index.js" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
/ * *
* @ name toDate
* @ category Common Helpers
* @ summary Convert the given argument to an instance of Date .
*
* @ description
* Convert the given argument to an instance of Date .
*
* If the argument is an instance of Date , the function returns its clone .
*
* If the argument is a number , it is treated as a timestamp .
*
* If the argument is none of the above , the function returns Invalid Date .
*
* * * Note * * : * all * Date arguments passed to any * date - fns * function is processed by ` toDate ` .
*
* @ param { Date | Number } argument - the value to convert
* @ returns { Date } the parsed date in the local time zone
* @ throws { TypeError } 1 argument required
*
* @ example
* // Clone the date:
* const result = toDate ( new Date ( 2014 , 1 , 11 , 11 , 30 , 30 ) )
* //=> Tue Feb 11 2014 11:30:30
*
* @ example
* // Convert the timestamp to date:
* const result = toDate ( 1392098430000 )
* //=> Tue Feb 11 2014 11:30:30
* /
function toDate ( argument ) {
( 0 , _index . default ) ( 1 , arguments ) ;
var argStr = Object . prototype . toString . call ( argument ) ; // Clone the date
if ( argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]' ) {
// Prevent the date to lose the milliseconds when passed to new Date() in IE10
return new Date ( argument . getTime ( ) ) ;
} else if ( typeof argument === 'number' || argStr === '[object Number]' ) {
return new Date ( argument ) ;
} else {
if ( ( typeof argument === 'string' || argStr === '[object String]' ) && typeof console !== 'undefined' ) {
// eslint-disable-next-line no-console
console . warn ( "Starting with v2.0.0-beta.1 date-fns doesn't accept strings as arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule" ) ; // eslint-disable-next-line no-console
console . warn ( new Error ( ) . stack ) ;
}
return new Date ( NaN ) ;
}
}
} , { "../_lib/requiredArgs/index.js" : "kK6Q" } ] , "H70G" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = differenceInMilliseconds ;
var _index = _interopRequireDefault ( require ( "../toDate/index.js" ) ) ;
var _index2 = _interopRequireDefault ( require ( "../_lib/requiredArgs/index.js" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
/ * *
* @ name differenceInMilliseconds
* @ category Millisecond Helpers
* @ summary Get the number of milliseconds between the given dates .
*
* @ description
* Get the number of milliseconds between the given dates .
*
* # # # v2 . 0.0 breaking changes :
*
* - [ Changes that are common for the whole library ] ( https : //github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
*
* @ param { Date | Number } dateLeft - the later date
* @ param { Date | Number } dateRight - the earlier date
* @ returns { Number } the number of milliseconds
* @ throws { TypeError } 2 arguments required
*
* @ example
* // How many milliseconds are between
* // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
* var result = differenceInMilliseconds (
* new Date ( 2014 , 6 , 2 , 12 , 30 , 21 , 700 ) ,
* new Date ( 2014 , 6 , 2 , 12 , 30 , 20 , 600 )
* )
* //=> 1100
* /
function differenceInMilliseconds ( dirtyDateLeft , dirtyDateRight ) {
( 0 , _index2 . default ) ( 2 , arguments ) ;
var dateLeft = ( 0 , _index . default ) ( dirtyDateLeft ) ;
var dateRight = ( 0 , _index . default ) ( dirtyDateRight ) ;
return dateLeft . getTime ( ) - dateRight . getTime ( ) ;
}
} , { "../toDate/index.js" : "KYJg" , "../_lib/requiredArgs/index.js" : "kK6Q" } ] , "oGJj" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = differenceInMinutes ;
var _index = _interopRequireDefault ( require ( "../differenceInMilliseconds/index.js" ) ) ;
var _index2 = _interopRequireDefault ( require ( "../_lib/requiredArgs/index.js" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
var MILLISECONDS _IN _MINUTE = 60000 ;
/ * *
* @ name differenceInMinutes
* @ category Minute Helpers
* @ summary Get the number of minutes between the given dates .
*
* @ description
* Get the signed number of full ( rounded towards 0 ) minutes between the given dates .
*
* # # # v2 . 0.0 breaking changes :
*
* - [ Changes that are common for the whole library ] ( https : //github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
*
* @ param { Date | Number } dateLeft - the later date
* @ param { Date | Number } dateRight - the earlier date
* @ returns { Number } the number of minutes
* @ throws { TypeError } 2 arguments required
*
* @ example
* // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
* var result = differenceInMinutes (
* new Date ( 2014 , 6 , 2 , 12 , 20 , 0 ) ,
* new Date ( 2014 , 6 , 2 , 12 , 7 , 59 )
* )
* //=> 12
*
* @ example
* // How many minutes are from 10:01:59 to 10:00:00
* var result = differenceInMinutes (
* new Date ( 2000 , 0 , 1 , 10 , 0 , 0 ) ,
* new Date ( 2000 , 0 , 1 , 10 , 1 , 59 )
* )
* //=> -1
* /
function differenceInMinutes ( dirtyDateLeft , dirtyDateRight ) {
( 0 , _index2 . default ) ( 2 , arguments ) ;
var diff = ( 0 , _index . default ) ( dirtyDateLeft , dirtyDateRight ) / MILLISECONDS _IN _MINUTE ;
return diff > 0 ? Math . floor ( diff ) : Math . ceil ( diff ) ;
}
2021-01-03 12:13:05 +00:00
} , { "../differenceInMilliseconds/index.js" : "H70G" , "../_lib/requiredArgs/index.js" : "kK6Q" } ] , "kcC2" : [ function ( require , module , exports ) {
2020-08-13 07:47:25 +00:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _differenceInMinutes = _interopRequireDefault ( require ( "date-fns/differenceInMinutes" ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2021-01-03 12:13:05 +00:00
const calcLoyalty = ( ennobledAt , speed ) => {
2020-08-13 07:47:25 +00:00
let loyalty = 25 + Math . abs ( ( 0 , _differenceInMinutes . default ) ( ennobledAt , new Date ( ) ) ) * ( speed / 60 ) ;
if ( loyalty > 100 ) {
loyalty = 100 ;
}
return Math . floor ( loyalty ) ;
} ;
2021-01-03 12:13:05 +00:00
var _default = calcLoyalty ;
2020-08-13 07:47:25 +00:00
exports . default = _default ;
2021-01-01 17:03:36 +00:00
} , { "date-fns/differenceInMinutes" : "oGJj" } ] , "J1Ly" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
var _default = function _default ( ) {
let server = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
return server . substr ( 0 , 2 ) ;
} ;
exports . default = _default ;
} , { } ] , "gvXE" : [ function ( require , module , exports ) {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . buildVillageURL = exports . buildTribeURL = exports . buildPlayerURL = exports . buildURLToProfile = exports . buildURLToServerPage = exports . BASE _URL = void 0 ;
const BASE _URL = 'tribalwarshelp.com' ;
exports . BASE _URL = BASE _URL ;
const buildURLToServerPage = function buildURLToServerPage ( ) {
let version = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
let server = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ;
return "https://" . concat ( version , "." ) . concat ( BASE _URL , "/server/" ) . concat ( server ) ;
} ;
exports . buildURLToServerPage = buildURLToServerPage ;
const buildURLToProfile = function buildURLToProfile ( ) {
let version = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
let server = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ;
let id = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 0 ;
let entity = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : '' ;
return "" . concat ( buildURLToServerPage ( version , server ) , "/" ) . concat ( entity , "/" ) . concat ( id ) ;
} ;
exports . buildURLToProfile = buildURLToProfile ;
const buildPlayerURL = function buildPlayerURL ( ) {
let version = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
let server = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ;
let id = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 0 ;
return buildURLToProfile ( version , server , id , 'player' ) ;
} ;
exports . buildPlayerURL = buildPlayerURL ;
const buildTribeURL = function buildTribeURL ( ) {
let version = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
let server = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ;
let id = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 0 ;
return buildURLToProfile ( version , server , id , 'tribe' ) ;
} ;
exports . buildTribeURL = buildTribeURL ;
const buildVillageURL = function buildVillageURL ( ) {
let version = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : '' ;
let server = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : '' ;
let id = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 0 ;
return buildURLToProfile ( version , server , id , 'village' ) ;
} ;
exports . buildVillageURL = buildVillageURL ;
} , { } ] , "tKRp" : [ function ( require , module , exports ) {
2020-07-20 13:37:38 +00:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
const translations = {
pl _PL : {
date : 'Data' ,
newOwner : 'Nowy właściciel' ,
2020-09-17 10:26:43 +00:00
oldOwner : 'Poprzedni właściciel' ,
2020-07-20 13:37:38 +00:00
village : 'Wioska' ,
title : 'Przejęcia'
} ,
en _DK : {
date : 'Date' ,
newOwner : 'New owner' ,
oldOwner : 'Old owner' ,
village : 'Village' ,
title : 'Ennoblements'
2021-05-08 07:56:55 +00:00
} ,
de _DE : {
date : 'Datum' ,
newOwner : 'Neuer Besitzer' ,
oldOwner : 'Alter Besitzer' ,
village : 'Dorf' ,
title : 'Adelungen'
2020-07-20 13:37:38 +00:00
}
} ;
var _default = ( ) => translations [ window . game _data . locale ] || translations . en _DK ;
2020-07-18 10:38:26 +00:00
exports . default = _default ;
2020-07-20 12:07:57 +00:00
} , { } ] , "chDM" : [ function ( require , module , exports ) {
2020-07-18 10:38:26 +00:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
2020-08-14 11:34:14 +00:00
exports . default = exports . POPUP _SELECTOR = void 0 ;
2021-01-14 16:51:10 +00:00
const POPUP _SELECTOR = '.popup_box' ;
2020-08-14 11:34:14 +00:00
exports . POPUP _SELECTOR = POPUP _SELECTOR ;
2020-07-18 10:38:26 +00:00
2021-01-14 16:51:10 +00:00
const showPopup = function showPopup ( ) {
2020-07-18 10:38:26 +00:00
let {
html ,
2021-01-14 16:51:10 +00:00
id ,
title
2020-07-18 10:38:26 +00:00
} = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
2021-01-14 16:51:10 +00:00
Dialog . show ( id , "<h3>" . concat ( title , "</h3>" ) + html ) ;
2020-07-18 10:38:26 +00:00
const popup = document . querySelector ( POPUP _SELECTOR ) ;
if ( popup ) {
popup . style . width = 'auto' ;
2020-07-21 13:53:42 +00:00
popup . style . maxWidth = '1000px' ;
}
2020-07-18 10:38:26 +00:00
} ;
2021-01-14 16:51:10 +00:00
var _default = showPopup ;
2020-07-18 10:38:26 +00:00
exports . default = _default ;
2020-08-05 19:10:42 +00:00
} , { } ] , "vNT1" : [ function ( require , module , exports ) {
2020-07-18 10:38:26 +00:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , {
value : true
} ) ;
exports . default = void 0 ;
2020-07-20 13:37:38 +00:00
var _showEnnoblementsPopup = _interopRequireDefault ( require ( "../i18n/showEnnoblementsPopup" ) ) ;
2020-07-22 14:19:44 +00:00
var _pagination = require ( "../utils/pagination" ) ;
2020-07-18 10:38:26 +00:00
2020-07-22 14:19:44 +00:00
var _showPopup = _interopRequireDefault ( require ( "../utils/showPopup" ) ) ;
2020-07-18 10:38:26 +00:00
2021-01-17 15:21:47 +00:00
var _date = require ( "../utils/date" ) ;
2020-07-18 10:38:26 +00:00
2021-01-03 12:13:05 +00:00
var twutils = _interopRequireWildcard ( require ( "../utils/tribalwars" ) ) ;
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
2020-07-18 10:38:26 +00:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2020-07-20 12:07:57 +00:00
const PAGINATION _CONTAINER _ID = 'ennoblementsPagination' ;
2020-07-20 13:37:38 +00:00
const translations = ( 0 , _showEnnoblementsPopup . default ) ( ) ;
2020-07-18 10:38:26 +00:00
const getPlayerTd = ( player , tribe ) => {
if ( player ) {
2021-01-03 12:13:05 +00:00
return "<td><a href=\"" . concat ( twutils . buildPlayerURL ( player . id ) , "\">" ) . concat ( player . name , " (" ) . concat ( tribe ? "<a href=\"" . concat ( twutils . buildTribeURL ( tribe . id ) , "\">" ) . concat ( tribe . tag , "</a>" ) : '-' , ")</a></td>" ) ;
2020-07-18 10:38:26 +00:00
}
return '<td>-</td>' ;
} ;
var _default = function _default ( e , ennoblements ) {
let {
limit = 0 ,
currentPage = 1 ,
onPageChange = ( ) => { }
} = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
const paginationItems = ( 0 , _pagination . generatePaginationItems ) ( {
total : ennoblements . total ,
limit ,
currentPage
} ) ;
2020-07-20 13:37:38 +00:00
const html = "\n <div style=\"" . concat ( ( 0 , _pagination . getContainerStyles ) ( ) , "\" id=\"" ) . concat ( PAGINATION _CONTAINER _ID , "\">\n " ) . concat ( paginationItems . join ( '' ) , "\n </div>\n <table class=\"vis\" style=\"border-collapse: separate; border-spacing: 2px; width: 100%;\">\n <tbody>\n <tr>\n <th>\n " ) . concat ( translations . date , "\n </th>\n <th>\n " ) . concat ( translations . village , "\n </th>\n <th>\n " ) . concat ( translations . newOwner , "\n </th>\n <th>\n " ) . concat ( translations . oldOwner , "\n </th>\n </tr>\n " ) . concat ( ennoblements . items . map ( ennoblement => {
2021-01-17 15:21:47 +00:00
let rowHTML = '<tr>' + "<td>" . concat ( ( 0 , _date . formatDate ) ( ennoblement . ennobledAt ) , "</td>" ) ;
2020-07-18 10:38:26 +00:00
if ( ennoblement . village ) {
2021-01-03 12:13:05 +00:00
rowHTML += "<td><a href=\"" . concat ( twutils . buildVillageURL ( ennoblement . village . id ) , "\">" ) . concat ( twutils . buildVillageName ( ennoblement . village . name , ennoblement . village . x , ennoblement . village . y ) , "</a></td>" ) ;
2020-07-18 10:38:26 +00:00
} else {
rowHTML += '<td>-</td>' ;
}
rowHTML += getPlayerTd ( ennoblement . newOwner , ennoblement . newOwnerTribe ) ;
rowHTML += getPlayerTd ( ennoblement . oldOwner , ennoblement . oldOwnerTribe ) ;
return rowHTML + '</tr>' ;
} ) . join ( '' ) , "\n </tbody>\n </table>\n " ) ;
2020-07-20 12:07:57 +00:00
( 0 , _showPopup . default ) ( {
2020-07-18 10:38:26 +00:00
e ,
2020-07-20 13:37:38 +00:00
title : translations . title ,
2020-07-18 10:38:26 +00:00
id : 'ennoblements' ,
html
} ) ;
2020-07-20 12:07:57 +00:00
document . querySelectorAll ( '#' + PAGINATION _CONTAINER _ID + ' a' ) . forEach ( el => {
2020-07-18 10:38:26 +00:00
el . addEventListener ( 'click' , onPageChange ) ;
} ) ;
} ;
exports . default = _default ;
2021-01-17 15:21:47 +00:00
} , { "../i18n/showEnnoblementsPopup" : "tKRp" , "../utils/pagination" : "fCHX" , "../utils/showPopup" : "chDM" , "../utils/date" : "ZbyX" , "../utils/tribalwars" : "fHHP" } ] , "UdfQ" : [ function ( require , module , exports ) {
2020-07-18 10:38:26 +00:00
"use strict" ;
var _requestCreator = _interopRequireDefault ( require ( "./libs/requestCreator" ) ) ;
2020-07-22 14:19:44 +00:00
var _extendedVillageProfile = _interopRequireDefault ( require ( "./i18n/extendedVillageProfile" ) ) ;
2020-07-18 10:38:26 +00:00
var _pagination = require ( "./utils/pagination" ) ;
var _getCurrentServer = _interopRequireDefault ( require ( "./utils/getCurrentServer" ) ) ;
var _getIDFromURL = _interopRequireDefault ( require ( "./utils/getIDFromURL" ) ) ;
2020-08-07 13:50:26 +00:00
var _buildUnitImgURL = _interopRequireDefault ( require ( "./utils/buildUnitImgURL" ) ) ;
2021-01-17 15:21:47 +00:00
var _date = require ( "./utils/date" ) ;
2020-08-13 07:47:25 +00:00
2020-08-07 13:50:26 +00:00
var _wait = _interopRequireDefault ( require ( "./utils/wait" ) ) ;
var _localStorage = require ( "./utils/localStorage" ) ;
2021-01-03 12:13:05 +00:00
var _calcLoyalty = _interopRequireDefault ( require ( "./utils/calcLoyalty" ) ) ;
2020-08-13 07:47:25 +00:00
2021-01-01 17:03:36 +00:00
var _getServerVersionCode = _interopRequireDefault ( require ( "./utils/getServerVersionCode" ) ) ;
2021-01-03 12:13:05 +00:00
var twhelputils = _interopRequireWildcard ( require ( "./utils/twhelp" ) ) ;
2021-01-01 17:03:36 +00:00
2020-07-22 14:19:44 +00:00
var _showEnnoblementsPopup = _interopRequireDefault ( require ( "./common/showEnnoblementsPopup" ) ) ;
2020-07-18 10:38:26 +00:00
2021-01-03 12:13:05 +00:00
function _getRequireWildcardCache ( ) { if ( typeof WeakMap !== "function" ) return null ; var cache = new WeakMap ( ) ; _getRequireWildcardCache = function ( ) { return cache ; } ; return cache ; }
function _interopRequireWildcard ( obj ) { if ( obj && obj . _ _esModule ) { return obj ; } if ( obj === null || typeof obj !== "object" && typeof obj !== "function" ) { return { default : obj } ; } var cache = _getRequireWildcardCache ( ) ; if ( cache && cache . has ( obj ) ) { return cache . get ( obj ) ; } var newObj = { } ; var hasPropertyDescriptor = Object . defineProperty && Object . getOwnPropertyDescriptor ; for ( var key in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , key ) ) { var desc = hasPropertyDescriptor ? Object . getOwnPropertyDescriptor ( obj , key ) : null ; if ( desc && ( desc . get || desc . set ) ) { Object . defineProperty ( newObj , key , desc ) ; } else { newObj [ key ] = obj [ key ] ; } } } newObj . default = obj ; if ( cache ) { cache . set ( obj , newObj ) ; } return newObj ; }
2020-07-18 10:38:26 +00:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2020-08-07 13:50:26 +00:00
function ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
function _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { _defineProperty ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
2020-07-18 10:38:26 +00:00
// ==UserScript==
2020-08-15 11:11:11 +00:00
// @name Extended village profile
2020-07-18 10:38:26 +00:00
// @namespace https://github.com/tribalwarshelp/scripts
// @updateURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedVillageProfile.js
// @downloadURL https://raw.githubusercontent.com/tribalwarshelp/scripts/master/dist/extendedVillageProfile.js
2021-01-17 15:21:47 +00:00
// @version 0.7.6
2020-08-15 11:11:11 +00:00
// @description Extended village profile
2021-01-17 08:20:19 +00:00
// @author Kichiyaki https://dwysokinski.me/
2020-07-19 19:35:07 +00:00
// @match *://*/game.php*screen=info_village*
2020-07-18 10:38:26 +00:00
// @grant none
// @run-at document-end
// ==/UserScript==
const SERVER = ( 0 , _getCurrentServer . default ) ( ) ;
const VILLAGE _ID = ( 0 , _getIDFromURL . default ) ( window . location . search ) ;
2020-11-21 14:01:40 +00:00
const LAST _CONQUER _QUERY = "\n query ennoblements($server: String!, $limit: Int, $sort: [String!], $filter: EnnoblementFilter!) {\n ennoblements(server: $server, limit: $limit, sort: $sort, filter: $filter) {\n items {\n ennobledAt\n village {\n id\n }\n }\n }\n }\n" ;
const ENNOBLEMENTS _QUERY = "\n query ennoblements($server: String!, $offset: Int, $limit: Int, $sort: [String!], $filter: EnnoblementFilter!) {\n ennoblements(server: $server, offset: $offset, limit: $limit, sort: $sort, filter: $filter) {\n total\n items {\n village {\n id\n name\n x\n y\n }\n oldOwner {\n id\n name\n }\n oldOwnerTribe {\n id\n tag\n }\n newOwner {\n id\n name\n }\n newOwnerTribe {\n id\n tag\n }\n ennobledAt\n }\n }\n }\n" ;
2020-07-18 10:38:26 +00:00
const ENNOBLEMENTS _PER _PAGE = 15 ;
2020-08-13 07:47:25 +00:00
const CURR _SERVER _CONFIG = "\n query server($key: String!) {\n server(key: $key) {\n config {\n speed\n }\n unitConfig {\n spear {\n pop\n }\n sword {\n pop\n }\n axe {\n pop\n }\n archer {\n pop\n }\n spy {\n pop\n }\n light {\n pop\n }\n marcher {\n pop\n }\n heavy {\n pop\n }\n ram {\n pop\n }\n catapult {\n pop\n }\n knight {\n pop\n }\n snob {\n pop\n }\n }\n }\n }\n" ;
2020-08-07 13:50:26 +00:00
const SERVER _CONFIG _LOCAL _STORAGE _KEY = 'kiszkowaty_extended_village_profile_server_cfg' ;
2020-08-13 07:47:25 +00:00
const actionContainer = document . querySelector ( '#content_value > table > tbody > tr > td:nth-child(1) > table:nth-child(2) > tbody' ) ;
const additionalInfoContainer = document . querySelector ( '#content_value table.vis tbody' ) ;
2020-08-07 13:50:26 +00:00
let serverConfig = { } ;
2020-07-22 14:19:44 +00:00
const translations = ( 0 , _extendedVillageProfile . default ) ( ) ;
2020-07-18 10:38:26 +00:00
2020-08-07 13:50:26 +00:00
const loadConfigFromLocalStorage = ( ) => {
return ( 0 , _localStorage . getItem ) ( SERVER _CONFIG _LOCAL _STORAGE _KEY ) ;
} ;
const cacheServerConfig = function cacheServerConfig ( ) {
let data = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
( 0 , _localStorage . setItem ) ( SERVER _CONFIG _LOCAL _STORAGE _KEY , data ) ;
} ;
const isConfigExpired = date => {
return Math . abs ( date . getTime ( ) - new Date ( ) . getTime ( ) ) > 1000 * 60 * 60 * 24 ;
} ;
const loadConfig = async ( ) => {
let data = loadConfigFromLocalStorage ( ) ;
2020-08-13 07:47:25 +00:00
if ( ! data . server || isConfigExpired ( new Date ( data . loadedAt ) ) || ! data . server . unitConfig || ! data . server . config ) {
2020-08-07 13:50:26 +00:00
data = await ( 0 , _requestCreator . default ) ( {
query : CURR _SERVER _CONFIG ,
variables : {
key : SERVER
}
} ) ;
data . loadedAt = new Date ( ) ;
cacheServerConfig ( data ) ;
}
return data . server ;
} ;
2020-08-13 07:47:25 +00:00
const loadPageData = async ( ) => {
let data = await ( 0 , _requestCreator . default ) ( {
query : LAST _CONQUER _QUERY ,
variables : {
server : SERVER ,
filter : {
2020-11-21 14:01:40 +00:00
villageID : [ VILLAGE _ID ]
} ,
sort : [ 'ennobledAt DESC' ] ,
limit : 1
2020-08-13 07:47:25 +00:00
}
} ) ;
return data ;
} ;
2020-07-18 10:38:26 +00:00
const handleShowTribeEnnoblementsClick = async e => {
e . preventDefault ( ) ;
const page = ( 0 , _pagination . getPage ) ( e . target ) ;
if ( ! isNaN ( page ) ) {
const data = await ( 0 , _requestCreator . default ) ( {
query : ENNOBLEMENTS _QUERY ,
variables : {
filter : {
2020-11-21 14:01:40 +00:00
villageID : [ VILLAGE _ID ]
2020-07-18 10:38:26 +00:00
} ,
2020-11-21 14:01:40 +00:00
offset : ENNOBLEMENTS _PER _PAGE * ( page - 1 ) ,
limit : ENNOBLEMENTS _PER _PAGE ,
sort : [ 'ennobledAt DESC' ] ,
2020-07-18 10:38:26 +00:00
server : SERVER
}
} ) ;
2020-07-20 12:07:57 +00:00
( 0 , _showEnnoblementsPopup . default ) ( e , data . ennoblements , {
2020-07-18 10:38:26 +00:00
currentPage : page ,
limit : ENNOBLEMENTS _PER _PAGE ,
onPageChange : handleShowTribeEnnoblementsClick
} ) ;
}
} ;
2020-08-07 13:50:26 +00:00
const buildCellsForIncSupport = units => {
const cells = [ ] ;
let pop = 0 ;
for ( let unit in units ) {
pop += units [ unit ] * serverConfig . unitConfig [ unit ] . pop ;
cells . push ( "<td>" . concat ( units [ unit ] . toLocaleString ( ) , "</td>" ) ) ;
}
cells . push ( "<td><strong>" . concat ( pop . toLocaleString ( ) , "</strong></td>" ) ) ;
return cells ;
} ;
const handleCountIncomingSupportClick = async e => {
e . preventDefault ( ) ;
const ids = [ ] ;
const allyCommand = { } ;
document . querySelectorAll ( 'span.command_hover_details[data-command-type="support"]' ) . forEach ( el => {
const id = parseInt ( el . getAttribute ( 'data-command-id' ) ) ;
if ( el . classList . contains ( 'commandicon-ally' ) ) {
allyCommand [ id ] = true ;
} else {
allyCommand [ id ] = false ;
}
ids . push ( id ) ;
} ) ;
const mySupport = {
spear : 0 ,
sword : 0 ,
axe : 0 ,
archer : 0 ,
spy : 0 ,
light : 0 ,
marcher : 0 ,
heavy : 0 ,
ram : 0 ,
catapult : 0 ,
knight : 0 ,
snob : 0
} ;
const allySupport = _objectSpread ( { } , mySupport ) ;
const total = _objectSpread ( { } , mySupport ) ;
for ( let i = 0 ; i < ids . length ; i ++ ) {
Dialog . show ( 'incomingSupport' , "" . concat ( translations . loaded , ": <strong>" ) . concat ( i , " / " ) . concat ( ids . length , "</strong>" ) ) ;
const id = ids [ i ] ;
const url = TribalWars . buildURL ( '' , {
screen : 'info_command' ,
ajax : 'details' ,
id
} ) ;
try {
const resp = await fetch ( url ) ;
const {
units
} = await resp . json ( ) ;
if ( units ) {
for ( let unit in mySupport ) {
const count = parseInt ( units [ unit ] . count ) ;
if ( allyCommand [ id ] ) {
allySupport [ unit ] += count ;
} else {
mySupport [ unit ] += count ;
}
total [ unit ] += count ;
}
}
await ( 0 , _wait . default ) ( 200 ) ;
} catch ( error ) {
console . log ( 'count incoming support' , error ) ;
}
}
const ths = [ '<th></th>' ] ;
for ( let unit in mySupport ) {
ths . push ( "<th><img src=\"" . concat ( ( 0 , _buildUnitImgURL . default ) ( unit ) , "\" /></th>" ) ) ;
}
ths . push ( "<th>" . concat ( translations . pop , "</th>" ) ) ;
const mySupportCells = [ "<th>" . concat ( translations . mySupport , "</th>" ) , ... buildCellsForIncSupport ( mySupport ) ] ;
const allySupportCells = [ "<th>" . concat ( translations . allySupport , "</th>" ) , ... buildCellsForIncSupport ( allySupport ) ] ;
const totalCells = [ "<th>" . concat ( translations . total , "</th>" ) , ... buildCellsForIncSupport ( total ) ] ;
Dialog . show ( 'incomingSupport' , "\n <table class=\"vis\" style=\"width: 100%;\">\n <tbody>\n <tr>\n " . concat ( ths . join ( '' ) , "\n </tr>\n <tr>\n " ) . concat ( mySupportCells . join ( '' ) , "\n </tr>\n <tr>\n " ) . concat ( allySupportCells . join ( '' ) , "\n </tr>\n <tr>\n " ) . concat ( totalCells . join ( '' ) , "\n </tr>\n </tbody>\n </table>\n " ) ) ;
const popup = document . querySelector ( '.popup_box' ) ;
if ( popup ) {
popup . style . width = 'auto' ;
popup . style . maxWidth = '900px' ;
}
} ;
2020-07-18 10:38:26 +00:00
const wrapAction = action => {
const actionWrapperTd = document . createElement ( 'td' ) ;
actionWrapperTd . colSpan = '2' ;
actionWrapperTd . append ( action ) ;
const actionWrapperTr = document . createElement ( 'tr' ) ;
actionWrapperTr . appendChild ( actionWrapperTd ) ;
return actionWrapperTr ;
} ;
const renderActions = ( ) => {
2021-01-01 17:03:36 +00:00
const linkToTWHelp = document . createElement ( 'a' ) ;
2021-01-03 12:13:05 +00:00
linkToTWHelp . href = twhelputils . buildVillageURL ( ( 0 , _getServerVersionCode . default ) ( SERVER ) , SERVER , VILLAGE _ID ) ;
2021-01-01 17:03:36 +00:00
linkToTWHelp . innerHTML = translations . action . linkToTWHelp ;
actionContainer . appendChild ( wrapAction ( linkToTWHelp ) ) ;
2020-07-20 12:07:57 +00:00
const showEnnoblementsPopup = document . createElement ( 'a' ) ;
showEnnoblementsPopup . href = '#' ;
( 0 , _pagination . setPage ) ( showEnnoblementsPopup , '1' ) ;
2020-07-22 14:19:44 +00:00
showEnnoblementsPopup . innerHTML = translations . action . showEnnoblements ;
2020-07-20 12:07:57 +00:00
showEnnoblementsPopup . addEventListener ( 'click' , handleShowTribeEnnoblementsClick ) ;
2020-08-13 07:47:25 +00:00
actionContainer . appendChild ( wrapAction ( showEnnoblementsPopup ) ) ;
2020-08-07 13:50:26 +00:00
const countIncomingSupport = document . createElement ( 'a' ) ;
countIncomingSupport . href = '#' ;
countIncomingSupport . innerHTML = translations . action . countIncomingSupport ;
countIncomingSupport . addEventListener ( 'click' , handleCountIncomingSupportClick ) ;
2020-08-13 07:47:25 +00:00
actionContainer . appendChild ( wrapAction ( countIncomingSupport ) ) ;
} ;
const renderTr = ( _ref ) => {
let {
title ,
data ,
id
} = _ref ;
let tr = document . querySelector ( '#' + id ) ;
if ( ! tr ) {
tr = document . createElement ( 'tr' ) ;
tr . id = id ;
tr . appendChild ( document . createElement ( 'td' ) ) ;
tr . appendChild ( document . createElement ( 'td' ) ) ;
additionalInfoContainer . append ( tr ) ;
}
tr . children [ 0 ] . innerHTML = title ;
tr . children [ 1 ] . innerHTML = data ;
} ;
2020-09-17 10:26:43 +00:00
const countUnitsInVillage = ( ) => {
2020-08-16 14:33:40 +00:00
const trs = document . querySelectorAll ( '#content_value > div tbody tr' ) ;
const units = [ ] ;
if ( trs . length === 0 ) throw new Error ( ) ;
trs [ 0 ] . querySelectorAll ( '.unit_link' ) . forEach ( ( ) => {
units . push ( 0 ) ;
} ) ;
for ( let i = 1 ; i < trs . length ; i ++ ) {
const tr = trs [ i ] ;
tr . querySelectorAll ( '.unit-item' ) . forEach ( ( td , index ) => {
units [ index ] += parseInt ( td . innerHTML ) ;
} ) ;
}
return units ;
} ;
2020-08-13 07:47:25 +00:00
const renderAdditionalInfo = function renderAdditionalInfo ( ) {
let {
config ,
ennoblements
} = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
const firstEnnoblement = ennoblements && Array . isArray ( ennoblements . items ) && ennoblements . items [ 0 ] ? ennoblements . items [ 0 ] : undefined ;
renderTr ( {
id : 'loyalty' ,
2020-08-13 09:28:03 +00:00
title : "" . concat ( translations . possibleLoyalty , ":" ) ,
2021-01-03 12:13:05 +00:00
data : firstEnnoblement ? ( 0 , _calcLoyalty . default ) ( new Date ( firstEnnoblement . ennobledAt ) , config . speed ) : 100
2020-08-13 07:47:25 +00:00
} ) ;
renderTr ( {
id : 'ennobledAt' ,
2020-08-13 09:28:03 +00:00
title : "" . concat ( translations . ennobledAt , ":" ) ,
2021-01-17 15:21:47 +00:00
data : firstEnnoblement ? ( 0 , _date . formatDate ) ( firstEnnoblement . ennobledAt ) : translations . never
2020-08-13 07:47:25 +00:00
} ) ;
2020-08-16 14:33:40 +00:00
try {
2020-09-17 10:26:43 +00:00
const units = countUnitsInVillage ( ) ;
2020-08-16 14:33:40 +00:00
const tr = document . createElement ( 'tr' ) ;
tr . style . textAlign = 'center' ;
tr . style . fontWeight = 'bold' ;
tr . appendChild ( document . createElement ( 'td' ) ) ;
2020-09-17 10:26:43 +00:00
units . forEach ( count => {
2020-08-16 14:33:40 +00:00
const td = document . createElement ( 'td' ) ;
2020-09-17 10:26:43 +00:00
td . innerHTML = count ;
2020-08-16 14:33:40 +00:00
tr . appendChild ( td ) ;
} ) ;
document . querySelector ( '#content_value > div tbody' ) . appendChild ( tr ) ;
} catch ( error ) { }
2020-07-18 10:38:26 +00:00
} ;
2020-08-07 13:50:26 +00:00
( async function ( ) {
try {
2020-08-13 07:47:25 +00:00
const pageData = await loadPageData ( ) ;
2020-08-07 13:50:26 +00:00
serverConfig = await loadConfig ( ) ;
2020-08-13 07:47:25 +00:00
renderAdditionalInfo ( {
config : serverConfig . config ,
ennoblements : pageData . ennoblements
} ) ;
2020-08-07 13:50:26 +00:00
renderActions ( ) ;
} catch ( error ) {
console . log ( 'extended village profile' , error ) ;
}
2020-07-18 10:38:26 +00:00
} ) ( ) ;
2021-01-17 15:21:47 +00:00
} , { "./libs/requestCreator" : "Ph2E" , "./i18n/extendedVillageProfile" : "LNef" , "./utils/pagination" : "fCHX" , "./utils/getCurrentServer" : "DMkL" , "./utils/getIDFromURL" : "tQUs" , "./utils/buildUnitImgURL" : "KX6P" , "./utils/date" : "ZbyX" , "./utils/wait" : "oUdd" , "./utils/localStorage" : "KWxH" , "./utils/calcLoyalty" : "kcC2" , "./utils/getServerVersionCode" : "J1Ly" , "./utils/twhelp" : "gvXE" , "./common/showEnnoblementsPopup" : "vNT1" } ] } , { } , [ "UdfQ" ] , null )