Created
March 21, 2011 01:41
-
-
Save sonota88/878890 to your computer and use it in GitHub Desktop.
Twitter から sinsai.info へのレポート用。日付をフォーマットして表示+コピペしやすいように
This file contains hidden or 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 twitter-dt | |
// @namespace anbt | |
// @include http://twitter.com/*/status/* | |
// @include http://twitter.com/*/statuses/* | |
// @include https://twitter.com/*/status/* | |
// @include https://twitter.com/*/statuses/* | |
// ==/UserScript== | |
/* | |
正しい日時表示になっているかという点については十分にテストしてませんので、 | |
確認しつつ使ってください。 | |
*/ | |
var _console = window.wrappedJSObject.console; | |
function puts(){ | |
//_console.log(arguments); | |
} | |
(function(){ | |
var $; | |
function formatDateTime(ts){ | |
return "" + (ts.getMonth()+1) +"/"+ ts.getDate() +" "+ ts.getHours() +":"+ ts.getMinutes(); | |
} | |
function formatTimeAmPm(ts){ | |
if( ts.getHours() < 12 ){ | |
return ts.getHours() +":"+ ts.getMinutes() + " AM"; | |
}else{ | |
return (ts.getHours()-12) +":"+ ts.getMinutes() + " PM"; | |
} | |
} | |
function main(){ | |
var dtData = $("span.timestamp").attr("data"); | |
dtData.match(/time:'(.+?)'/); | |
var dttext = RegExp.$1; | |
var ts = new Date(dttext); | |
var text = formatDateTime(ts) +" ("+ formatTimeAmPm(ts) +")"; | |
text += "\n" + (new Date(dttext)).toString(); | |
text += "\n(raw: " + dttext + ")"; | |
text += "\n"; | |
var text2 = formatDateTime(ts) + " (" + formatTimeAmPm(ts) +")"; | |
text2 += "\n「" + $("span.entry-content").text() + "」"; | |
text2 += "\n ( " + location.href + " )"; | |
var pre = $("<pre></pre>"); | |
pre.text(text); | |
$("span.entry-content").after(pre); | |
var ta = $("<textarea></textarea>"); | |
ta.val(text2); | |
ta.css("width", "400px"); | |
ta.css("height", "200px"); | |
pre.after(ta); | |
} | |
// Greasemonkey で 超お手軽に jQuery を使うスニペット – OTCHY.NET | |
// http://www.otchy.net/20091104/use-jquery-on-greasemonkey/ | |
(function(d, func) { | |
var check = function() { | |
if (typeof unsafeWindow.jQuery == 'undefined') return false; | |
$ = unsafeWindow.jQuery; | |
func(); | |
return true; | |
}; | |
if (check()) return; | |
var s = d.createElement('script'); | |
s.type = 'text/javascript'; | |
s.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'; | |
d.getElementsByTagName('head')[0].appendChild(s); | |
(function() { | |
if (check()) return; | |
setTimeout(arguments.callee, 100); | |
})(); | |
})(document, main); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment