njongto_duo 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_duo.rb +78 -25
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98362172929d84e95721b15124bc435e8e112520dc2dbebfeb1f255e8d98207c
4
- data.tar.gz: 1b18b9b09d145408624d758b762ab8bf6648a0cbec121c76ddf8ea15b221b6fb
3
+ metadata.gz: 4542f98629642152e98f6d1430f32932c214106e393531aeb106e30c8ce50888
4
+ data.tar.gz: 830383f6c4b45e2cb8a3113dc69cf2ec8dc5e01292143e7c13eaf362af5361b9
5
5
  SHA512:
6
- metadata.gz: 3aa4611aebae97f092a9a307a77489e524e5276e6bd6b123c8a891e874e466c908a3e00016697c8b0d3e7fa8ed86fdffa262c4db2a03487ae505f167d89d1343
7
- data.tar.gz: f62e23025cd78c048fea601a1ada411e8463b6b1857f091491f30f0bcb4db687208d46867c9847a7f5802833a088eec517524a41b70c59f4050b309803e53080
6
+ metadata.gz: d196feb03236cd01953af05db59749d66ae36360553a0d2e1c141aa72c1277f8608e80179bb8c20674f5f5198b09880b069bd49f7926e9f02e3803ad9cad465f
7
+ data.tar.gz: 9af99ff6c19e5977c712e3362def59d119c6cfa66525350bfc67e61379609bc3d9cdf0927897cf1fef524ad39a1d8ecc0900ff7aa950f23ae8c1eb6f6c74da1a
data/lib/njongto_duo.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
@@ -544,36 +567,66 @@ class Wordpress
544
567
  puts table[7]
545
568
  if table[5].to_i > table[7].to_i #설정을 맞게해줘야 실행이 됨
546
569
  if @data['포스트설정']['테더링'].checked?
547
- puts 'tedering ip change...'
570
+ puts 'Tethering IP change...'
571
+
548
572
  stdout, stderr, status = Open3.capture3('./adb devices')
573
+
549
574
  if status.success?
550
- device_id = stdout.split("\n")[1].split("\t")[0]
551
- puts device_id
552
- puts 'adb -s '+device_id+' shell svc data disable'
553
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
575
+ device_id = stdout.split("\n")[1].split("\t")[0]
576
+ puts device_id
577
+
578
+ # ADB 서버 초기화
579
+ puts 'adb kill-server'
580
+ Open3.capture3('adb kill-server')
581
+ sleep(2)
582
+
583
+ # 다시 ADB 서버 실행
584
+ puts 'adb start-server'
585
+ Open3.capture3('adb start-server')
586
+ sleep(2)
587
+
588
+ # 데이터를 끄고 켜기
589
+ puts 'adb -s ' + device_id + ' shell svc data disable'
590
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
591
+
592
+ if status2.success?
554
593
  sleep(3)
555
- puts 'adb -s '+device_id+' shell svc data enable'
556
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
594
+ puts 'adb -s ' + device_id + ' shell svc data enable'
595
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
557
596
  sleep(3)
558
597
  puts 'adb ok'
559
598
  sleep(8)
599
+
600
+ # IP 변경을 확인하는 람다 함수
560
601
  robot_ip = lambda do
561
- http = HTTP.get('https://www.findip.kr/')
562
- noko = Nokogiri::HTML(http.to_s)
563
- if noko.xpath('/html/body/header/h2').text != @my_ip
564
- @my_ip = noko.xpath('/html/body/header/h2').text
565
- else
566
- puts @my_ip
567
- puts'[테더링] 연결 재시도.......'.red
568
- sleep(3)
569
- robot_ip[]
602
+ loop do # 무한 루프
603
+ begin
604
+ http = HTTP.get('https://www.findip.kr/')
605
+ noko = Nokogiri::HTML(http.to_s)
606
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
607
+
608
+ if new_ip != @my_ip
609
+ @my_ip = new_ip
610
+ puts "IP 변경됨: #{@my_ip}"
611
+ break # IP가 변경되었으면 루프 종료
612
+ else
613
+ puts 'IP가 변경되지 않음. 재시도...'
614
+ sleep(3) # 3초 후 재시도
615
+ end
616
+ rescue => e
617
+ puts "IP 확인 중 오류 발생: #{e.message}. 재시도 중..."
618
+ sleep(3) # 3초 후 재시도
570
619
  end
620
+ end
571
621
  end
572
- robot_ip[]
622
+ robot_ip[] # 최초 호출
623
+ else
624
+ puts 'Failed to disable data. Error: ' + stderr2
625
+ end
573
626
  else
574
- puts 'adb error pass'.red
627
+ puts 'adb error, unable to get devices. Error: ' + stderr
575
628
  end
576
- end
629
+ end
577
630
 
578
631
  check_success = 1
579
632
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njongto_duo
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