The West market rework

The West market report icon rework

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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 );
}