// ==UserScript== // @name Tribal Wars - Zrabowane Surowce // @namespace http://tampermonkey.net/ // @version 0.1 // @description Wyświetl zrabowane surowce na profilu gracza w Tribal Wars // @author Nienawisc // @match https://*.plemiona.pl/game.php*screen=info_player* // @grant none // @require http://code.jquery.com/jquery-latest.min.js // @license GNU GPLv3 // @downloadURL none // ==/UserScript== (function() { 'use strict'; function getPlayerName() { const playerNameElement = document.querySelector('#content_value #player_info>tbody>tr>th'); return playerNameElement ? playerNameElement.textContent.trim() : null; } function fetchDailyRanking(playerName) { return new Promise((resolve, reject) => { $.ajax({ url: `/game.php?screen=ranking&mode=in_a_day&type=loot_res&name=${encodeURIComponent(playerName)}`, success: (data) => { const parser = new DOMParser(); const doc = parser.parseFromString(data, 'text/html'); const lootCell = doc.querySelector('#in_a_day_ranking_table tr:nth-child(2) td:nth-child(4)'); const loot = lootCell ? parseInt(lootCell.textContent.trim().replace(/,/g, '').replace('.','')) : 0; resolve(loot); }, error: (xhr, status, error) => { reject(error); } }); }); } function displayLoot(loot) { const container = document.querySelector('#content_value #player_info'); if (container) { const newRow = document.createElement('tr'); newRow.innerHTML = ` Zrabowane surowce (dziennie): ${loot.toLocaleString()} `; container.appendChild(newRow); } } const playerName = getPlayerName(); if (playerName) { fetchDailyRanking(playerName) .then(loot => { displayLoot(loot); }) .catch(error => { console.error('Nie można pobrać danych o zrabowanych surowcach:', error); }); } })();