Created
September 29, 2011 04:28
-
-
Save youpy/1249979 to your computer and use it in GitHub Desktop.
facebook chat logger
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
| # OSX only | |
| %w/ubygems grope pit open-uri/.each {|g| require g } | |
| def main | |
| url = 'http://www.facebook.com/' | |
| env = Grope::Env.new | |
| env.load(url) | |
| if env.document.title !~ /^Facebook/ | |
| config = Pit.get("facebook.com", :require => { | |
| 'username' => 'your username in facebook', | |
| 'password' => 'your password in facebook' | |
| }) | |
| doc = env.document | |
| doc.getElementById('email').value = config['username'] | |
| doc.getElementById('pass').value = config['password'] | |
| doc.getElementById('login_form').submit | |
| env.wait(1) | |
| end | |
| previous = [] | |
| js = env.eval('return Grope') | |
| js.click(env.document.querySelector('#fbDockChatBuddylistNub .fbNubButton')) | |
| loop do | |
| current = env.document.querySelectorAll('.active').map do |item| | |
| item.textContent | |
| end | |
| log(current - previous, 'in') | |
| log(previous - current, 'out') | |
| previous = current.clone | |
| env.wait(1) | |
| end | |
| end | |
| def log(names, behavior) | |
| if names.size > 0 | |
| msg = ['[' + behavior + ']', names.join(', ')].join(' ') | |
| STDERR.puts msg | |
| # https://gist.github.com/1021283 | |
| open('http://localhost:5678/?text=' + URI.encode(msg)) | |
| end | |
| end | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment