Created
October 8, 2021 12:41
-
-
Save Sigri44/4a1ba2e6effebce2c71380d2f04d3422 to your computer and use it in GitHub Desktop.
Track Whalinvest bag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Whalinvest - Wallet | |
// @namespace Whalinvest | |
// @version 0.2 | |
// @description Whalinvest bag calculator | |
// @author Sigri44 | |
// @match https://app.whalinvest.com/bag* | |
// @icon https://www.google.com/s2/favicons?domain=whalinvest.com | |
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let whalinvest = window.whalinvest = {}; | |
whalinvest.waitForGrids = setTimeout(function (){ | |
whalinvest.getBagValue() | |
whalinvest.markBuySellBot() | |
}, 3000); | |
whalinvest.getBagValue = function (){ | |
let bagTotal = 0 | |
let table = $('.col-sm-12.col-md-9').find('.row').find('.col-sm-12').find('.row') | |
let navbar = $('.row.mb-3.mt-3').find('.col-12').find('.btn.btn-primary.ms-2') | |
table.find('span.align-middle.fw-bold.ms-2').each(function (key, value) { | |
const regex = /(\d+(?:\.\d{1,2})?)/ | |
let bagBrut = value.textContent | |
let bagPrice = parseFloat(bagBrut.match(regex)[0]) | |
bagTotal += bagPrice | |
}) | |
let html = '<span class="align-middle fw-bold ms-2 h5">Total bag price : (' + bagTotal + '$)</span>' | |
navbar.after(html) | |
} | |
whalinvest.markBuySellBot = function(){ | |
let table = $('.col-sm-12.col-md-9').find('.row').find('.col-sm-12.mt-2').find('.row') | |
table.find('span.ms-2.align-middle').each(function (key, value) { | |
const buyRegex = /achat$/ | |
const sellRegex = /vendre$/ | |
let text = value.innerHTML | |
let matchBuy = text.match(buyRegex) | |
let matchSell = text.match(sellRegex) | |
if (matchBuy) { | |
$(this).parent().parent().parent().parent().css("background-color", "#599959"); | |
} else if (matchSell) { | |
$(this).parent().parent().parent().parent().css("background-color", "#bb5959"); | |
} | |
}) | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment