積立設定取得

var Queue = function() {
  this.promise = Promise.resolve(true);
  this.addAsync = (action) => this.promise = this.promise.then(() => new Promise((resolve) => action(resolve)));
  this.addSync  = (action) => this.addAsync((resolve) => { action(); resolve(); });
  this.delay    = (delay)  => this.addAsync((resolve) => setTimeout(resolve, delay));
};
var downloadAsTextFile = function(fileName, content) {
    var bom = new Uint8Array([0xEF, 0xBB, 0xBF]);
    var blob = new Blob([bom, content]);
    var url = window.URL || window.webkitURL;
    var blobURL = url.createObjectURL(blob);

    var a = document.createElement('a');
    a.download = fileName;
    a.href = blobURL;
    a.click();  
};
var downloadAsCSVFile = function(fileName, rows) {
  var content = "";
  for( var i in rows) {
    var ary = rows[i];
    for (var j = 0, m = ary.length; j < m; ++j) {
      content += '"' + ("" + ary[j]).replace('"', '""') + '"';
      if (j !== m) {
        content += ',';
      }
    }
    content += '\n';
  }
  downloadAsTextFile(fileName, content);
};

var q = new Queue();
var rows = [["ID", "ファンド名", "コース", "預り区分", "積立金額", "申込設定日", "信託報酬", "信託財産留保額"]];
$("tr.md-l-tr-03 td.vaM > a").filter((i, e) => e.href.match(/param6=(\w+)/i)).each((i,e) => {
  var td = $("td", $(e).parent().parent());
  var name = $("a", td[0]).text();
  var course = $(td[1]).text().trim();
  var kind = $(td[2]).text().trim();
  var amount = $(td[3]).html().replace(/\s/g, "").split("<br>");
  
  q.addAsync((resolve) => {
    //console.log("open", name);
    var w = window.open(e.href, "dummy", 'width=100,height=100');
    $(w).load(function() {
      //console.log("loaded", name);
      var t = $(w.document).find("#CONTENTSAREA01");
      rows.push([
        w.location.href.match(/param6=(\w+)/i)[1],
        name,
        course,
        kind,
        amount[0].match(/[\d,]+/)[0],
        amount[1].match(/\((.*)\)/)[1],
        t.find("p:contains('信託報酬')").closest("tr").next("tr").text().trim().match(/([\d\.]+)[%%]/)[1]+"%",
        t.find("p:contains('信託財産留保額')").closest("tr").next("tr").text().trim(),
      ]);
      //console.log("close", name);
      w.close();
      resolve();
    })
  });
})
q.addSync(() => downloadAsCSVFile("hoge.csv", rows));