// ==UserScript== // @name to CSV // @namespace https://ateraimemo.com/ // @include http://* // @description Html table -> CSV(textarea) // @grant none // @version 1.0.6 // ==/UserScript== //- [JavaScriptでHtmlのtable要素をCSVに変換する](https://ateraimemo.com/JavaScript/table2csv.html) (function() { function table2csv(table) { var tr = table.getElementsByTagName('tr'), i, j, k, l, xoff, text, cells, td, array = [], lenr = tr.length, lenc; for(i=0; i/mg, '').replace(/\t/g,' ').replace(/(^\s+)|(\s+$)/g, '').replace(/\"/, '""'); //前の行のrowspanですでにこのセルが使用されている場合はxoffだけ移動 xoff = 0; while(array[i][j+xoff] != null) { xoff++; } array[i][j+xoff] = text; for(k=1; k0) continue; //レイアウト目的の
は、無視する(例:
,
//console.log("== : " + (table[i].getAttribute('border')==0)); //console.log("===: " + (table[i].getAttribute('border')===0)); if(table[i].getAttribute('role')==='presentation' || (table[i].getAttribute('border')==='0')) continue; table[i].addEventListener('dblclick', listener, false); } }());