Skip to content

Instantly share code, notes, and snippets.

@AknEp
Last active May 13, 2016 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AknEp/b63f6ddef8e180ec1dc5fef0c13b2c04 to your computer and use it in GitHub Desktop.
Save AknEp/b63f6ddef8e180ec1dc5fef0c13b2c04 to your computer and use it in GitHub Desktop.
MoneyForwardのトップページでクレカの未確定残高もチェックできるやつ
// ==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;
})();
@AknEp
Copy link
Author

AknEp commented May 11, 2016

僕の手元のGoogle Chromeだと、TemperMonkeyをインストールした状態で右上のRawボタンを押下するとスクリプトを導入できるようでした。

@AknEp
Copy link
Author

AknEp commented May 11, 2016

左上の画面がこんな風になります!(金額はウソ)

2016-05-12 01 27 57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment