// ==UserScript== // @name Extended player profile // @version 1.2.0 // @description Adds additional info and actions on a player overview. // @author Dawid Wysokiński - Kichiyaki - contact@twhelp.app // @match https://*.plemiona.pl/game.php?*screen=info_player* // @icon https://www.google.com/s2/favicons?domain=plemiona.pl // @grant none // @run-at document-end // ==/UserScript== !function(){function e(e,t,r,n){Object.defineProperty(e,t,{get:r,set:n,enumerable:!0,configurable:!0})}function t(e){return e&&e.__esModule?e.default:e}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},n={},o={},i=r.parcelRequire03e0;null==i&&((i=function(e){if(e in n)return n[e].exports;if(e in o){var t=o[e];delete o[e];var r={id:e,exports:{}};return n[e]=r,t.call(r.exports,r,r.exports),r.exports}var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(e,t){o[e]=t},r.parcelRequire03e0=i);var s=i.register;s("cyqxw",function(e,t){// Extended player profile i("1AONd");var r,n,o=i("gxD7Y");i("1eGEI");var s=i("02oNZ"),a=i("cO4wG");i("dn3NW");var l=i("dzS2D"),u=i("hUoNS"),d=i("6AVOj"),f=i("ezORx");let c=(0,s.createTranslationFunc)({pl_PL:{"Joined at":"Dołączył o","Last activity at":"Ostatnio aktywny o","Best rank":"Najwyższy ranking","Most points":"Najwięcej punkt\xf3w","Most villages":"Najwięcej wiosek","Show other servers":"Pokaż inne serwery","Show in a day ranks":"Pokaż dzienne rankingi","Show tribe changes":"Pokaż zmiany plemion","Show history":"Pokaż historię","Show ennoblements":"Pokaż przejęcia","Old tribe":"Stare plemię","New tribe":"Nowe plemię","Date/time":"Data/czas",Village:"Wioska","Old owner":"Stary właściciel","New owner":"Nowy właściciel",Rank:"Ranking",Points:"Punkty",Barbarian:"Barbarzyńska",Unknown:"Nieznany",Server:"Serwer",Deleted:"Usunięty",Yes:"Tak",No:"Nie",Date:"Data",Tribe:"Plemię",Villages:"Wioski",OD:"Pokonani og\xf3lnie","OD - rank":"Pokonani og\xf3lnie - ranking",ODA:"Pokonani agresor","ODA - rank":"Pokonani agresor - ranking",ODD:"Pokonani obrońca","ODD - rank":"Pokonani obrońca - ranking",ODS:"Pokonani wspierający","ODS - rank":"Pokonani wspierający - ranking",Type:"Typ",Score:"Wynik","Units defeated while attacking":"Jednostki pokonane w ataku","Units defeated while defending":"Jednostki pokonane w obronie","Units defeated while supporting":"Jednostki pokonane jako wspierający","Resources plundered":"Zrabowane surowce","Villages plundered":"Splądrowane wioski","Resources gathered":"Zebrane surowce","Villages conquered":"Przejęte wioski",Changes:"Zmiany",Open:"Otwarty",Closed:"Zamknięty"}});class h{async player(){return(await this.client.players.getPlayer({versionCode:this.version,serverKey:this.server,playerId:this.id})).data}async latestSnapshot(){let e=await this.playerSnapshots(void 0,1);return e.data.length>0?e.data[0]:null}playerTribeChanges(e,t){return this.client.tribeChanges.listPlayerTribeChanges({versionCode:this.version,serverKey:this.server,playerId:this.id,limit:t,cursor:e,sort:["createdAt:DESC"]})}playerEnnoblements(e,t){return this.client.ennoblements.listPlayerEnnoblements({versionCode:this.version,serverKey:this.server,playerId:this.id,limit:t,cursor:e,sort:["createdAt:DESC"]})}playerSnapshots(e,t){return this.client.snapshots.listPlayerPlayerSnapshots({versionCode:this.version,serverKey:this.server,playerId:this.id,limit:t,cursor:e,sort:["date:DESC"]})}playerOtherServers(e,t){return this.client.players.listVersionPlayers({versionCode:this.version,limit:t,cursor:e,id:[this.id]})}constructor(e,t,r,n){this.baseUrl=e,this.version=t,this.server=r,this.id=n,this.client=new u.TWHelpClient({BASE:e},l.AxiosHttpRequestWithTimeout)}}class p{player(){return this.cache.load(p.CACHE_KEY_PREFIX+this.name,600,()=>this.client.player(this.name))}constructor(e){this.name=e,this.cache=new f.Cache(localStorage),this.client=new o.InADayClient}}p.CACHE_KEY_PREFIX="extended_player_profile_in_a_day_",(r=n||(n={})).OTHER_SERVERS="extended_player_profile_other_servers",r.IN_A_DAY_RANKS="extended_player_profile_in_a_day_ranks",r.TRIBE_CHANGES="extended_player_profile_tribe_changes",r.ENNOBLEMENTS="extended_player_profile_ennoblements",r.HISTORY="extended_player_profile_history";class v{render(){this.renderAdditionalInfo(),this.renderStats(),this.renderActions()}renderAdditionalInfo(){let e=document.querySelector("#player_info tbody");e instanceof HTMLTableSectionElement&&e.insertAdjacentHTML("beforeend",`
${c("Changes")} | |
---|---|
${e.header} | ${Math.abs(e.value).toLocaleString()} |
${o("Loading")}...
`);try{let{data:t,cursor:r}=await this.loadData(e,this.limit);window.Dialog.show(this.id,` ${this.buildPagination(r)} ${this.buildTable(t)} `),this.addEventListeners(r)}catch(e){console.error(e),window.Dialog.close(),window.UI.ErrorMessage(o("Something went wrong while loading the data"))}}buildPagination(e){return`${e.header} | `).join("")}
---|
${n.accessor(t,r,e)} | `).join("")}