Guest User

Untitled

a guest
Feb 5th, 2013
50
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
  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].firstChild.nodeValue.replace(/[^\d.-]/g,'')),
  36.                 parseFloat(cells[4].firstChild.nodeValue.replace(/[^\d.-]/g,''))
  37.             ];
  38.             // THIS IS WHERE YOUR CONDITIONS GO
  39.             if( values[0] > 990000 && values[2] < 1) return false;
  40.             if( values[1] < 1 && (values[2] < 1 && values[2] > 0.01)) return false;
  41.             return true;
  42.         };
  43.     for( i=0; i<l; i++) {
  44.        
  45.         if( !filter(rows[i].cells)) rows[i].style.display = "none", skip++;
  46.     }
  47.    
  48.     var hidden = "(" + skip.toString() + " securities are being hidden with the Hide script.)"
  49.     var newRow=tbl.insertRow(1);
  50.     var newCell=newRow.insertCell(0);
  51.     newCell.setAttribute('colspan', 11);
  52.     newCell.innerHTML=hidden;
  53. })();
Advertisement
Add Comment
Please, Sign In to add comment