NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Owned stock // @namespace torn.com // @version 0.8 // @description Owned stock at top // @author ahab // @match *.torn.com/page.php?sid=stocks* // @license MIT // @require https://code.jquery.com/jquery-3.6.0.min.js // @updateURL https://openuserjs.org/meta/Ahab/Owned_stock.meta.js // @run-at document-start // @grant unsafeWindow // ==/UserScript== const original_fetch = fetch var sort = [] var ac = ['Ready','In progress','Inactive'] unsafeWindow.fetch = async (input, init) => { const response = await original_fetch(input, init) const consumed_res = await response.json() if(consumed_res['stocks']){ consumed_res['stocks'].sort(function (a, b) { return ac.indexOf(a.dividends.status) < ac.indexOf(b.dividends.status) ? -1 : (ac.indexOf(a.dividends.status) > ac.indexOf(b.dividends.status) ? 1 : 0) || b.userOwned.sharesAmount - a.userOwned.sharesAmount; }); $.each(consumed_res['stocks'], function(i){ sort.push(this['id']) }) } else if(consumed_res['charts'] && response.url.split('=')[2] != 'getChartDataByTransactionID'){ consumed_res['charts'].sort(function(a, b){ return sort.indexOf(a.stockId) - sort.indexOf(b.stockId) }) } const b = new Blob([JSON.stringify(consumed_res, null, 2)], {type : 'application/json'}) return new Response(b) }