Created
October 3, 2010 04:07
-
-
Save balibali/608254 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Utasuki tsv for history | |
// @namespace http://rimpei.org | |
// @include http://joysound.com/ex/utasuki/mypage/singhistory/*index.htm | |
// ==/UserScript== | |
// 履歴 table.rows を取得(Firebug で XPath コピーしてきた) | |
var rows = document.evaluate( | |
"/html/body/div/div[3]/div[2]/div[2]/div/div/div/span/div/table", | |
document, | |
null, | |
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, | |
null).snapshotItem(0).rows; | |
var results = []; | |
for each (var row in rows) { | |
if (!row.cells | |
|| !row.parentNode | |
|| row.parentNode.nodeName == "THEAD" | |
|| row.parentNode.nodeName == "TFOOT" | |
) { | |
continue; | |
} | |
results.push( | |
row.cells[0].textContent // 演奏日付 | |
+ "\t" + row.cells[1].textContent // 曲名 | |
+ "\t" + row.cells[2].textContent // 歌手名 | |
+ "\t" + row.cells[1].firstChild.attributes[0].value.match(/[0-9]+/) // 曲ID | |
+ "\t" + row.cells[2].firstChild.attributes[0].value.match(/[0-9_]+/) // 歌手ID | |
); | |
} | |
// body 末尾に pre 要素で tsv 表示(逆順) | |
var elem = document.createElement("pre"); | |
while (results.length) { | |
elem.innerHTML += results.pop() + "\n"; | |
} | |
document.getElementsByTagName("body")[0].appendChild(elem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Utasuki tsv for history | |
// @namespace http://rimpei.org | |
// @include http://joysound.com/ex/utasuki/mypage/singhistory/*index.htm | |
// ==/UserScript== | |
// Using jQuery | |
// http://www.otchy.net/20091104/use-jquery-on-greasemonkey/ | |
(function(d,f){var c=function(){if(unsafeWindow.jQuery==null)return 1;f(unsafeWindow.jQuery)};if(c()){var s=d.createElement("script");s.src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";d.getElementsByTagName("head")[0].appendChild(s);(function(){!c()||setTimeout(arguments.callee,100)})()}})(document,function($){main($);$("#b").click(function(){alert("")})}); | |
function main($) { | |
// table.rows を取得 | |
var rows = $("div.tableList table tbody tr"); | |
var results = []; | |
for (var i = 0; i < rows.length; i++) { | |
results.push( | |
rows[i].cells[0].textContent // 演奏日付 | |
+ "\t" + rows[i].cells[1].textContent // 曲名 | |
+ "\t" + rows[i].cells[2].textContent // 歌手名 | |
+ "\t" + rows[i].cells[1].firstChild.attributes[0].value.match(/[0-9]+/) // 曲ID | |
+ "\t" + rows[i].cells[2].firstChild.attributes[0].value.match(/[0-9_]+/) // 歌手ID | |
); | |
} | |
// body 末尾に pre 要素で tsv 表示(逆順) | |
var tsv = ""; | |
while (results.length) { | |
tsv += results.pop() + "\n"; | |
} | |
$("body").append("<pre>" + tsv + "</pre>"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment