Class: Okayu::ChromeCookieThief

Inherits:
CookieThief show all
Defined in:
lib/cookie_thief.rb

Class Method Summary collapse

Methods inherited from CookieThief

cookiestxt_from_array, do_on_tmpfile, get, send_query

Class Method Details

.chrome_from_firefox(args) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/cookie_thief.rb', line 149

def chrome_from_firefox args
  chrome_args = {}
  args.each do |key, value|
    case key
    when :host
      chrome_args[:host_key] = value
    when :isHttpOnly
      chrome_args[:httponly] = value
    when :isSecure
      chrome_args[:secure] = value
    when :expiry
      chrome_args[:expires_utc] = value
    else
      chrome_args[key] = value
    end
  end
  chrome_args
end

.cookies_filenameObject



131
132
133
134
135
136
137
138
139
140
# File 'lib/cookie_thief.rb', line 131

def cookies_filename
  cookies_filename = nil
  case OS
  when 'Windows'
    if File.exist?(filename = "#{LOCALAPPDATA_PATH}/Google/Chrome/User Data/Default/Cookies")
      cookies_filename = filename
    end
  end
  cookies_filename
end

.sql_from_hash(args) ⇒ Object



142
143
144
145
146
147
# File 'lib/cookie_thief.rb', line 142

def sql_from_hash args
  args = chrome_from_firefox(args)
  sql = "select host_key, httponly, path, secure, expires_utc, name, value from cookies where "
  sql << args.map{|key, value|"#{key.to_s} = '#{value}'"}.join(' and ')
  sql << ';'
end