cafe_basics_duo 0.0.57 → 0.0.70

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/cafe_basics_duo.rb +72 -36
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c27bef52165f76a872fd99567c0994b41e14e7b5fe5fd744e60aff6a9fa684a5
4
- data.tar.gz: 0c1ff9f0e0f26624e4deb595343ed68cb2ac1267e8341969642e42e816a2c05e
3
+ metadata.gz: ea5feb7b70f1bec72be681017e62af54ceff0970871158320cab18ecd95ef198
4
+ data.tar.gz: 1cee6247918642c33e0156c720384f9797c2ce21d10f15d88816b308bd444d56
5
5
  SHA512:
6
- metadata.gz: 8063886c46501d412944913befb416f2096a5757705566d5c86d5bdefb2d0790573d125d9d0ddb034fb4e668f0e23c6c08ee333f6cef0c449f560ad0275d834e
7
- data.tar.gz: c5f53f6a0b44aa3607c32501900f940ceae3e9fe81c24dde0c5c789b95ad7bc2c39218c95e765e02fe5246ba27f5cf553c329c384119379f39edefbbd6d02df2
6
+ metadata.gz: 288d4f6e629df681f3a64dfe62c1d19551f6241649a3b437881a367b35e9c657f5e4b8952f722facce7d0baac4644fbdd58220c37e078a8ae2491f9eecd0c830
7
+ data.tar.gz: 671c6e8cd006d2fb9c68c6d94e36f0cec26936ede5e32c825225484743969d159c7434a20c5ecedbfe831f9ce575be4a40bbaa2f38c9bd0bfacab0665ded5221
@@ -246,9 +246,13 @@ class Naver
246
246
  naver_cookie_dir = "C:/naver_cookie"
247
247
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
248
248
  if proxy == ''
249
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
249
+
250
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --no-first-run --no-default-browser-check --disable-sync})
251
+
250
252
  else
251
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" "https://naver.com/" --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s}})
253
+
254
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync})
255
+
252
256
  end
253
257
  end
254
258
  def chrome_start(proxy, user_id)
@@ -260,6 +264,9 @@ class Naver
260
264
  options = Selenium::WebDriver::Chrome::Options.new
261
265
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
262
266
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
267
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
268
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
269
+ options.add_argument('--no-default-browser-check')
263
270
  options.page_load_strategy = :normal
264
271
  options.timeouts = {page_load: 20_000}
265
272
  options.page_load_strategy = 'none'
@@ -285,6 +292,9 @@ class Naver
285
292
  options = Selenium::WebDriver::Chrome::Options.new
286
293
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
287
294
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
295
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
296
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
297
+ options.add_argument('--no-default-browser-check')
288
298
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
289
299
  options.page_load_strategy = :normal
290
300
  options.timeouts = {page_load: 20_000}
@@ -309,6 +319,9 @@ class Naver
309
319
  options = Selenium::WebDriver::Chrome::Options.new
310
320
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
311
321
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
322
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
323
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
324
+ options.add_argument('--no-default-browser-check')
312
325
  options.page_load_strategy = :normal
313
326
  options.timeouts = {page_load: 20_000}
314
327
  options.page_load_strategy = 'none'
@@ -334,6 +347,7 @@ class Naver
334
347
 
335
348
 
336
349
 
350
+
337
351
  def login(user_id, user_pw, proxy)
338
352
  @user_id = user_id
339
353
  @user_id11 = user_id
@@ -372,13 +386,20 @@ class Naver
372
386
  puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
373
387
  sleep(2.5)
374
388
  rescue
375
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
376
- #요소가 나타날 때까지 3초 동안 기다립니다.
377
- wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
378
- sleep(1.5)
379
- @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
380
- check_cookie_login = 0
381
- sleep(1)
389
+ begin
390
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
391
+ # 요소가 나타날 때까지 기다립니다.
392
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
393
+ sleep(1.5)
394
+
395
+ # 요소가 있으면 클릭
396
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
397
+ check_cookie_login = 0
398
+ sleep(1)
399
+ rescue
400
+ @driver.quit
401
+ return 0
402
+ end
382
403
  end
383
404
 
384
405
  if check_cookie_login == 0
@@ -413,8 +434,9 @@ class Naver
413
434
  puts "Failed to close tab: #{e.message}"
414
435
  end
415
436
  end
416
- return 0
417
437
  @driver.quit
438
+ return 0
439
+
418
440
  end
419
441
 
420
442
  else
@@ -437,8 +459,9 @@ class Naver
437
459
  puts "Failed to close tab: #{e.message}"
438
460
  end
439
461
  end
440
- return 0
441
462
  @driver.quit
463
+ return 0
464
+
442
465
  end
443
466
  end
444
467
 
@@ -764,8 +787,9 @@ class Naver
764
787
  puts "Failed to close tab: #{e.message}"
765
788
  end
766
789
  end
767
- return 0
768
- @driver.quit
790
+ @driver.quit
791
+ return 0
792
+
769
793
  end
770
794
 
771
795
 
@@ -793,8 +817,9 @@ class Naver
793
817
  puts "Failed to close tab: #{e.message}"
794
818
  end
795
819
  end
796
- return 0
797
820
  @driver.quit
821
+ return 0
822
+
798
823
  end
799
824
  sleep(2)
800
825
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -2248,7 +2273,7 @@ class Wordpress
2248
2273
  puts 'Tethering IP change...'
2249
2274
 
2250
2275
  stdout, stderr, status = Open3.capture3('./adb devices')
2251
-
2276
+
2252
2277
  if status.success?
2253
2278
  device_id = stdout.split("\n")[1].split("\t")[0]
2254
2279
  puts device_id
@@ -2256,42 +2281,53 @@ class Wordpress
2256
2281
  # ADB 서버 초기화
2257
2282
  puts 'adb kill-server'
2258
2283
  Open3.capture3('./adb kill-server')
2259
- sleep(3)
2284
+ sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
2260
2285
 
2261
2286
  # 다시 ADB 서버 실행
2262
2287
  puts 'adb start-server'
2263
2288
  Open3.capture3('./adb start-server')
2264
- sleep(3)
2289
+ sleep(5) # ADB 서버가 안정될 시간을 충분히 주기
2265
2290
 
2266
2291
  # 데이터를 끄고 켜기
2267
2292
  puts 'adb -s ' + device_id + ' shell svc data disable'
2268
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
2269
- sleep(3)
2293
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2294
+ puts "stderr: #{stderr2}" unless status2.success? # 오류 출력
2295
+ sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
2270
2296
  puts 'adb -s ' + device_id + ' shell svc data enable'
2271
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
2272
- sleep(3)
2297
+ stdout3, stderr3, status3 = Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2298
+ puts "stderr: #{stderr3}" unless status3.success? # 오류 출력
2299
+ sleep(5) # 네트워크가 안정될 시간을 더 줍니다.
2273
2300
  puts 'adb ok'
2274
2301
  sleep(8)
2275
-
2302
+
2303
+ # IP 변경 확인을 위한 람다 함수
2276
2304
  robot_ip = lambda do
2277
- http = HTTP.get('https://www.findip.kr/')
2278
- noko = Nokogiri::HTML(http.to_s)
2279
- if noko.xpath('/html/body/header/h2').text != @my_ip
2280
- @my_ip = noko.xpath('/html/body/header/h2').text
2305
+ begin
2306
+ # IP 변경 확인
2307
+ http = HTTP.get('https://www.findip.kr/')
2308
+ noko = Nokogiri::HTML(http.to_s)
2309
+
2310
+ current_ip = noko.xpath('/html/body/header/h2').text.strip
2311
+ if current_ip != @my_ip
2312
+ @my_ip = current_ip
2281
2313
  puts "IP 변경됨[ #{@my_ip} ]"
2282
- else
2283
- puts @my_ip
2284
- puts '제시도...'
2285
- sleep(3)
2286
- robot_ip[]
2314
+ else
2315
+ puts "현재 IP: #{@my_ip}"
2316
+ puts 'IP 변경이 감지되지 않았습니다. 다시 시도합니다...'
2317
+ sleep(5) # 여유롭게 대기 시간 증가
2318
+ robot_ip[] # 재시도
2319
+ end
2320
+ rescue HTTP::ConnectionError => e
2321
+ puts "네트워크 오류 발생: #{e.message}. 재시도 중..."
2322
+ sleep(5) # 재시도 간 여유 시간 추가
2323
+ retry # 재시도
2287
2324
  end
2288
- end
2289
- robot_ip[]
2290
-
2325
+ end
2326
+ robot_ip[] # IP 확인 시작
2291
2327
  else
2292
- puts 'adb error pass'
2328
+ puts "adb devices 명령어 실행 실패. stderr: #{stderr}"
2293
2329
  end
2294
- end
2330
+ end
2295
2331
 
2296
2332
 
2297
2333
  check_success = 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57
4
+ version: 0.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-13 00:00:00.000000000 Z
11
+ date: 2025-02-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com