Flight Rising: Active Dragon to Bio

Instead of sifting through someones lair, clicking the active dragon on the forums or user profile will link directly to the dragon.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Flight Rising: Active Dragon to Bio
// @description  Instead of sifting through someones lair, clicking the active dragon on the forums or user profile will link directly to the dragon.
// @namespace    https://greasyfork.org/en/users/547396
// @author       https://greasyfork.org/en/users/547396
// @match        *.flightrising.com/main.php?p=*&tab=userpage*
// @match        *.flightrising.com/forums/*
// @icon         https://www.google.com/s2/favicons?domain=flightrising.com
// @grant        none
// @version      0.2
// ==/UserScript==

(function() {
    'use strict';

    if (document.URL.includes('tab=userpage')) {
        const avatar = document.querySelector("#userdata > div:nth-child(1) > span:nth-child(5) > span:nth-child(1) > img");
        avatar.style.cursor = 'pointer';
        avatar.addEventListener('click', openDragonBio);
    } else {
        const avatars = document.querySelectorAll('.post-author-avatar > a > img');

        for (let avatar of avatars) {
            avatar.addEventListener('click', openDragonBio);
        }
    }

    function openDragonBio(e) {
        e.preventDefault();

        let avatarSrc = e.target.src.split('/'),
          dID = avatarSrc[avatarSrc.length - 1].split('p.png')[0],
          dURL = 'https://www1.flightrising.com/dragon/' + dID;

        window.location.href = dURL;

    }
})();