njongto_zon 0.0.50 → 0.0.52

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/njongto_zon.rb +78 -25
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e232b8c01c3212569ad740e7aa535ab3f47a85c33f7bef6b407ad9ae7c87c554
4
- data.tar.gz: a362964a7a438d1f22c819a24b0f98531f774763352576d9f22aefdb26bf3ad4
3
+ metadata.gz: f83981bed05f139863890be134a0c3fa42346b9bb8760b2cdb694ce49333f7c7
4
+ data.tar.gz: fbf01d18464135bc51f3588b467b881573a40e081107bf713f74324b5bd97e17
5
5
  SHA512:
6
- metadata.gz: 218ed83d85b421d7c370af1c672fe958793940c16e10d82a1a670a719536de11626f63e29e678c8c906d379281d1d084c0ffc429b3de1407d38c21345b934b2d
7
- data.tar.gz: 2bca8cc878a9ea831d5d3b015d74114d64e648d053f6ace3c0adb693e38e39ff11b4b68021ceb9980cbdb27af9b5c06c4252edcc2fbcf6f379cb3afb189c4c7b
6
+ metadata.gz: 47a3cc2fe9cbb63a0af73beb8b262d3963a28b2f9b9c80ff7522107544d2581459c7d3ade7c803dd72e9a670958e696aafbbe2187a216812d4440ab95d550e47
7
+ data.tar.gz: 9bacd4145576d5599e497843dbaf46de553a112c39c05071a4cc072def02eacf76a6cf22faa41536b9b08491c2c8dff5e5967035ff34cfd3ad3a4408d27d52c8
data/lib/njongto_zon.rb CHANGED
@@ -51,9 +51,17 @@ class Naver
51
51
  options.add_argument('--disable-gpu')
52
52
  options.add_argument('--remote-debugging-port=9222')
53
53
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
54
- @driver = Selenium::WebDriver.for(:chrome, options: options)
55
- rescue
56
- @driver = Selenium::WebDriver.for(:chrome, options: options)
54
+ # 'capabilities'과 'options' 배열로 설정
55
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
56
+ capabilities["goog:chromeOptions"] = options.as_json
57
+
58
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
59
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
60
+
61
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
62
+
63
+ rescue => e
64
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
57
65
  end
58
66
  else
59
67
  begin
@@ -69,7 +77,14 @@ class Naver
69
77
  options.add_argument('--disable-gpu')
70
78
  options.add_argument('--remote-debugging-port=9222')
71
79
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
72
- @driver = Selenium::WebDriver.for(:chrome, options: options)
80
+ # 'capabilities'과 'options' 배열로 설정
81
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
82
+ capabilities["goog:chromeOptions"] = options.as_json
83
+
84
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
85
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
86
+
87
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
73
88
  rescue => e
74
89
  puts e
75
90
  puts 'proxy error...'
@@ -85,9 +100,16 @@ class Naver
85
100
  options.add_argument('--disable-gpu')
86
101
  options.add_argument('--remote-debugging-port=9222')
87
102
  options.add_argument('user-data-dir=C:/naver_cookie/' + user_id)
88
- @driver = Selenium::WebDriver.for(:chrome, options: options)
103
+ # 'capabilities'과 'options' 배열로 설정
104
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
105
+ capabilities["goog:chromeOptions"] = options.as_json
106
+
107
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
108
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
109
+
110
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
89
111
  rescue
90
- @driver = Selenium::WebDriver.for(:chrome, options: options)
112
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
91
113
  end
92
114
  end
93
115
  end
@@ -95,6 +117,7 @@ class Naver
95
117
 
96
118
 
97
119
 
120
+
98
121
  def login(user_id, user_pw, proxy)
99
122
  @user_id = user_id
100
123
  @user_id11 = user_id
@@ -474,36 +497,66 @@ end
474
497
  puts table[7]
475
498
  if table[5].to_i > table[7].to_i #설정을 맞게해줘야 실행이 됨
476
499
  if @data['포스트설정']['테더링'].checked?
477
- puts 'tedering ip change...'
500
+ puts 'Tethering IP change...'
501
+
478
502
  stdout, stderr, status = Open3.capture3('./adb devices')
503
+
479
504
  if status.success?
480
- device_id = stdout.split("\n")[1].split("\t")[0]
481
- puts device_id
482
- puts 'adb -s '+device_id+' shell svc data disable'
483
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
505
+ device_id = stdout.split("\n")[1].split("\t")[0]
506
+ puts device_id
507
+
508
+ # ADB 서버 초기화
509
+ puts 'adb kill-server'
510
+ Open3.capture3('adb kill-server')
511
+ sleep(2)
512
+
513
+ # 다시 ADB 서버 실행
514
+ puts 'adb start-server'
515
+ Open3.capture3('adb start-server')
516
+ sleep(2)
517
+
518
+ # 데이터를 끄고 켜기
519
+ puts 'adb -s ' + device_id + ' shell svc data disable'
520
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
521
+
522
+ if status2.success?
484
523
  sleep(3)
485
- puts 'adb -s '+device_id+' shell svc data enable'
486
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
524
+ puts 'adb -s ' + device_id + ' shell svc data enable'
525
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
487
526
  sleep(3)
488
527
  puts 'adb ok'
489
528
  sleep(8)
529
+
530
+ # IP 변경을 확인하는 람다 함수
490
531
  robot_ip = lambda do
491
- http = HTTP.get('https://www.findip.kr/')
492
- noko = Nokogiri::HTML(http.to_s)
493
- if noko.xpath('/html/body/header/h2').text != @my_ip
494
- @my_ip = noko.xpath('/html/body/header/h2').text
495
- else
496
- puts @my_ip
497
- puts'[테더링] 연결 재시도.......'.red
498
- sleep(3)
499
- robot_ip[]
532
+ loop do # 무한 루프
533
+ begin
534
+ http = HTTP.get('https://www.findip.kr/')
535
+ noko = Nokogiri::HTML(http.to_s)
536
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
537
+
538
+ if new_ip != @my_ip
539
+ @my_ip = new_ip
540
+ puts "IP 변경됨: #{@my_ip}"
541
+ break # IP가 변경되었으면 루프 종료
542
+ else
543
+ puts 'IP가 변경되지 않음. 재시도...'
544
+ sleep(3) # 3초 후 재시도
545
+ end
546
+ rescue => e
547
+ puts "IP 확인 중 오류 발생: #{e.message}. 재시도 중..."
548
+ sleep(3) # 3초 후 재시도
500
549
  end
550
+ end
501
551
  end
502
- robot_ip[]
552
+ robot_ip[] # 최초 호출
553
+ else
554
+ puts 'Failed to disable data. Error: ' + stderr2
555
+ end
503
556
  else
504
- puts 'adb error pass'.red
557
+ puts 'adb error, unable to get devices. Error: ' + stderr
505
558
  end
506
- end
559
+ end
507
560
 
508
561
  check_success = 1
509
562
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njongto_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.52
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