11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/bnicovideo/user_session/linux.rb', line 11
def self.init_from_firefox
base_path = File.join(ENV['HOME'], '.mozilla', 'firefox')
ini_path = File.join(base_path, 'profiles.ini')
ini_hash = IniFile.load(ini_path).to_h
profile_path = nil
ini_hash.each do |k, v|
next unless v['Name'] == 'default'
relative = (v['IsRelative'] != '0')
input_path = v['Path']
if relative
profile_path = File.join(base_path, input_path)
else
profile_path = input_path
end
sql_path = File.join(profile_path, 'cookies.sqlite')
conn = SQLite3::Database.new(sql_path)
val = conn.get_first_value("select value from moz_cookies" +
" where host='.nicovideo.jp' AND name='user_session'")
return val
end
return nil
end
|