Last active
May 13, 2016 18:37
-
-
Save AknEp/b63f6ddef8e180ec1dc5fef0c13b2c04 to your computer and use it in GitHub Desktop.
MoneyForwardのトップページでクレカの未確定残高もチェックできるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MoneyForwardでクレカの未確定残高もチェック | |
// @namespace https://github.com/AknEp | |
// @version 0.2 | |
// @description MoneyForwardのトップページ左上の総資産から、未確定のカード残高を引いて表示してくれるやつ。Tampermonkeyとか使えばインストールできるっぽいです。(Developed by: Twitter/GitHub @AknEp ) | |
// @author AknEp | |
// @match https://moneyforward.com | |
// ==/UserScript== | |
(function(){ | |
'use strict'; | |
function safeParseFloat(text){ | |
return parseFloat(text.replace(/[^-^0-9^\.]/g,"")); | |
} | |
function currencyFormat(num){ | |
return num.toString().replace(/(\d)(?=(\d{3})+$)/g , '$1,'); | |
} | |
var totalDom = document.querySelector('#user-info .total-assets .heading-radius-box'); | |
var totalStr = totalDom.textContent; | |
var total = safeParseFloat(totalStr); | |
var pendings = 0; | |
var accounts = document.querySelectorAll('.account.facilities-column') || []; | |
for(var i=0; i < accounts.length; i++){ | |
var account = accounts[i]; | |
var schedule = account.querySelector('.schedule'); | |
if(schedule != null && schedule.textContent == '引き落とし額未確定'){ | |
var amountStr = account.querySelector('.amount').textContent; | |
var amount = safeParseFloat(amountStr); | |
if(!isNaN(amount)){ | |
pendings += amount; | |
} | |
} | |
} | |
var truth_total = total + pendings; | |
var htmlString = currencyFormat(truth_total)+"円<br><small>(元の総資産"+currencyFormat(total)+")<br>(未確定額:"+currencyFormat(pendings)+")</small>"; | |
totalDom.innerHTML = htmlString; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
左上の画面がこんな風になります!(金額はウソ)