cafe_buy 0.0.39 → 0.0.51

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_buy.rb +99 -57
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 770e4ff2cb7dc9f603cc0e1c550f9e81ab69bf935fd079ce1dc40dd69e0a5a19
4
- data.tar.gz: dc94edba8336c8e6367e641026c12a7c67d33f158c5b6651a0f8ccddc894f1e7
3
+ metadata.gz: 655ab27b31f8113fcc7d97273c2da07906d2d3151ef8052b141c3e5f803edd00
4
+ data.tar.gz: c39b910dd65d5037d39f36aa8f728345a413e7d5f913a67c903f383af80fc261
5
5
  SHA512:
6
- metadata.gz: a513632a966cb20bf9877e98e19d3d9001a7dd9e53ba9cd6af7565a29a88a6c7ca6292ddd5dcc923742f49b515d0728159bd36e45c8df84e2f8511f2659daca8
7
- data.tar.gz: ff1f5f3aea886cf248d2a64240665194275b91459d0daf50222fbad7e9c64bd52a7642959362676aedbd2e1f4814cdc6f732b9dfe66aeb1e5120c0ba5ed7b859
6
+ metadata.gz: 49ee9783f88d12bf8e83e54aba4d8c57fc486915844265715e3d4c49e419e4149f42c6cf78609a0a44c91c999111ec3cfe99f2a332bcd5b8d9c8711d060c5a92
7
+ data.tar.gz: a6a4c5c299f3aa225b3f405f0371846b6513281097689f6cbc6efd4d8554b0176d9c67ced20815a87cc89f709436cb40a63c27ad3eea9180b3765746380020bb
data/lib/cafe_buy.rb CHANGED
@@ -235,9 +235,19 @@ class Naver
235
235
  options.add_argument('--disable-gpu')
236
236
  options.add_argument('--remote-debugging-port=9222')
237
237
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
238
- @driver = Selenium::WebDriver.for(:chrome, options: options)
239
- rescue
240
- @driver = Selenium::WebDriver.for(:chrome, options: options)
238
+ options.add_argument('--disable-blink-features=AutomationControlled') # JavaScript로 navigator.webdriver 숨기기
239
+
240
+ # 'capabilities'과 'options' 배열로 설정
241
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
242
+ capabilities["goog:chromeOptions"] = options.as_json
243
+
244
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
245
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
246
+
247
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
248
+
249
+ rescue => e
250
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
241
251
  end
242
252
  else
243
253
  begin
@@ -253,7 +263,17 @@ class Naver
253
263
  options.add_argument('--disable-gpu')
254
264
  options.add_argument('--remote-debugging-port=9222')
255
265
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
256
- @driver = Selenium::WebDriver.for(:chrome, options: options)
266
+
267
+ options.add_argument('--disable-blink-features=AutomationControlled') # JavaScript로 navigator.webdriver 숨기기
268
+
269
+ # 'capabilities'과 'options' 배열로 설정
270
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
271
+ capabilities["goog:chromeOptions"] = options.as_json
272
+
273
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
274
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
275
+
276
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
257
277
  rescue => e
258
278
  puts e
259
279
  puts 'proxy error...'
@@ -269,9 +289,18 @@ class Naver
269
289
  options.add_argument('--disable-gpu')
270
290
  options.add_argument('--remote-debugging-port=9222')
271
291
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
272
- @driver = Selenium::WebDriver.for(:chrome, options: options)
292
+ options.add_argument('--disable-blink-features=AutomationControlled') # JavaScript로 navigator.webdriver 숨기기
293
+
294
+ # 'capabilities'과 'options' 배열로 설정
295
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
296
+ capabilities["goog:chromeOptions"] = options.as_json
297
+
298
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
299
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
300
+
301
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
273
302
  rescue
274
- @driver = Selenium::WebDriver.for(:chrome, options: options)
303
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
275
304
  end
276
305
  end
277
306
  end
@@ -279,6 +308,7 @@ class Naver
279
308
 
280
309
 
281
310
 
311
+
282
312
  def login(user_id, user_pw, proxy)
283
313
  @user_id = user_id
284
314
  @user_id11 = user_id
@@ -2452,65 +2482,77 @@ class Wordpress
2452
2482
  puts table[10]
2453
2483
  if table[7].to_i > table[10].to_i
2454
2484
  if @data['포스트설정']['테더링'].checked?
2455
- puts 'tethering ip change...'
2456
-
2457
- # ADB devices 확인
2458
- stdout, stderr, status = Open3.capture3('./adb devices')
2459
- if status.success?
2460
- device_id = stdout.split("\n")[1].split("\t")[0]
2461
- puts device_id
2462
- puts 'adb -s ' + device_id + ' shell svc data disable'
2463
-
2464
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2465
- if status2.success?
2466
- sleep(3)
2467
- puts 'adb -s ' + device_id + ' shell svc data enable'
2468
- Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2469
- sleep(3)
2470
- puts 'adb ok'
2471
- sleep(8)
2472
-
2473
- # IP 확인 및 재시도 (반복문 사용)
2474
- retry_count = 0
2475
- max_retries = 5
2476
- current_ip = nil
2477
-
2478
- # 무한 루프 방지
2479
- while retry_count < max_retries
2480
- begin
2481
- http = HTTP.get('https://www.findip.kr/')
2482
- noko = Nokogiri::HTML(http.to_s)
2483
- new_ip = noko.xpath('/html/body/header/h2').text.strip
2484
-
2485
- puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2486
-
2487
- # IP가 변경되었으면 @my_ip를 갱신하고 종료
2488
- if new_ip != @my_ip
2489
- @my_ip = new_ip
2490
- puts "IP 변경됨: #{@my_ip}"
2491
- break
2492
- else
2493
- puts 'IP가 변경되지 않음. 재시도...'
2485
+ puts 'tethering ip change...'
2486
+
2487
+ # ADB devices 확인
2488
+ stdout, stderr, status = Open3.capture3('./adb devices')
2489
+ if status.success?
2490
+ device_id = stdout.split("\n")[1].split("\t")[0]
2491
+ puts device_id
2492
+
2493
+ # ADB 서버 초기화
2494
+ puts 'adb kill-server'
2495
+ Open3.capture3('adb kill-server')
2496
+ sleep(2)
2497
+
2498
+ # 다시 ADB 서버 실행
2499
+ puts 'adb start-server'
2500
+ Open3.capture3('adb start-server')
2501
+ sleep(2)
2502
+
2503
+ # 데이터를 끄고 켜기
2504
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2505
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2506
+
2507
+ if status2.success?
2508
+ sleep(3)
2509
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2510
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2511
+ sleep(3)
2512
+ puts 'adb ok'
2513
+ sleep(8)
2514
+
2515
+ # IP 확인 재시도 (반복문 사용)
2516
+ retry_count = 0
2517
+ max_retries = 5
2518
+ current_ip = nil
2519
+
2520
+ # 무한 루프 방지
2521
+ while retry_count < max_retries
2522
+ begin
2523
+ http = HTTP.get('https://www.findip.kr/')
2524
+ noko = Nokogiri::HTML(http.to_s)
2525
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2526
+
2527
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2528
+
2529
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2530
+ if new_ip != @my_ip
2531
+ @my_ip = new_ip
2532
+ puts "IP 변경됨: #{@my_ip}"
2533
+ break
2534
+ else
2535
+ puts 'IP가 변경되지 않음. 재시도...'
2536
+ retry_count += 1
2537
+ sleep(3) # 3초 후 재시도
2538
+ end
2539
+ rescue => e
2494
2540
  retry_count += 1
2495
2541
  sleep(3) # 3초 후 재시도
2496
2542
  end
2497
- rescue => e
2498
- retry_count += 1
2499
- sleep(3) # 3초 재시도
2500
- end
2501
-
2502
- # 최대 재시도 횟수를 초과하면 예외 발생시키기
2503
- if retry_count >= max_retries
2504
- raise "최대 재시도 횟수 초과. IP 변경 실패."
2543
+
2544
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2545
+ if retry_count >= max_retries
2546
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2547
+ end
2505
2548
  end
2549
+ else
2550
+ puts 'Failed to disable data. Error: ' + stderr2
2506
2551
  end
2507
2552
  else
2508
- puts 'Failed to disable data. Error: ' + stderr2
2553
+ puts 'adb error, unable to get devices. Error: ' + stderr
2509
2554
  end
2510
- else
2511
- puts 'adb error, unable to get devices. Error: ' + stderr
2512
2555
  end
2513
- end
2514
2556
 
2515
2557
  check_success = 1
2516
2558
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.51
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-07 00:00:00.000000000 Z
11
+ date: 2025-02-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com