Skip to content

Instantly share code, notes, and snippets.

@Kohei-Toyoda
Created August 16, 2019 01:14
Show Gist options
  • Save Kohei-Toyoda/b60718156b25339a4c45c65239ab084f to your computer and use it in GitHub Desktop.
Save Kohei-Toyoda/b60718156b25339a4c45c65239ab084f to your computer and use it in GitHub Desktop.
三菱自動車 電動車両サポート 利用金額合計を表示するユーザースクリプト
// ==UserScript==
// @name Mitsubishi EV Support
// @version 1
// @grant none
// @include https://mem.ev-support.mitsubishi-motors.co.jp/mypage/individual/details
// @include https://mem.ev-support.mitsubishi-motors.co.jp/mypage/individual/details/*
// ==/UserScript==
const get_cost = () => {
const table_cells = Array.from(document.querySelector('table.mypage_history_table').querySelectorAll('td'))
const money_sum = table_cells.map( (elem) => /\d+\.?\d+円/.test(elem.textContent) ? parseFloat(elem.textContent.match(/\d+\.?\d+/)) : 0.0 ).reduce( (a,b) => a+b ,0.0 )
return money_sum;
}
document.body.onload = () => {
const syouhizeiritu = 1.08
const total_cost = Math.round( ( Math.max( get_cost() - 500 , 0 ) + 1500 ) * syouhizeiritu )
const total_money_elem = document.createElement("div")
total_money_elem.appendChild(document.createTextNode( "請求額: " + total_cost + "円"))
document.getElementById("right_contents").appendChild(total_money_elem)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment