Flight Rising - Detect Underpriced Auctions

Detects and highlights Auction House listings where the price is set at or below the autosell cost. If underpriced listings are found, automatically scrolls down to the first one.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Flight Rising - Detect Underpriced Auctions
// @namespace    https://greasyfork.org/users/547396
// @version      0.3
// @description  Detects and highlights Auction House listings where the price is set at or below the autosell cost. If underpriced listings are found, automatically scrolls down to the first one.
// @author       Jicky
// @match        https://www1.flightrising.com/auction-house/buy/*
// @icon         https://www.google.com/s2/favicons?domain=flightrising.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // User-editable values:
    var treasurePerGem = 1500.0;
    var priceOffset = 0;
    var flagColor = 'Gold';

    // FLAGGING
    // ------

    function detectUnderpriced() {
        var underpriced = [];
        var sellValues = parseItemSellValues();
        var listingDivs = document.querySelectorAll('div.ah-listing-row');
        for (const div of listingDivs) {
            let itmId = parseInt(div.getAttribute('data-listing-itemid'));
            let price = parseFloat(div.querySelector('div.ah-listing-sellprice div strong').textContent);
            if (div.querySelector('img.ah-listing-currency-icon').getAttribute('src').includes('gems')) {
                price = (price * treasurePerGem);
            }

            if ((price-priceOffset) <= sellValues[itmId]) {
                flagListing(div)
                underpriced.push(div);
            }
        }
        console.log(`Underpriced listings found: ${underpriced.length}`);
        if (underpriced.length > 0) { underpriced[0].scrollIntoView(); }
        return underpriced;
    }

    function flagListing(div) {
        div.style.backgroundColor = flagColor;
    }

    // PARSING
    // ------

    function parseItemSellValues() {
        var itemSellValues = [];
        var tooltips = document.querySelectorAll('div.itemtip');
        for (const tooltip of tooltips) {
            let id=parseInt(tooltip.getAttribute('id').split("-")[1]);
            let val=parseInt(tooltip.querySelector('div.sellval').textContent);
            itemSellValues[id] = val;
        }
        return itemSellValues;
    }

    detectUnderpriced();

})();