cafe_basics 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_basics.rb +98 -57
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b06b45f7b30acd8084b197547c03effb6ca58ec56b11c4daeeaa98734eefc3a
4
- data.tar.gz: 89b2277ffcc2bbc4da6b6cf45a92597103684813633801f7540d046fdd100516
3
+ metadata.gz: 005fc1b1a606bc76cd284bdb214e9ec477775f9f8e5ca78e71840073ba34664a
4
+ data.tar.gz: 6c62486ad35a2b165c47cbb061663354ec2e33b99b70af074c9a50602fdd8907
5
5
  SHA512:
6
- metadata.gz: 87e5fde891f962134677d6db010490cb16d298d9fb1523568540e56e2cd458deb09267989bcb5126c7f93362464bd60b5711e5542b887769b2ff64165b2d981b
7
- data.tar.gz: 1c98353ff8aa441a921b0fa33d948771812b8f57f9b552b2b90bc60fa81c99636c09ae96367715b8d16454d63818d93acf21b90780038887e3d443f17c7a4c61
6
+ metadata.gz: 731252f0665ad0a6911d8f0ad7aa5d07feb534c933f101e5528386858d73b9e89fbce87038fd4df29777ba1073b60d82e58f586ac1788d94c837dad80dd3b4ef
7
+ data.tar.gz: da197145ae00a7137586e0a33b8470d55a96063eaa95bb3941cc1cea08b5c9464c2922ecefdaef85bc001cf7780f6e847b69c5d542fad1f3fa6e37b2da351711
data/lib/cafe_basics.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
@@ -2122,65 +2151,77 @@ class Wordpress
2122
2151
  puts table[10]
2123
2152
  if table[7].to_i > table[10].to_i
2124
2153
  if @data['포스트설정']['테더링'].checked?
2125
- puts 'tethering ip change...'
2126
-
2127
- # ADB devices 확인
2128
- stdout, stderr, status = Open3.capture3('./adb devices')
2129
- if status.success?
2130
- device_id = stdout.split("\n")[1].split("\t")[0]
2131
- puts device_id
2132
- puts 'adb -s ' + device_id + ' shell svc data disable'
2133
-
2134
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2135
- if status2.success?
2136
- sleep(3)
2137
- puts 'adb -s ' + device_id + ' shell svc data enable'
2138
- Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2139
- sleep(3)
2140
- puts 'adb ok'
2141
- sleep(8)
2142
-
2143
- # IP 확인 및 재시도 (반복문 사용)
2144
- retry_count = 0
2145
- max_retries = 5
2146
- current_ip = nil
2147
-
2148
- # 무한 루프 방지
2149
- while retry_count < max_retries
2150
- begin
2151
- http = HTTP.get('https://www.findip.kr/')
2152
- noko = Nokogiri::HTML(http.to_s)
2153
- new_ip = noko.xpath('/html/body/header/h2').text.strip
2154
-
2155
- puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2156
-
2157
- # IP가 변경되었으면 @my_ip를 갱신하고 종료
2158
- if new_ip != @my_ip
2159
- @my_ip = new_ip
2160
- puts "IP 변경됨: #{@my_ip}"
2161
- break
2162
- else
2163
- puts 'IP가 변경되지 않음. 재시도...'
2154
+ puts 'tethering ip change...'
2155
+
2156
+ # ADB devices 확인
2157
+ stdout, stderr, status = Open3.capture3('./adb devices')
2158
+ if status.success?
2159
+ device_id = stdout.split("\n")[1].split("\t")[0]
2160
+ puts device_id
2161
+
2162
+ # ADB 서버 초기화
2163
+ puts 'adb kill-server'
2164
+ Open3.capture3('adb kill-server')
2165
+ sleep(2)
2166
+
2167
+ # 다시 ADB 서버 실행
2168
+ puts 'adb start-server'
2169
+ Open3.capture3('adb start-server')
2170
+ sleep(2)
2171
+
2172
+ # 데이터를 끄고 켜기
2173
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2174
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2175
+
2176
+ if status2.success?
2177
+ sleep(3)
2178
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2179
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2180
+ sleep(3)
2181
+ puts 'adb ok'
2182
+ sleep(8)
2183
+
2184
+ # IP 확인 재시도 (반복문 사용)
2185
+ retry_count = 0
2186
+ max_retries = 5
2187
+ current_ip = nil
2188
+
2189
+ # 무한 루프 방지
2190
+ while retry_count < max_retries
2191
+ begin
2192
+ http = HTTP.get('https://www.findip.kr/')
2193
+ noko = Nokogiri::HTML(http.to_s)
2194
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2195
+
2196
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2197
+
2198
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2199
+ if new_ip != @my_ip
2200
+ @my_ip = new_ip
2201
+ puts "IP 변경됨: #{@my_ip}"
2202
+ break
2203
+ else
2204
+ puts 'IP가 변경되지 않음. 재시도...'
2205
+ retry_count += 1
2206
+ sleep(3) # 3초 후 재시도
2207
+ end
2208
+ rescue => e
2164
2209
  retry_count += 1
2165
2210
  sleep(3) # 3초 후 재시도
2166
2211
  end
2167
- rescue => e
2168
- retry_count += 1
2169
- sleep(3) # 3초 재시도
2170
- end
2171
-
2172
- # 최대 재시도 횟수를 초과하면 예외 발생시키기
2173
- if retry_count >= max_retries
2174
- raise "최대 재시도 횟수 초과. IP 변경 실패."
2212
+
2213
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2214
+ if retry_count >= max_retries
2215
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2216
+ end
2175
2217
  end
2218
+ else
2219
+ puts 'Failed to disable data. Error: ' + stderr2
2176
2220
  end
2177
2221
  else
2178
- puts 'Failed to disable data. Error: ' + stderr2
2222
+ puts 'adb error, unable to get devices. Error: ' + stderr
2179
2223
  end
2180
- else
2181
- puts 'adb error, unable to get devices. Error: ' + stderr
2182
2224
  end
2183
- end
2184
2225
 
2185
2226
 
2186
2227
  check_success = 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
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