loconejo / PVU_MARKER

// ==UserScript==
// @name         PVU_MARKER
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  PVU MARKET
// @author       Loconejo
// @match        https://marketplace.plantvsundead.com/*
// @icon         https://www.google.com/s2/favicons?domain=plantvsundead.com
// @grant        none
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @copyright 2021, loconejo (https://openuserjs.org/users/loconejo)
// @license MIT

// ==/UserScript==

(function () {

  setInterval(function () {

    $(".tw-grid").each(function (index) {
      var num1 = 0;
      var num2 = 0;
      num1 = parseInt($(this).find(".le").html().split(" ")[8].replace("\n", "").split("/")[0]);
      num2 = parseInt($(this).find(".le").html().split(" ")[8].replace("\n", "").split("/")[1]);

      var num3 = ($(this).find(".text__green").html()) * 500

      var nums = (num1 / num2).toFixed(2);
      var roi = ((num3) / (num1 / num2) / 24);

      $(this).find(".test").remove();
      $(this).find(".test2").remove();
      $(this).find(".le").append("<div class='test'></span>");
      $(this).find(".le").find(".test").html("LE/H: " + nums);

      $(this).find(".le").append("<div class='test2'></span>");

      $(this).find(".le").find(".test2").html("ROI: " + roi.toFixed(2));
      if (roi < 30 && roi > 20) {
        $(this).find(".le").find(".test2").css("background-color", "red");
      }
      else if (roi <= 20)
      $(this).find(".le").find(".test2").css("background-color", "DarkRed");
      else {
        $(this).find(".le").find(".test2").css("background-color", "");
      }

    });

  

  }, 100);

})();