// ==UserScript== // @name Pomocnik Bazarowicza // @namespace http://tampermonkey.net/ // @version 0.1 // @description Pomaga zarządzać swoimi ofertami sprzedaży na bazar.lowcygier.pl / Helps managing offers at bazar.lowcygier.pl // @author nochalon // @match https://bazar.lowcygier.pl/offer/my* // @icon https://bazar.lowcygier.pl/favicon.ico // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; var re = /\d+\.\d+ zł/g; var ths = document.getElementsByClassName("fa fa-usd icon-sm"); for (var i = 0; i < ths.length; i++) { var content = ths[i].getAttribute("data-original-title").match(re); var lowestPrice = document.createElement("div"); lowestPrice.innerHTML = content; lowestPrice.classList.add("trader"); var priceElem = ths[i].parentNode.parentNode.parentNode.querySelectorAll(".prc-offert")[0]; var myPrice = document.createElement("div"); var myPriceVal = parseFloat(priceElem.innerHTML); var lowestPriceVal = parseFloat(content); var difference = myPriceVal - lowestPriceVal; if (difference < myPriceVal * 0.05) { myPrice.style.color="#00E000"; } else if (difference < myPriceVal * 0.1) { myPrice.style.color="#5DE000"; } else if (difference < myPriceVal * 0.2) { myPrice.style.color="#B9E000"; } else if (difference > myPriceVal * 0.7) { myPrice.style.color="#E00000"; } else if (difference > myPriceVal * 0.5) { myPrice.style.color="#E1E100"; } myPrice.innerHTML = priceElem.innerHTML; priceElem.innerHTML = ""; priceElem.appendChild(myPrice); priceElem.appendChild(lowestPrice); } })();