require 'mechanize' module Grope class Env def initialize(options = {}) @options = { :timeout => 60, :use_shared_cookie => false, :init_width => 1024, :init_height => 600 }.merge(options) NSApplication.sharedApplication @webview = WebView.alloc @webview.initWithFrame(rect) @webview.setPreferencesIdentifier('Grope') @webview.preferences.setShouldPrintBackgrounds(true) @webview.preferences.setAllowsAnimatedImages(false) @webview.mainFrame.frameView.setAllowsScrolling(false) @webview.setMediaStyle('screen') create_window @frame_load_delegate = FrameLoadDelegate.alloc.init @webview.setFrameLoadDelegate(@frame_load_delegate) unless @options[:use_shared_cookie] @resource_load_delegate = WebResourceLoadDelegate.alloc.init @resource_load_delegate.cookie_storage = Mechanize::CookieJar.new @webview.setResourceLoadDelegate(@resource_load_delegate) end end def load(url) run do @webview.setMainFrameURL(url) if !@webview.mainFrame.provisionalDataSource raise " ... not a proper url?" end end end def eval(js) value = nil run do wso = @webview.windowScriptObject value = WSOWrapper.wrap(wso.evaluateWebScript(<