H::Q profile csv
@@ -1,21 +1,43 @@
/*
- * @title http://q.hatena.ne.jp/mafucode/で数値を行にする
- * @description これにforとかwhileするのも面倒だった
- * @include http://q.hatena.ne.jp/mafucode/
- * @license MIT License
+ * @title H::Q profile csv
+ * @description generate csv on Hatena Question profile page
+ * @include http://q.hatena.ne.jp/*
+ * @contributor mafucode http://let.hatelabo.jp/mafucode/let/hLHXiJKUi9cB (Fork of)
+ * @license MIT License http://opensource.org/licenses/MIT
+ * @javascript_url
*/
-document.getElementById('usertable').outerHTML+="<div>"+
-(function(){
- var d=new Date();
- return (d.getYear()+1900)+"/"+((d.getMonth<9?"0":"")+d.getMonth()+1)+"/"+d.getDate();
-})()+","+
-(document.querySelectorAll('#usertable tr')[1].querySelectorAll('td')[0].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[1].querySelectorAll('td')[1].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[1].querySelectorAll('td')[2].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[3].querySelectorAll('td')[0].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[3].querySelectorAll('td')[1].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[3].querySelectorAll('td')[2].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[5].querySelectorAll('td')[0].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[5].querySelectorAll('td')[1].firstChild.textContent)+","+
-(document.querySelectorAll('#usertable tr')[5].querySelectorAll('td')[2].firstChild.textContent)+","+"\n</div>";
+// - [x] fix zero-fill(padding) bug of month
+// - fork of: "2015/21/29" (at 2015/03/29)
+// - [x] remove redundant last comma of csv
+// - [ ] csv word-wrap
+
+// e.g. http://q.hatena.ne.jp/noromanba/
+(function () {
+ var table = document.querySelector('#usertable');
+ if (!table) return;
+
+ // c.f. https://gist.github.com/noromanba/6737784
+ //*
+ var date = new Date().toLocaleDateString('ja', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit'
+ });
+ /*/
+ var now = new Date();
+ [
+ now.getFullYear(),
+ ('0' + (now.getMonth() + 1)).slice(-2),
+ '0' + now.getDate()).slice(-2)
+ ].join('/');
+ //*/
+ var info = [date].concat(table.textContent.replace(/[^\d\n.-]/g, '').match(/[^\s]+/g));
+
+ var container = document.createElement('div');
+ container.style.wordWrap = 'break-word;'; // WIP
+ container.textContent = info;
+
+ table.parentNode.appendChild(container);
+})();
+
/*
* @title H::Q profile csv
* @description generate csv on Hatena Question profile page
* @include http://q.hatena.ne.jp/*
* @contributor mafucode http://let.hatelabo.jp/mafucode/let/hLHXiJKUi9cB (Fork of)
* @license MIT License http://opensource.org/licenses/MIT
* @javascript_url
*/
// - [x] fix zero-fill(padding) bug of month
// - fork of: "2015/21/29" (at 2015/03/29)
// - [x] remove redundant last comma of csv
// - [ ] csv word-wrap
// e.g. http://q.hatena.ne.jp/noromanba/
(function () {
var table = document.querySelector('#usertable');
if (!table) return;
// c.f. https://gist.github.com/noromanba/6737784
//*
var date = new Date().toLocaleDateString('ja', {
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
/*/
var now = new Date();
[
now.getFullYear(),
('0' + (now.getMonth() + 1)).slice(-2),
'0' + now.getDate()).slice(-2)
].join('/');
//*/
var info = [date].concat(table.textContent.replace(/[^\d\n.-]/g, '').match(/[^\s]+/g));
var container = document.createElement('div');
container.style.wordWrap = 'break-word;'; // WIP
container.textContent = info;
table.parentNode.appendChild(container);
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。