This repository has been archived on 2023-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
scripts-old/dist/quickbar/extendedVillageProfile.js

1 line
14 KiB
JavaScript
Raw Normal View History

!function(){const e="https://api.tribalwarshelp.com/graphql";var t=function(){let{query:t,variables:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return fetch(e,{method:"POST",body:JSON.stringify({query:t,variables:n}),headers:{"Content-Type":"application/json"}}).then((e=>e.json())).then((e=>{let{data:t,errors:n}=e;if(n&&Array.isArray(n)&&n.length>0)throw new Error(n[0].message);return new Promise((e=>e(t)))}))};const n={pl_PL:{loaded:"Załadowano",pop:"Populacja",mySupport:"Moje wsparcie",allySupport:"Wsparcie plemienia",total:"Łącznie",possibleLoyalty:"Prawdopodobne poparcie",ennobledAt:"Podbita o",never:"Nigdy",action:{linkToTWHelp:"Akta wioski (TWHelp)",showEnnoblements:"Pokaż przejęcia",countIncomingSupport:"Policz nadchodzące wsparcie"}},en_DK:{loaded:"Loaded",pop:"Pop",mySupport:"My support",allySupport:"Ally support",total:"Total",possibleLoyalty:"Possible loyalty",never:"Never",ennobledAt:"Ennobled at",action:{linkToTWHelp:"Village file (TWHelp)",showEnnoblements:"Show ennoblements",countIncomingSupport:"Count incoming support"}},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"}}};const o="data-page",r=(e,t)=>{if("number"!=typeof e)throw new Error("Expected number as the first argument");if("number"!=typeof t)throw new Error("Expected number as the second argument");return e>0?Math.ceil(e/t):1},a=function(){let{total:e,limit:t,marginRight:n=3,currentPage:a=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=r(e,t),l=[];for(let e=1;e<=i;e++)e===a?l.push('<strong style="margin-right: '.concat(n,'px">>').concat(e,"<</strong>")):l.push('<a style="margin-right: '.concat(n,'px" href="#" ').concat(o,'="').concat(e,'">').concat(e,"</a>"));return l};const i=e=>window.location.origin+TribalWars.buildURL("",{screen:"info_village",id:e}),l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500;const o="K"+String(n)[0]+String(t)[0];return"".concat(e," (").concat(t,"|").concat(n,") ").concat(o)};var c=e=>{return t="unit/unit_".concat(e,".png"),image_base+t;var t};const s=(e,t)=>new Date(e).toLocaleDateString(void 0,t||{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});var d=e=>new Promise((t=>setTimeout(t,e)));const p=(e,t)=>{localStorage.setItem(e,JSON.stringify(t))};function u(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function g(e){u(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(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"),console.warn((new Error).stack)),new Date(NaN))}function h(e,t){u(2,arguments);var n=g(e),o=g(t);return n.getTime()-o.getTime()}const m=(e,t)=>{let n=25+Math.abs(function(e,t){u(2,arguments);var n=h(e,t)/6e4;return n>0?Math.floor(n):Math.ceil(n)}(e,new Date))*(t/60);return n>100&&(n=100),Math.floor(n)};const b="tribalwarshelp.com",f=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"https://".concat(e,".").concat(b,"/server/").concat(t)},y=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return"".concat(f(e,t),"