Lending Club

Auto expand things on lending club

目前为 2015-08-28 提交的版本,查看 最新版本

// ==UserScript==
// @name       Lending Club
// @namespace  http://geekminute.com/
// @version    0.6
// @description  Auto expand things on lending club
// @match      https://www.lendingclub.com/*
// @copyright  2015+, Jon Heizer
// ==/UserScript==

setTimeout(function() {  
    //If there are any errors on the screen, jump out
    if (document.querySelectorAll("#master_message-list > *").length > 0 && document.documentElement.innerHTML.indexOf('There was no activity during this period') > -1 )
    {
        return;
    }
    
    //Expand loan performance
    if (document.getElementById("showLoanPerf") !== null)
    {
        document.getElementById("showLoanPerf").getElementsByTagName("a")[0].click();
    }

    //Expand payment history
    if (document.getElementById("showPayments") !== null)
    {
        document.getElementById("showPayments").getElementsByTagName("a")[0].click();
    }

    //Account Activity
    if (document.getElementById("submitAccountDates") !== null && document.getElementById("lender-activity-div") === null)
    {
        var yest = new Date();
        yest.setDate(yest.getDate()-1);

        document.getElementById("start-date").value = (yest.getMonth() + 1).toString() + "/" + yest.getDate().toString() + "/" + yest.getFullYear().toString();
        document.getElementById("submitAccountDates").click();

    }

    setTimeout(function (){
        //If there are any errors on the screen, jump out
        if (document.querySelectorAll("#master_message-list > *").length > 0 && document.documentElement.innerHTML.indexOf('There was no activity during this period') > -1)
        {
            return;
        }
        
        //Any resizing combo
        var sel = document.querySelector("select[id^='yui-pg0-0']");

        if (sel !== null)
        {
            sel.value = 10000;

            if ('fireEvent' in sel)
                sel.fireEvent("onchange");
            else {
                var evt = document.createEvent("HTMLEvents");
                evt.initEvent("change", false, true);
                sel.dispatchEvent(evt);
            }
        }
    },200);

    //Add totals to detail tables
    
    setTimeout(function (){
        TableTotals();
    },1000);

},500);

function TableTotals(){
    
    if (document.querySelectorAll("#detailPanel-div").length > 0)
    {
        //Give the table a moment to fill before calculating
        setTimeout(function (){
            var totalLine = document.querySelectorAll("div.bd div")[0];
            
            //Principal
            var prin = document.querySelectorAll("td.yui-dt-col-principal div");
            var ptotal = 0;
            for (i = 0; i < prin.length; ++i) {
                ptotal += parseFloat(prin[i].title.substr(1));
            }

            totalLine.innerHTML+= "&nbsp;&nbsp;&nbsp;&nbsp;<em>Principal:</em>&nbsp;<strong>$" + ptotal.toFixed(2).toString() + "</strong>";
        
            //Interest
            prin = document.querySelectorAll("td.yui-dt-col-interest div");
            ptotal = 0;
            for (i = 0; i < prin.length; ++i) {
                ptotal += parseFloat(prin[i].title.substr(1));
            }

            totalLine.innerHTML+= "&nbsp;&nbsp;&nbsp;&nbsp;<em>Interest:</em>&nbsp;<strong>$" + ptotal.toFixed(2).toString() + "</strong>";
            
            totalLine.innerHTML+= "&nbsp;&nbsp;&nbsp;&nbsp;<em>Count:</em>&nbsp;<strong>" + (prin.length).toString() + "</strong>";
        },1000);
    }else{
        setTimeout(function (){
            TableTotals();
        },1000);
        
    }
    
}