Greasy Fork

Greasy Fork is available in English.

The West - Market best bids

Market utility for highlighting the best bids.

当前为 2015-01-17 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name The West - Market best bids
// @namespace TomRobert
// @author Esperiano (modified by Darius II; updated by Tom Robert)
// @description Market utility for highlighting the best bids.
// @include http://*.the-west.*/game.php*
// @version 0.4
// @grant none
// ==/UserScript==
TWMBB_inject = function () {
  if (document.getElementById('TWMBB_js'))
  {
    alert('Script already installed');
    return;
  }
  var twmbbjs = document.createElement('script');
  twmbbjs.setAttribute('type', 'text/javascript');
  twmbbjs.setAttribute('language', 'javascript');
  twmbbjs.setAttribute('id', 'TWMBB_js');
  twmbbjs.innerHTML = '(' + (function () {
    version = '0.4',
    name = 'Market best bids',
    author = 'Esperiano (modified by Darius II; updated by Tom Robert)',
    id_scripts = '7391';
    min_gameversion = '2.05';
    max_gameversion = Game.version.toString();
    website = 'http://greasyfork.icu/scripts/7391',
    TheWestApi.register('TWMBB', name, min_gameversion, max_gameversion, author, website).setGui('<br>Market utility for highlighting the best bids.<br><br><span style="color:green;">Green</span> – Bid is lower than the purchase price.<br>Black -  Bid is equal to the purchase price.<br><span style="color:blue;">Blue</span> – Bid is between 100% and 200% of the purchase price.<br><span style="color:red;">Red</span> – Bid is more than 200% of the purchase price.<br><br>The sold item will always have the color of the lowest bid!<br><br><i>' + name + ' v' + version + '</i>');
    var windows = document.getElementById('windows');
    windows.addEventListener('DOMNodeInserted', OnNodeInserted, false);
    function OnNodeInserted(event) {
      if ($('#market_buytable').length) {
        var purchase = document.getElementById('market_buytable');
        var items = purchase.getElementsByClassName('row');
        var nrow = items.length - 1;
        //Anzahl Verkaufsstücke
        var qty = items[nrow].getElementsByClassName('mpb_stack'); //Download Mengen
        qty = qty[0].getElementsByTagName('div');
        qty = qty[0].textContent;
        //Sofortkauf
        if (items[nrow].getElementsByClassName('mpb_buynow')) {
          var purchase_original = items[nrow].getElementsByClassName('mpb_buynow'); //Sofortkauf Download
          purchase = purchase_original[0].textContent;
          purchase = purchase.replace('$', '');
          purchase = purchase.replace(/\./g, '');
          purchase = purchase.replace(/\,/g, ''); //'$', Punkte und Kommas entfernen
        }
        if (purchase) {
          var price_purchase = purchase / qty;
        }
        //Auktionspreis

        var bid_original = items[nrow].getElementsByClassName('mpb_bid'); //Auktionspreis Download
        bid = bid_original[0].textContent;
        bid = bid.replace('$', '');
        bid = bid.replace(/\./g, '');
        bid = bid.replace(/\,/g, '');
        if (bid) {
          var price_bid = bid / qty;
        }
        var name_original = items[nrow].getElementsByClassName('mpb_article'); //Name des Verkaufsgegenstandes
        var item;
        var price_original;
        name = name_original[0].textContent;
        for (i = 0; i < 185206; i++) {
          if (ItemManager.get(i)) {
            item = ItemManager.get(i).name;
            if (item == name) {
              price_original = ItemManager.get(i).price;
            }
          }
        }
        if (price_purchase < price_original) {
          purchase_original[0].style.color = 'green';
          if (!bid) {
            name_original[0].style.color = 'green';
          }
        }
        if ((price_purchase > price_original) && (price_purchase <= price_original * 2)) {
          purchase_original[0].style.color = 'blue';
          if (!bid) {
            name_original[0].style.color = 'blue';
          }
        }
        if (price_purchase > price_original * 2) {
          purchase_original[0].style.color = 'red';
          if (!bid) {
            name_original[0].style.color = 'red';
          }
        }
        if (price_bid < price_original) {
          bid_original[0].style.color = 'green';
          name_original[0].style.color = 'green';
        }
        if ((price_bid > price_original) && (price_bid <= price_original * 2)) {
          bid_original[0].style.color = 'blue';
          name_original[0].style.color = 'blue';
        }
        if (price_bid > price_original * 2) {
          name_original[0].style.color = 'red';
          bid_original[0].style.color = 'red';
        }
      }
    }
  }).toString() + ')();';
  document.body.appendChild(twmbbjs);
};
if (location.href.indexOf('.the-west.') != - 1 && location.href.indexOf('game.php') != - 1)
setTimeout(TWMBB_inject, 2500, false);