Skip to content

Instantly share code, notes, and snippets.

@momota
Last active April 13, 2019 08:31
Show Gist options
  • Save momota/6479565b0e36a4abac772b3aff9c39bd to your computer and use it in GitHub Desktop.
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() {
let tsv = '',
rows = document.querySelectorAll('#cf-detail-table > tbody > tr');
for(let row of rows) {
for(let td of row.querySelectorAll('td')) {
tsv += td.innerText + '\t';
}
tsv += '\n';
}
return tsv;
}
(function () {
let t = copyTransaction();
GM.setClipboard(t);
let 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