Skip to content

Instantly share code, notes, and snippets.

@tanabe
Created December 8, 2012 13:40
Show Gist options
  • Save tanabe/4240303 to your computer and use it in GitHub Desktop.
Save tanabe/4240303 to your computer and use it in GitHub Desktop.
(function() {
var memberId;
var ie = WScript.CreateObject('InternetExplorer.Application');
ie.Visible = true;
var openURL = function(url, callback) {
ie.Navigate(url);
while (ie.ReadyState != 4) {
WScript.Sleep(200);
}
var window = ie.Document.parentWindow;
callback(window);
};
var fetchVoices = function(next) {
openURL('http://mixi.jp/list_voice.pl', function(window) {
var diaryBody = '';
var $ = window.$j;
var voice = $('.archive');
voice.each(function(index, element) {
var postedTime = $(element).find('.postTime').val();
var matches = postedTime.match(/^(\d{4})(\d{2})(\d{2})/);
var year = matches[1];
var month = matches[2];
var day = matches[3];
var body = $(element).find('.voiced p').clone().children().remove().end().text();
diaryBody += [year, '/', month, '/', day, ' : ', body, "\n"].join('');
});
memberId = $('.memberId').val();
next(diaryBody);
});
};
var writeDiary = function(diaryBody) {
openURL('http://mixi.jp/add_diary.pl?id=' + memberId, function(window) {
var $ = window.$j;
$('.JS_diaryBody').val(diaryBody);
});
};
fetchVoices(writeDiary);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment