Lending Club

Auto expand things on lending club

当前为 2015-08-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Lending Club
  3. // @namespace http://geekminute.com/
  4. // @version 0.7.1
  5. // @description Auto expand things on lending club
  6. // @match https://www.lendingclub.com/*
  7. // @copyright 2015+, Jon Heizer
  8. // ==/UserScript==
  9.  
  10. setTimeout(function() {
  11. //If there are any errors on the screen, jump out
  12. if (document.querySelectorAll("#master_message-list > *").length > 0 && document.documentElement.innerHTML.indexOf('There was no activity during this period') > -1 )
  13. {
  14. return;
  15. }
  16.  
  17. //Expand loan performance
  18. if (document.getElementById("showLoanPerf") !== null)
  19. {
  20. document.getElementById("showLoanPerf").getElementsByTagName("a")[0].click();
  21. }
  22.  
  23. //Expand payment history
  24. if (document.getElementById("showPayments") !== null)
  25. {
  26. document.getElementById("showPayments").getElementsByTagName("a")[0].click();
  27. }
  28.  
  29. //Account Activity
  30. if (document.getElementById("submitAccountDates") !== null && document.getElementById("lender-activity-div") === null)
  31. {
  32. var yest = new Date();
  33. yest.setDate(yest.getDate()-1);
  34.  
  35. document.getElementById("start-date").value = (yest.getMonth() + 1).toString() + "/" + yest.getDate().toString() + "/" + yest.getFullYear().toString();
  36. document.getElementById("submitAccountDates").click();
  37.  
  38. }
  39.  
  40. setTimeout(function (){
  41. //If there are any errors on the screen, jump out
  42. if (document.querySelectorAll("#master_message-list > *").length > 0 && document.documentElement.innerHTML.indexOf('There was no activity during this period') > -1)
  43. {
  44. return;
  45. }
  46.  
  47. //Any resizing combo
  48. var sel = document.querySelector("select[id^='yui-pg0-0']");
  49.  
  50. if (sel !== null)
  51. {
  52. sel.value = 10000;
  53.  
  54. if ('fireEvent' in sel)
  55. sel.fireEvent("onchange");
  56. else {
  57. var evt = document.createEvent("HTMLEvents");
  58. evt.initEvent("change", false, true);
  59. sel.dispatchEvent(evt);
  60. }
  61. }
  62. },200);
  63.  
  64. //Add totals to detail tables
  65.  
  66. setTimeout(function (){
  67. TableTotals();
  68. },1000);
  69.  
  70. },500);
  71.  
  72. function TableTotals(){
  73.  
  74. if (document.querySelectorAll("#detailPanel-div").length > 0)
  75. {
  76. //Give the table a moment to fill before calculating
  77. setTimeout(function (){
  78. var excess = 0;
  79. var excessCount = 0;
  80. var totalLine = document.querySelectorAll("div.bd div")[0];
  81.  
  82. //Principal
  83. var prin = document.querySelectorAll("td.yui-dt-col-principal div");
  84. var ptotal = 0;
  85. for (i = 0; i < prin.length; ++i) {
  86. ptotal += parseFloat(prin[i].title.substr(1));
  87. }
  88.  
  89. totalLine.innerHTML+= "&nbsp;&nbsp;&nbsp;&nbsp;<em>Principal:</em>&nbsp;<strong>$" + ptotal.toFixed(2).toString() + "</strong>";
  90.  
  91. //Interest
  92. var intr = document.querySelectorAll("td.yui-dt-col-interest div");
  93. var itotal = 0;
  94. for (i = 0; i < intr.length; ++i) {
  95. itotal += parseFloat(intr[i].title.substr(1));
  96.  
  97. //Check for excess payments
  98. if (parseFloat(intr[i].title.substr(1)) == 0 || (parseFloat(intr[i].title.substr(1)) > 0 && parseFloat(prin[i].title.substr(1)) > 5)){
  99. excessCount +=1;
  100. excess += parseFloat(prin[i].title.substr(1))
  101. }
  102.  
  103.  
  104. }
  105.  
  106. totalLine.innerHTML+= "&nbsp;&nbsp;<em>Interest:</em>&nbsp;<strong>$" + itotal.toFixed(2).toString() + "</strong>";
  107.  
  108. totalLine.innerHTML+= "&nbsp;&nbsp;<em>Count:</em>&nbsp;<strong>" + (intr.length).toString() + "</strong>";
  109. if(excess > 0)
  110. {
  111. totalLine.innerHTML+= "&nbsp;&nbsp;<em>Excess:</em>&nbsp;<strong>" + (excessCount).toString() + " - $" + excess.toFixed(2).toString() + "</strong>";
  112. }
  113. },1000);
  114. }else{
  115. setTimeout(function (){
  116. TableTotals();
  117. },1000);
  118.  
  119. }
  120.  
  121. }
  122.  
  123. addGlobalStyle('body #master_banner {padding-top: 5px; !important; }');
  124. addGlobalStyle('#master_banner span a { height: 16px; !important; }');
  125. addGlobalStyle('#master_top-nav { padding: 0px; !important; }');
  126. addGlobalStyle('#master_content-header h1 { font-size: 125%; padding-bottom: 1px; !important;}');
  127. addGlobalStyle('.box-module label { padding-top: 2px; !important;}');
  128. addGlobalStyle('.box-module { height: 100px; !important;}');
  129. addGlobalStyle('.master_alert { font-size: .7em; margin: 0px; !important;}');
  130. addGlobalStyle('body #master_top-nav.master_fmenuExtended { padding: 0px; !important;}');
  131. addGlobalStyle('div#lender-activity-page .filter-container { height: auto; !important;}');
  132. addGlobalStyle('body.master_full-width #master_content-mid { margin-top: 0px; !important;}');
  133. addGlobalStyle('div.yui-dt tr { height: 27px; !important;}');
  134.  
  135.  
  136. function addGlobalStyle(css) {
  137. var head, style;
  138. head = document.getElementsByTagName('head')[0];
  139. if (!head) { return; }
  140. style = document.createElement('style');
  141. style.type = 'text/css';
  142. style.innerHTML = css;
  143. head.appendChild(style);
  144. }