posting_duo 3.101.999 → 3.103.999

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/posting_duo.rb +225 -68
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae4fd84ffdf6c4512dfe76630a84be559b6156f6ff1960540b5a9ecefe9a16cc
4
- data.tar.gz: d95fd450c5d5fec6d3ef96e4259098a3ed3ffcf179da5cac2fb19f2e81a5395f
3
+ metadata.gz: 3b31e7f20845f7b4678629a039ee5898cdfc4eb3f14c86bb9a073e28af2d3a24
4
+ data.tar.gz: 1fc94f8e07cdbdd0bd1ee63ba986dd31da47f8ea04c95355333e853faf88d6e6
5
5
  SHA512:
6
- metadata.gz: bb037bb48a57d10225d2a10f84f412c89ea19f395b05ac77461a1d5c5bc7e59683302827dc43d002d8d3afa3ea32ec27966b26f4c09e83c8ca02e12fba864099
7
- data.tar.gz: 54ecbe4220fa3fe89ccc434a9084076c8fa4e40626b868f9011c1b0a5851ae7c57af5aec6d08611cebe37bd22861282cce8ad0d6e8c7cd92061f56fca50e15f3
6
+ metadata.gz: aa1f480fbcc84ced0e031edff8bdfb728621198225868eab85301ab0d6e97ac93062bc0bc8d90ef655fa5694f9937c7cf72e61df55f4956d30c995cdb285bd08
7
+ data.tar.gz: 91a7a0fdd9735522808ae9b27de8581566e340134b670449b84fa5de4a156bdc907a9dc2323049f2004cf37b9a729962d16bad09b97d96dc69b56fd508de27c8
data/lib/posting_duo.rb CHANGED
@@ -25,13 +25,40 @@ include AutoClickMethods
25
25
  using Rainbow
26
26
 
27
27
 
28
-
28
+ class ChromeKiller
29
+ def self.kill_selenium_chrome
30
+ begin
31
+ wmi = WIN32OLE.connect("winmgmts://")
32
+ chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
33
+ chrome_procs.each do |proc|
34
+ cmd = proc.CommandLine
35
+ if cmd && cmd.include?("user-data-dir=C:/board_cookie")
36
+ puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
37
+ begin
38
+ proc.Terminate
39
+ rescue
40
+ # 무시
41
+ end
42
+ end
43
+ end
44
+ sleep(1)
45
+ rescue => e
46
+ puts "Chrome 종료 시도 중 오류 발생: #{e.message}"
47
+ end
48
+ end
49
+ end
29
50
 
30
51
  class Naver
31
- def initialize
52
+ def initialize
53
+ begin
54
+ ChromeKiller.kill_selenium_chrome
55
+ sleep(1)
56
+ rescue => e
57
+ puts "크롬 창 초기화 시도 중 오류 발생: #{e.message} (무시하고 진행)"
32
58
  end
59
+ end
60
+
33
61
 
34
-
35
62
  def chrome_setup(proxy, board_cookie_dir = "C:/board_cookie")
36
63
  board_cookie_dir = "C:/board_cookie"
37
64
  FileUtils.mkdir_p(board_cookie_dir) unless File.exist?(board_cookie_dir)
@@ -223,37 +250,36 @@ class Naver
223
250
  sleep(1)
224
251
 
225
252
  chrome_start(proxy, board_cookie_dir)
253
+
226
254
 
227
- # 열린 모든 탭 핸들 확인
255
+ target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
256
+
228
257
  all_windows = @driver.window_handles
229
- #puts "현재 열려 있는 탭 수: #{all_windows.size}" # 열린 탭 수 출력
230
258
 
231
- # 원하는 URL
232
- target_url = "https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko"
259
+ # target_url로 열린 탭들만 필터링
260
+ target_tabs = all_windows.select do |win|
261
+ @driver.switch_to.window(win)
262
+ @driver.current_url == target_url
263
+ end
233
264
 
234
- # 탭을 순회하면서
235
- all_windows.each do |window|
236
- @driver.switch_to.window(window)
237
- current_url = @driver.current_url
238
- #puts "탭 URL: #{current_url}" # 각 탭 URL 출력
239
-
240
- # 원하는 URL이 아니면 탭을 닫기
241
- if current_url != target_url
242
- begin
243
- @driver.close # 다른 탭을 닫기
244
- rescue Selenium::WebDriver::Error::WebDriverError => e
245
- #puts "탭을 닫는 데 오류 발생: #{e.message}"
246
- end
265
+ # 남길 탭: target_url 탭 중 가장 마지막 (없으면 빈 배열)
266
+ tabs_to_keep = target_tabs.empty? ? [] : [target_tabs.last]
267
+
268
+ # 닫을 탭 = 전체에서 남길 탭 제외
269
+ tabs_to_close = all_windows - tabs_to_keep
270
+
271
+ tabs_to_close.each do |win|
272
+ begin
273
+ @driver.switch_to.window(win)
274
+ @driver.close
275
+ rescue Selenium::WebDriver::Error::WebDriverError => e
276
+ # 닫기 실패해도 무시
247
277
  end
248
278
  end
249
279
 
250
- # 남아 있는 탭으로 전환
251
- all_windows = @driver.window_handles # 남은 탭 리스트 갱신
252
- if all_windows.size > 0
253
- @driver.switch_to.window(all_windows.first) # 남아 있는 첫 번째 탭으로 전환
254
- else
255
- #puts "남은 탭이 없습니다."
256
- end
280
+ # 남아있는 탭으로 포커스 이동 (남은 게 있으면)
281
+ remaining_windows = @driver.window_handles
282
+ @driver.switch_to.window(remaining_windows.first) if remaining_windows.any?
257
283
 
258
284
 
259
285
 
@@ -775,22 +801,65 @@ def update(user_id, user_pw, title, content, option, post_url, signup_url, login
775
801
  sleep(1)
776
802
  rescue
777
803
  begin
778
- # 타임아웃을 77초로 설정
779
- wait = Selenium::WebDriver::Wait.new(:timeout => 150)
780
- # 요소가 나타날 때까지 100초 동안 기다립니다.
781
- wait.until { @driver.find_elements(:xpath, '//*[@class="spacer"]').size == 0 }
782
- sleep(1)
783
-
784
- #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
785
- puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
786
- sleep(5)
787
- rescue => e
788
- puts '-[√] 캡챠 해제 실패(캡챠는 사람이 풀기에 간혹 실수로 실패가 될수있습니다.).......'.red
789
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
790
- puts e
791
- @driver.close
792
- return 0
793
- end
804
+ # 타임아웃을 77초로 설정
805
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
806
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
807
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
808
+ sleep(1)
809
+
810
+ #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
811
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
812
+ sleep(7)
813
+ begin
814
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
815
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
816
+
817
+ original_tab = @driver.window_handle
818
+
819
+ @driver.switch_to.new_window(:tab)
820
+ new_tab = @driver.window_handle # 새 탭 핸들 저장
821
+
822
+ @driver.get('chrome://extensions/')
823
+ sleep(3)
824
+
825
+ # 마우스 및 키보드 입력 시도
826
+ mouse_move_percentage(0.35, 0.02)
827
+ sleep(0.5)
828
+ left_click
829
+ sleep(1)
830
+ key_stroke('enter')
831
+ sleep(1)
832
+ 6.times do
833
+ key_stroke('tab')
834
+ sleep(0.5)
835
+ end
836
+ key_stroke('enter')
837
+ sleep(1)
838
+
839
+
840
+
841
+ # 원래 탭으로 전환
842
+ @driver.switch_to.window(original_tab)
843
+ @driver.navigate.refresh
844
+ sleep(10)
845
+ @driver.switch_to.window(new_tab)
846
+ sleep(1)
847
+ # 마우스 및 키보드 입력 시도
848
+ mouse_move_percentage(0.35, 0.02)
849
+ sleep(0.5)
850
+ left_click
851
+ sleep(1)
852
+ key_stroke('enter')
853
+ sleep(1)
854
+ @driver.close
855
+ sleep(1)
856
+ @driver.switch_to.window(original_tab)
857
+ sleep(1)
858
+ rescue
859
+ end
860
+
861
+ rescue
862
+ end
794
863
  end
795
864
  rescue
796
865
  begin
@@ -3752,12 +3821,60 @@ login_url = option['login_url'].to_s
3752
3821
  # 타임아웃을 77초로 설정
3753
3822
  wait = Selenium::WebDriver::Wait.new(:timeout => 150)
3754
3823
  # 요소가 나타날 때까지 100초 동안 기다립니다.
3755
- wait.until { @driver.find_elements(:xpath, '//*[@class="spacer"]').size == 0 }
3824
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
3756
3825
  sleep(1)
3757
3826
 
3758
3827
  #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
3759
3828
  puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
3760
- sleep(5)
3829
+ sleep(7)
3830
+ begin
3831
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
3832
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
3833
+
3834
+ original_tab = @driver.window_handle
3835
+
3836
+ @driver.switch_to.new_window(:tab)
3837
+ new_tab = @driver.window_handle # 새 탭 핸들 저장
3838
+
3839
+ @driver.get('chrome://extensions/')
3840
+ sleep(3)
3841
+
3842
+ # 마우스 및 키보드 입력 시도
3843
+ mouse_move_percentage(0.35, 0.02)
3844
+ sleep(0.5)
3845
+ left_click
3846
+ sleep(1)
3847
+ key_stroke('enter')
3848
+ sleep(1)
3849
+ 6.times do
3850
+ key_stroke('tab')
3851
+ sleep(0.5)
3852
+ end
3853
+ key_stroke('enter')
3854
+ sleep(1)
3855
+
3856
+
3857
+
3858
+ # 원래 탭으로 전환
3859
+ @driver.switch_to.window(original_tab)
3860
+ @driver.navigate.refresh
3861
+ sleep(10)
3862
+ @driver.switch_to.window(new_tab)
3863
+ sleep(1)
3864
+ # 마우스 및 키보드 입력 시도
3865
+ mouse_move_percentage(0.35, 0.02)
3866
+ sleep(0.5)
3867
+ left_click
3868
+ sleep(1)
3869
+ key_stroke('enter')
3870
+ sleep(1)
3871
+ @driver.close
3872
+ sleep(1)
3873
+ @driver.switch_to.window(original_tab)
3874
+ sleep(1)
3875
+ rescue
3876
+ end
3877
+
3761
3878
  rescue
3762
3879
  end
3763
3880
  end
@@ -3849,6 +3966,8 @@ login_url = option['login_url'].to_s
3849
3966
  end
3850
3967
  ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
3851
3968
 
3969
+
3970
+
3852
3971
 
3853
3972
  begin
3854
3973
  # 요소 찾기 타임아웃을 10초로 설정
@@ -4990,10 +5109,11 @@ login_url = option['login_url'].to_s
4990
5109
 
4991
5110
 
4992
5111
 
4993
-
4994
5112
  rescue => e
4995
5113
  #puts '-[√] 로그인 PASS.......'.cyan
5114
+
4996
5115
  puts e
5116
+
4997
5117
  end
4998
5118
 
4999
5119
 
@@ -5555,34 +5675,71 @@ post_url = option['post_url'].to_s
5555
5675
  sleep(1)
5556
5676
  rescue
5557
5677
  begin
5558
- # 타임아웃을 77초로 설정
5559
- wait = Selenium::WebDriver::Wait.new(:timeout => 150)
5560
- # 요소가 나타날 때까지 100초 동안 기다립니다.
5561
- wait.until { @driver.find_elements(:xpath, '//*[@class="spacer"]').size == 0 }
5562
- sleep(1)
5563
-
5564
- #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
5565
- puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
5566
- sleep(5)
5567
- rescue => e
5568
- puts '-[√] 캡챠 해제 실패(캡챠는 사람이 풀기에 간혹 실수로 실패가 될수있습니다.).......'.red
5569
- puts '-[√] 다음 작업 준비로 약 1초~60초 내외 시간이 소요됩니다.......'.red
5570
- puts e
5571
- @driver.close
5572
- return 0
5573
- end
5574
- end
5575
- rescue
5576
-
5577
- end
5578
- end
5579
- ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
5678
+ # 타임아웃을 77초로 설정
5679
+ wait = Selenium::WebDriver::Wait.new(:timeout => 150)
5680
+ # 요소가 나타날 때까지 100초 동안 기다립니다.
5681
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="solved"]') }
5682
+ sleep(1)
5683
+
5684
+ #@driver.find_element(:xpath, '//*[@data-state="solved"]').click
5685
+ puts '-[√] 캡챠 해제 완료 → 이어서 진행 합니다.......'.green
5686
+ sleep(7)
5687
+ begin
5688
+ wait = Selenium::WebDriver::Wait.new(timeout: 10)
5689
+ wait.until { @driver.find_element(:xpath, '//*[@data-state="ready"]') }
5580
5690
 
5691
+ original_tab = @driver.window_handle
5581
5692
 
5693
+ @driver.switch_to.new_window(:tab)
5694
+ new_tab = @driver.window_handle # 새 탭 핸들 저장
5582
5695
 
5696
+ @driver.get('chrome://extensions/')
5697
+ sleep(3)
5698
+
5699
+ # 마우스 및 키보드 입력 시도
5700
+ mouse_move_percentage(0.35, 0.02)
5701
+ sleep(0.5)
5702
+ left_click
5703
+ sleep(1)
5704
+ key_stroke('enter')
5705
+ sleep(1)
5706
+ 6.times do
5707
+ key_stroke('tab')
5708
+ sleep(0.5)
5709
+ end
5710
+ key_stroke('enter')
5711
+ sleep(1)
5583
5712
 
5713
+
5584
5714
 
5715
+ # 원래 탭으로 전환
5716
+ @driver.switch_to.window(original_tab)
5717
+ @driver.navigate.refresh
5718
+ sleep(10)
5719
+ @driver.switch_to.window(new_tab)
5720
+ sleep(1)
5721
+ # 마우스 및 키보드 입력 시도
5722
+ mouse_move_percentage(0.35, 0.02)
5723
+ sleep(0.5)
5724
+ left_click
5725
+ sleep(1)
5726
+ key_stroke('enter')
5727
+ sleep(1)
5728
+ @driver.close
5729
+ sleep(1)
5730
+ @driver.switch_to.window(original_tab)
5731
+ sleep(1)
5732
+ rescue
5733
+ end
5585
5734
 
5735
+ rescue
5736
+ end
5737
+ end
5738
+ rescue
5739
+
5740
+ end
5741
+ end
5742
+ ##<─────────────────────────────────────────────────────────────────────캡챠 해제 입력 코드 부분
5586
5743
 
5587
5744
 
5588
5745
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posting_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.101.999
4
+ version: 3.103.999
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-12 00:00:00.000000000 Z
10
+ date: 2025-06-13 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com