Skip to content

Instantly share code, notes, and snippets.

@llatzhar
Created March 6, 2009 10:46
Show Gist options
  • Save llatzhar/74862 to your computer and use it in GitHub Desktop.
Save llatzhar/74862 to your computer and use it in GitHub Desktop.
<html>
<head>
<HTA:APPLICATION ID="hta"
SCROLL="no"/>
<script language="RubyScript">
def start
require 'rubygems'
require 'mechanize'
require 'nkf'
@agent = WWW::Mechanize.new
login_page = @agent.get('http://www.tumblr.com/login')
login_page.form_with(:action => '/login') do |f|
f.email = 'your mail address'
f.password = 'your password'
end.submit
checknew
end
def checknew
@refresh = nil
@posts = []
dashboard = @agent.get('http://www.tumblr.com/dashboard')
dashboard.root.xpath('//li').each do |n|
post_id = n['id']
if post_id != nil
@posts << n
end
end
m = @window.document.all("memo")
m.innerHTML = "#{@posts.size} posts found"
@cur = 0
view(@posts[@cur])
@timer = Window.setTimeout "refresh", 6000, "RubyScript"
end
def refresh
m = @window.document.all("memo")
m.innerHTML = "#{@cur.to_s}/#{@posts.size}"
if @cur < @posts.size - 1
@cur += 1
view(@posts[@cur])
@refresh = Window.setTimeout "refresh", 5000, "RubyScript"
else
checknew
end
end
def view(post)
v = @window.document.all("view")
if /video/ =~ post['class']
v.innerHTML = 'video is not supported'
else
v.innerHTML = NKF.nkf('-s', post.to_html)
end
end
</script>
</head>
<body onload="start" language="RubyScript">
<center>
<textarea id="memo"></textarea>
<div id="view"></div>
<hr>
<input type="button" id="qt" value="END"
onclick="@window.close" language="RubyScript">
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment