Skip to content

Instantly share code, notes, and snippets.

@momota
Last active April 13, 2019 08:31
Show Gist options
  • Select an option

  • Save momota/6479565b0e36a4abac772b3aff9c39bd to your computer and use it in GitHub Desktop.

Select an option

Save momota/6479565b0e36a4abac772b3aff9c39bd to your computer and use it in GitHub Desktop.
UserScript for copying family budget detail data to clipboard from the moneyfoward page.
// ==UserScript==
// @name moneyforward_scraping
// @namespace http://momota.github.io/
// @include https://moneyforward.com/cf
// @version 1
// @grant GM.setClipboard
// ==/UserScript==
function copyTransaction() {
var csv = '',
rows = document.querySelectorAll('#cf-detail-table > tbody > tr');
for(var row of rows) {
for(var td of row.querySelectorAll('td')) {
csv += td.innerText + '\t';
}
csv += '\n';
}
return csv;
}
(function () {
GM.setClipboard(copyTransaction());
var period = document.querySelector('span.fc-header-title:nth-child(2) > h2:nth-child(1)');
alert('copied: ' + period.innerText);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment