fuck_facebook 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fuck_facebook/version.rb +1 -1
- data/src/authenticator.rb +11 -6
- data/src/config.rb +16 -2
- data/src/cookie_handler.rb +1 -1
- data/src/message_handler.rb +1 -4
- data/src/xpaths.rb +6 -0
- data/xpaths.yaml +4 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd816f264c73ea38c4349c8110cade9787ae11f92de9b37ad8a1f6fbef9b2059
|
|
4
|
+
data.tar.gz: e2862a3aee723788f459ab7b84acf84ca2b3bda8ef6176e51a1018915cb350d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa5dfc850834b1ab4efd759eb853ac2bdc25c6a9cb739ee704b2e2182fc917fc43b85c504c75ad7394074f0549abd8e372906911a68da64ea0a4c78766d0d39b
|
|
7
|
+
data.tar.gz: 8ebea4e69e013d5c2f7f7345755c5ed39768bdbcd231587ae06c64e196e718d2f57293ea9714c84cf61008bc104d05c1dfd90df7548c8eade979d76a5391f129
|
data/src/authenticator.rb
CHANGED
|
@@ -19,7 +19,7 @@ class Authenticator
|
|
|
19
19
|
|
|
20
20
|
accept_cookies
|
|
21
21
|
submit_credentials
|
|
22
|
-
|
|
22
|
+
submit_otp
|
|
23
23
|
click_remember_password
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -32,7 +32,7 @@ class Authenticator
|
|
|
32
32
|
|
|
33
33
|
def click_remember_password
|
|
34
34
|
driver.navigate.to('https://www.facebook.com/settings?tab=security')
|
|
35
|
-
driver.switch_to.frame(xpaths.
|
|
35
|
+
driver.switch_to.frame(xpaths.wait_for_element(:settings, :security_iframe))
|
|
36
36
|
xpaths.element(:settings, :save_login_information_edit_button).click
|
|
37
37
|
xpaths.element(:settings, :save_login_information_button).click
|
|
38
38
|
end
|
|
@@ -43,15 +43,20 @@ class Authenticator
|
|
|
43
43
|
xpaths.element(:login_button).click
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def
|
|
47
|
-
return unless xpaths.
|
|
46
|
+
def submit_otp
|
|
47
|
+
return unless xpaths.element_exists?(:checkpoint, :otp_prompt)
|
|
48
48
|
|
|
49
49
|
xpaths.element(:checkpoint, :otp_input).send_keys(user_input.get(:otp))
|
|
50
|
-
xpaths.element(:checkpoint, :
|
|
51
|
-
|
|
50
|
+
otp_button = xpaths.element(:checkpoint, :submit_button)
|
|
51
|
+
otp_button.click
|
|
52
|
+
|
|
53
|
+
save_browser_button = xpaths.element(:checkpoint, :submit_button)
|
|
54
|
+
save_browser_button.click
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
def accept_cookies
|
|
58
|
+
return unless xpaths.element_exists?(:accept_cookies_button)
|
|
59
|
+
|
|
55
60
|
accept_cookies_button = xpaths.element(:accept_cookies_button)
|
|
56
61
|
accept_cookies_button.click
|
|
57
62
|
end
|
data/src/config.rb
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
require 'yaml'
|
|
2
2
|
|
|
3
3
|
class Config
|
|
4
|
-
|
|
4
|
+
CONFIG_FILE_PATH = "#{ENV['HOME']}/.local/share/fuck-facebook/config.yaml".freeze
|
|
5
5
|
|
|
6
6
|
def self.option(*path)
|
|
7
7
|
path_strings = path.map(&:to_s)
|
|
8
|
-
|
|
8
|
+
config.dig(*path_strings)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def self.config
|
|
14
|
+
create_config_file_if_not_exists!
|
|
15
|
+
|
|
16
|
+
YAML.load_file(CONFIG_FILE_PATH)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.create_config_file_if_not_exists!
|
|
20
|
+
dirname = File.dirname(CONFIG_FILE_PATH)
|
|
21
|
+
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
|
22
|
+
File.write(CONFIG_FILE_PATH, '{}') unless File.exist?(CONFIG_FILE_PATH)
|
|
9
23
|
end
|
|
10
24
|
end
|
data/src/cookie_handler.rb
CHANGED
|
@@ -41,7 +41,7 @@ class CookieHandler
|
|
|
41
41
|
saved_cookies = JSON.parse(File.read(cookies_filename), symbolize_names: true)
|
|
42
42
|
|
|
43
43
|
saved_cookies.each do |saved_cookie|
|
|
44
|
-
saved_cookie[:expires] = Time.parse(saved_cookie[:expires])
|
|
44
|
+
saved_cookie[:expires] = Time.parse(saved_cookie[:expires]) unless saved_cookie[:expires].nil?
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
saved_cookies
|
data/src/message_handler.rb
CHANGED
|
@@ -18,10 +18,7 @@ class MessageHandler
|
|
|
18
18
|
def messages
|
|
19
19
|
visit_messages_page
|
|
20
20
|
|
|
21
|
-
xpaths.
|
|
22
|
-
|
|
23
|
-
chats = xpaths.elements(:messages, :chats)
|
|
24
|
-
|
|
21
|
+
chats = xpaths.wait_for_elements(:messages, :chats)
|
|
25
22
|
messages = messages_for_chats(chats)
|
|
26
23
|
|
|
27
24
|
messages_after_last_message_time(messages)
|
data/src/xpaths.rb
CHANGED
|
@@ -63,6 +63,12 @@ class Xpaths
|
|
|
63
63
|
found_element
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def wait_for_elements(*path_elements)
|
|
67
|
+
wait_for_element(*path_elements)
|
|
68
|
+
|
|
69
|
+
elements(*path_elements)
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
def for(*path_elements)
|
|
67
73
|
path_elements_strings = path_elements.map(&:to_s)
|
|
68
74
|
result = XPATHS.dig(*path_elements_strings)
|
data/xpaths.yaml
CHANGED
|
@@ -8,13 +8,12 @@ settings:
|
|
|
8
8
|
save_login_information_button: '//div[text() = "Save your login information"]'
|
|
9
9
|
link_to_profile: '//a[@href="/me/"]'
|
|
10
10
|
checkpoint:
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
otp_prompt: '//strong[text() = "Two-factor authentication required"]'
|
|
12
|
+
otp_input: '//*[@id="approvals_code"]'
|
|
13
13
|
save_browser_radio_input: '/html/body/div[1]/div[3]/div[1]/div/form/div/div[2]/div[2]/div[1]/input'
|
|
14
|
-
|
|
15
|
-
prompt: '/html/body/div[1]/div[3]/div[1]/div/form/div/div[1]'
|
|
14
|
+
submit_button: '//*[@id="checkpointSubmitButton"]'
|
|
16
15
|
messages:
|
|
17
|
-
chats: '
|
|
16
|
+
chats: './/*[@aria-label="Chats"]/child::*'
|
|
18
17
|
title_relative: 'div[1]/div/a/div/div[2]/div[1]/div/div/div[1]/span/span/span/span'
|
|
19
18
|
text_relative: 'div[1]/div/a/div/div[2]/div[1]/div/div/div[2]/span/span/div/span[1]/span'
|
|
20
19
|
time_sent_ago_relative: 'div[1]/div/a/div/div[2]/div[1]/div/div/div[2]/span/span/div/span[3]'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fuck_facebook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keeyan Nejad
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|