Display Bounty Amounts

Merges hover over label text for bounty reports with the default table body

目前為 2022-11-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Display Bounty Amounts
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Merges hover over label text for bounty reports with the default table body
// @author       Luvaboy
// @license      MIT
// @grant GM_addStyle
// @match        *.travian.com/position_details.php?*
// @match        *.travian.com/build.php?id=39&gid=16&tt=99
// ==/UserScript==

GM_addStyle(`#center #contentOuterContainer.contentPage {
    width: 650px !important;
    translate: -20px;
}`);

GM_addStyle("#raidList .villageWrapper .dropContainer .raidList .raidListContent table td.troops { width: 0px !important; }");

(function() {
    'use strict';

     if (window.location.href.indexOf("build.php") !== -1) {
         setTimeout(exposeLabelTextOnFarmLists, 1000);
     }
     if (window.location.href.indexOf("position_details.php") !== -1) {
         exposeLabelText();
     }

     function exposeLabelText() {
        let reportIcons = document.querySelectorAll(".reportInfoIcon");

        if (reportIcons) {
            for (let i = 0; i < reportIcons.length; i++) {
                // New Element
                const span = document.createElement("span");
                span.innerText = reportIcons[i].alt;

                var colour = "rgb(255 210 210)";

                if (span.innerText.indexOf("/") !== -1) {
                    colour = "rgb(109 235 107 / 56%)";
                }

                span.style.background = colour;
                span.style["border-radius"] = "5px"
                span.style.padding = "2px"
                span.style.margin = "2px 4px"

                // Insert
                reportIcons[i].parentElement.after(span);

                // Tidy up
                reportIcons[i].style.margin = "0px 4px 0px 8px";
                reportIcons[i].style.float = "none";
            }
        }
    }

    function exposeLabelTextOnFarmLists() {
        let carryIcons = document.querySelectorAll(".carry");

        console.log("carryIcons", carryIcons);

        if (carryIcons) {
            for (let i = 0; i < carryIcons.length; i++) {
                // New Element
                if (carryIcons[i].alt) {
                    console.log("carryIcons[i].alt", carryIcons[i].alt);

                    const span = document.createElement("span");
                    let matches = carryIcons[i].alt.match(/\d+/g);

                    if (matches) {
                        span.innerText = matches.map(Number).join("/");
                    }

                    var colour = "rgb(255 210 210)";

                    if (span.innerText.indexOf("/") === -1) {
                        colour = "rgb(109 235 107 / 56%)";
                    }

                    span.style.background = colour;
                    span.style["border-radius"] = "5px";
                    span.style.padding = "2px";
                    span.style.margin = "2px 4px";

                    // Insert
                    carryIcons[i].after(span);
                }

                // Tidy up
                carryIcons[i].style.margin = "0px 4px 0px 8px";
                carryIcons[i].style.float = "none";
            }
        }
    }

})();