-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportfolio-tweaks.user.js
44 lines (31 loc) · 1.51 KB
/
portfolio-tweaks.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ==UserScript==
// @name Portfolio Tweaks
// @namespace Heasleys.portfoliotweaks
// @version 0.2
// @description Adds net change to stocks
// @author Heasleys4hemp [1468764]
// @match https://www.torn.com/stockexchange.php?step=portfolio
// @grant none
// @updateURL https://github.com/Heasleys/bird-scripts/raw/master/portfolio-tweaks.user.js
// ==/UserScript==
(function() {
'use strict';
$('ul.stock-cont > li.item-wrap').each(function() {
let dir = '';
let dirclass = '';
let acro = $(this).data('stock');
let info_tab = $(this).find('ul > li.info');
let shares_tab = info_tab.find('div.b-price-wrap > div:contains("Shares:")');
let shares = parseInt(shares_tab.text().replace(/\D/g,''));
let length_wrap = info_tab.find('div.length-wrap');
if (length_wrap.find('span.change.down').length) {dir = '-';}else{dir = '+'}
let change_tab = length_wrap.find('span.value');
let change = change_tab.text().split(" ").shift().replace('$','');
let net = Math.floor(change * shares);
let qualify_wrap = info_tab.find('div.qualify-wrap');
if (dir == '-') {dirclass = 'bold change down';}
if (dir == '+') {dirclass = 'bold change up';}
let netFormatted = net.toLocaleString('en-US');
qualify_wrap.append('<div style="float: right;"><span class="bold">Net Change: </span><span class="'+dirclass+'">' + dir + '$' + netFormatted + '</span></div>');
});
})();