// ==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.3
// @supportURL
// @grant none
// @downloadURL none
// ==/UserScript==
TWPT_inject = function () {
if (document.getElementById('TWPT_js'))
{
alert('Script already installed');
return;
}
var twpdjs = document.createElement('script');
twpdjs.setAttribute('type', 'text/javascript');
twpdjs.setAttribute('language', 'javascript');
twpdjs.setAttribute('id', 'TWPT_js');
twpdjs.innerHTML = '(' + (function () {
version = '0.3',
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 = 'https://greasyfork.org/scripts/7391',
TheWestApi.register('TW-Mbb', name, min_gameversion, max_gameversion, author, website).setGui('
Market utility for highlighting the best bids.
Green – Bid is lower than the purchase price.
Black - Bid is equal to the purchase price.
Blue – Bid is between 100% and 200% of the purchase price.
Red – Bid is more than 200% of the purchase price.
' + name + ' v' + version + '');
var windows = document.getElementById('windows');
windows.addEventListener('DOMNodeInserted', OnNodeInserted, false);
function OnNodeInserted(event) {
if ($('#market_buytable').length) {
var szakup = document.getElementById('market_buytable');
//var produkty = zakup.getElementsByClassName("row");
//var nrow=produkty.length-1;
setTimeout(colorize(szakup), 1000);
}
}
function colorize(zakup) {
var zakup = zakup;
var produkty = zakup.getElementsByClassName('row');
var nrow = produkty.length - 1;
// Ilość sprzedawanych szt //Ricavo la quantità dei pezzi in vendita
var il = produkty[nrow].getElementsByClassName('mpb_stack'); // pobranie ilości
il = il[0].getElementsByTagName('div');
il = il[0].textContent;
// Cena kup teraz //Ricavo il compra subito dell'oggetto in vendita
if (produkty[nrow].getElementsByClassName('mpb_buynow')) {
var cena_oryginalna = produkty[nrow].getElementsByClassName('mpb_buynow'); // pobranie ceny kup teraz //PREZZO COMPRA ORA ASTA
kupno = cena_oryginalna[0].textContent;
kupno = kupno.replace('$', '');
kupno = kupno.replace(/\./g, '');
kupno = kupno.replace(/\,/g, ''); // usunięcie z ceny bez przecinków i kropek oraz $ //PREZZO COMPRA ORA SENZA PUNTI(ITA), VIRGOLE(ENG) E $
}
// Cena aukcyjna //Rivavo il prezzo d'asta dell'oggetto in vendita
var cenal_oryginalna = produkty[nrow].getElementsByClassName('mpb_bid'); // pobranie ceny licytacji
licyt = cenal_oryginalna[0].textContent;
licyt = licyt.replace('$', '');
licyt = licyt.replace(/\./g, '');
licyt = licyt.replace(/\,/g, '');
var cena = kupno / il;
/*if(!kupno||(licyt cena_obj) && (cena <= cena_obj * 2)) {
cena_oryginalna[0].style.color = 'blue';
cenal_oryginalna[0].style.color = 'blue';
}
if (cena > cena_obj * 2) {
cena_oryginalna[0].style.color = 'red';
cenal_oryginalna[0].style.color = 'red';
}
}
}).toString() + ')();';
document.body.appendChild(twpdjs);
};
if (location.href.indexOf('.the-west.') != - 1 && location.href.indexOf('game.php') != - 1)
setTimeout(TWPT_inject, 2500, false);