Guest User

Hide HSX securities

a guest
Feb 6th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Authored by socby19 and with a big help from Kolink at StackOverflow
  2. // ==UserScript==
  3. // @name=   Hidden HStocks
  4. // @description De-cluttering of port by hiding certain securities that meet certain criteria based on price, change, and percent change
  5. // @version     1.0
  6. // @run-at document-end
  7. // @include        http://*hsx.com/portfolio/*
  8. // @exclude        http://*hsx.com/portfolio/bank*
  9. // @exclude        http://*hsx.com/portfolio/limit*
  10. // @exclude        http://*hsx.com/portfolio/history*
  11. // @exclude        http://*hsx.com/portfolio/chart*
  12. // ==/UserScript==
  13.  
  14. //Column indexes for values array:
  15. //0  Symbol
  16. //1  Quantity - firstChild...
  17. //2  Short or Long
  18. //3  Avg Price Paid
  19. //4  Price
  20. //5  Price Change
  21. //6  % Price Change
  22. //7  Total Worth
  23. //8  Worth Change
  24. //9  % Worth Change
  25.  
  26. // Start
  27.  
  28. (function() {
  29.     var tbl = document.getElementById("sortable_MovieStocks"),
  30.         rows = tbl.tBodies[0].children, l = rows.length, i, skip=0,
  31.         filter = function(cells) {
  32.        
  33.             var values = [
  34.                 parseInt(cells[1].firstChild.nodeValue.replace(/,/g,''),10),
  35.                 parseFloat(cells[3].getAttribute("sorttable_customkey")),
  36.                 parseFloat(cells[4].getAttribute("sorttable_customkey")),
  37.         parseFloat(cells[6].getAttribute("sorttable_customkey"))
  38.             ];
  39.             // THIS IS WHERE YOUR CONDITIONS GO
  40.             if( values[0] > 990000 && values[2] < 1) return false;
  41.             if( values[1] < 1 && (values[2] < 1 && values[2] > 0.01)) return false;
  42.             return true;
  43.         };
  44.     for( i=0; i<l; i++) {
  45.        
  46.         if( !filter(rows[i].cells)) rows[i].style.display = "none", skip++;
  47.     }
  48.    
  49.     var hidden = "(" + skip.toString() + " securities are being hidden with the Hide script.)"
  50.     var newRow=tbl.insertRow(1);
  51.     var newCell=newRow.insertCell(0);
  52.     newCell.setAttribute('colspan', 11);
  53.     newCell.innerHTML=hidden;
  54. })();
Advertisement
Add Comment
Please, Sign In to add comment