PASMO履歴照会サービスがどうかと思ったのでGreasemonkeyでどうにかしてみた

履歴照会画面で残額しか表示されないのでいくらかかったのか計算しなくてはいけない…








計算させた。









追記:ついでだから総額も表示するようにした








どう考えても使い過ぎ><

// ==UserScript==
// @name           PASMO Table Extension
// @namespace      http://k12u.org/gm/pasmo/
// @description    PASMO Table Extension to display each charge
// @include        https://www.pasmo-mypage.jp/CardStatusWebForm.aspx
// ==/UserScript==


(function () {
    var sum = 0;
    var tbody = document.getElementsByTagName('tbody')[9];
    var trs   = tbody.getElementsByTagName('tr');

    var header_tr = trs[1];
    var header_th = document.createElement('th');
    var header_font = document.createElement('font');
    header_th.setAttribute('width', 80);

    header_font.appendChild(document.createTextNode('変動額'));
    header_font.setAttribute('color', '#ffffff');
    header_th.appendChild(header_font);
    trs[1].appendChild(header_th);
	
    trs[0].childNodes[1].setAttribute("colspan", 7);
    for (var i = 3; i <  (trs.length - 2) ; i+=2){
	var tbl_td = document.createElement('td');
	tbl_td.setAttribute('align', 'right');
	var charge = trs[i].childNodes[11].textContent.slice(1)
	    - trs[i+2].childNodes[11].textContent.slice(1);
	if( charge < 0 ) {
	    sum += -charge;
	}
	tbl_td.appendChild(document.createTextNode(charge));
	trs[i-1].childNodes[1].setAttribute("colspan", 7);
	trs[i].appendChild(tbl_td);
    }
    trs[i+1].childNodes[1].setAttribute("colspan", 7);
    var blank = document.createElement('td');
    blank.appendChild(document.createTextNode(''));
    trs[i].appendChild(blank);
    trs[i-1].childNodes[1].setAttribute("colspan", 7);

    var p_node = document.getElementsByTagName('tbody')[2];
    p_node.childNodes[16].childNodes[1].textContent += '利用総額: '+sum;
	
})();