// ==UserScript== // @name Yahoo Finance Statistics Highlighter // @namespace yahoofinancehighlighter // @version 0.1 // @description It highlights some statistics in Yahoo Finance // @author Michele // @match https://finance.yahoo.com/quote/** // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @grant GM_setClipboard // @grant GM_addStyle // @require https://openuserjs.org/src/libs/sizzle/GM_config.js // @require https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js // @downloadURL none // ==/UserScript== (function() { // 'use strict'; GM_config.init( { 'id': 'YFHConfig', 'title': 'Settings', 'fields': { 'roe-green': { 'label': 'ROE - Green', 'type': 'number', 'default': '40' }, 'roe-red': { 'label': 'ROE - Red', 'type': 'number', 'default': '30' }, 'current-ratio-green': { 'label': 'Current Ratio - Green', 'type': 'number', 'default': '1' }, 'current-ratio-red': { 'label': 'Current Ratio - Red', 'type': 'number', 'default': '0.8' }, 'payout-ratio-green': { 'label': 'Payout Ratio - Green', 'type': 'number', 'default': '80' }, 'payout-ratio-red': { 'label': 'Payout Ratio - Red', 'type': 'number', 'default': '99' }, } }); GM_registerMenuCommand('Configure', () => { GM_config.open(); }) var groups = [ {"ariaLabel": "Return on Equity", "field": "roe", "bestLower": false}, {"ariaLabel": "Current Ratio", "field": "current-ratio", "bestLower": false}, {"ariaLabel": "Payout Ratio", "field": "payout-ratio", "bestLower": true}, ]; function best(a, b, group) { return group.bestLower ? a < b : a > b; } setInterval ( function () { $.each(groups, function(i, group) { $.each($("span:contains(" + group.ariaLabel + ")"), function(i, el) { if ($(el).text() == group.ariaLabel) { var valueEl = $($(el).parent().siblings()[0]); var currentValue = parseFloat(valueEl.text()); var greenValue = parseFloat(GM_config.get(group.field + '-green')); var redValue = parseFloat(GM_config.get(group.field + '-red')); if (best(currentValue, greenValue, group)) { $(valueEl).css("color", "green"); } else if (!best(currentValue, redValue, group)) { $(valueEl).css("color", "red"); } else { $(valueEl).css("color", "orange"); } $(valueEl).css("font-weight", "bold"); } }); }); }, 1000); })();