The West market rework

The West market report icon rework

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name The West market rework
// @description The West market report icon rework
// @author Jaklee
// @version 0.1
// @grant none
// @include http://*.the-west.*/game.php*
// @include https://*.the-west.*/game.php*
// @include http://*.tw.innogames.*/game.php*
// @include https://*.tw.innogames.*/game.php*
// @namespace https://greasyfork.org/users/890912
// ==/UserScript==

(function() {
   checkDOMChange();
})();

function checkDOMChange()
{
    if( document.getElementsByClassName("marketplace").length > 0 )
    {
        document.querySelectorAll('[id^="mpb_marketOfferReport"]').forEach(
        x=>
        {
            var row = x.parentNode.parentNode;
            var offerMsgImg = row.querySelector(".cell_7").querySelector("img"); // Check if there is any "comment" for the offer
            if( offerMsgImg !== null )
            {
                // Replace report icon with more sofisticated warn icon (without brown background...)
                x.src="https://westhu.innogamescdn.com/images/icons/warn_circle.png";
                x.height=16;

                // Relocate the report icon next to the "info" icon
                offerMsgImg.parentNode.insertBefore(x,offerMsgImg);
            }
            else
            {
                // Remove "report" button if there is no message which can be reported...
                x.remove();
            }
        }
        );
    }

    // call the function again after 200 milliseconds
    // TODO Call this function only if market is opened / next page clicked / etc
    setTimeout( checkDOMChange, 200 );
}