AoM Profile Redirector

Adds quick profile navigation buttons for Age of Mythology stats websites.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AoM Profile Redirector
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Adds quick profile navigation buttons for Age of Mythology stats websites.
// @author       Webmaster
// @match        https://freefoodparty.com/aom/*
// @match        https://aomstats.io/profile/*
// @match        https://www.aom.gg/profile/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Extract the player ID from the URL
    let playerId;
    if (window.location.hostname.includes("freefoodparty.com")) {
        playerId = new URLSearchParams(window.location.search).get("idPlayer");
    } else {
        playerId = window.location.pathname.split("/").pop();
    }

    if (!playerId) return;

    // Create container for links
    let container = document.createElement("div");
    container.style = `
        position: fixed;
        bottom: 20px;
        right: 20px;
        display: flex;
        gap: 10px;
        background: rgba(0, 0, 0, 0.7);
        padding: 10px;
        border-radius: 5px;
    `;

    // Define link styles
    const linkStyle = `
        background: #007bff;
        color: white;
        padding: 10px;
        font-size: 16px;
        border-radius: 5px;
        text-decoration: none;
        transition: background 0.3s;
    `;

    const hoverStyle = `background: #0056b3;`;

    // Create the buttons as links
    function createLink(name, url) {
        let link = document.createElement("a");
        link.innerText = name;
        link.href = url;
        link.target = "_blank";
        link.style = linkStyle;
        link.onmouseover = () => link.style.background = "#0056b3";
        link.onmouseout = () => link.style.background = "#007bff";
        container.appendChild(link);
    }

    // Determine which site we are on and add the appropriate links
    if (window.location.hostname.includes("freefoodparty.com")) {
        createLink("AoM Stats", `https://aomstats.io/profile/${playerId}?leaderboard=2`);
        createLink("AoM GG", `https://www.aom.gg/profile/${playerId}`);
    } else if (window.location.hostname.includes("aomstats.io")) {
        createLink("FreeFoodParty", `https://freefoodparty.com/aom/profile?idPlayer=${playerId}`);
        createLink("AoM GG", `https://www.aom.gg/profile/${playerId}`);
    } else if (window.location.hostname.includes("aom.gg")) {
        createLink("FreeFoodParty", `https://freefoodparty.com/aom/profile?idPlayer=${playerId}`);
        createLink("AoM Stats", `https://aomstats.io/profile/${playerId}?leaderboard=2`);
    }

    document.body.appendChild(container);
})();