Last active
October 21, 2020 04:55
-
-
Save kouki-dan/63f1d6c61592b48de43c8458840b2c31 to your computer and use it in GitHub Desktop.
FOLIO損失?
This file contains hidden or 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
/* | |
* https://folio-sec.com/mypage/history/balance を開いて開発者ツールを開いてこのスクリプトをコピペしてください | |
*/ | |
function waitMottoMiru(completion) { | |
setTimeout(function() { | |
var mottoMiru = document.querySelectorAll("div[class*=\"More__more\"] > button") | |
if (mottoMiru.length == 0) { | |
completion(); | |
return; | |
} | |
mottoMiru[0].click(); | |
waitMottoMiru(completion); | |
}, 200); | |
} | |
async function fetchAllShisan() { | |
var assets = await fetch("https://folio-sec.com/mypage/assets"); | |
var text = await assets.text(); | |
var div = document.createElement("div"); | |
div.innerHTML = text; | |
var allShisan = div.getElementsByClassName("mypageHeaderAssetSummary__col__value__price--large")[0].innerText.replace(/,/g, "").replace("¥", ""); | |
return parseInt(allShisan); | |
} | |
function calcProfit() { | |
var tbody = document.getElementsByTagName("tbody")[0]; | |
var profit = 0; | |
var rows = tbody.children; | |
for (var i = 0; i < rows.length; i++) { | |
var row = rows[i]; | |
if (row.children[1].innerText == "売買代金・テーマ配当金等") { | |
continue; | |
} | |
var income = parseInt(row.children[2].innerText.replace(/,/g, "").replace("¥", "")) || 0; | |
var excome = parseInt(row.children[3].innerText.replace(/,/g, "").replace("¥", "")) || 0; | |
profit += income + excome | |
} | |
fetchAllShisan().then(allShisan => { | |
alert("全ての資産: " + allShisan + "\nこれまでの損益?: " + (allShisan - profit) + "\n損益率?: " + ((allShisan/profit*100)-100) + "%")}); | |
} | |
waitMottoMiru(calcProfit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment