cafe_basics_duo 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_duo.rb +99 -57
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7ea78320bab5a2a6d1f35a574aab41c67fbc22b51cb8bf6dcb4f9f194a555fd
4
- data.tar.gz: 2bbc4ee8ce16396133bcfed9da180eb1588379f4bd21511273e902eade0c1c1e
3
+ metadata.gz: 6d5adc1d0918824e0d5cadaf746e8eaab19c627bed0ab07ff45bd42e2e631dc8
4
+ data.tar.gz: 1a7b5ae5b17be69abad640e976df60a459d233c93d5af0d952dd7ab1ac8946ac
5
5
  SHA512:
6
- metadata.gz: 5feb9d123e8e22613fa35029d9c20be5cce9761fdb218b1ba58a5548400c149e02c86644e46a8a5168b11da6175750ad462a0c04b48bd6930a0edf5aba45b51b
7
- data.tar.gz: ee1221949df05ce7d63d106f73c1728a13a31ef9b050aebdf3a9a310a26eb1fd7cfaa9a3b906b75234a02deef7e1888104e4dfc7fe6fc90d150cb9b1342d42a7
6
+ metadata.gz: 2facbd7fc6a988a5a0d420f4afdf286ff76e3e59e07ca8d39ab385ef4552cc468ecdc864b2152aab8e43b34d19ef2a7ff8014d4ba8d7e2b810d0f4eafca176f7
7
+ data.tar.gz: e42dad0a696418eb8584e5c3b5dead7189b85875f29e35e33b6f66b63a767c8a18e9ba1c2adf44c53484c51dc005bcf62ce12b346476850813d41dfb36765317
@@ -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
@@ -2190,65 +2220,77 @@ class Wordpress
2190
2220
  puts table[10]
2191
2221
  if table[7].to_i > table[10].to_i
2192
2222
  if @data['포스트설정']['테더링'].checked?
2193
- puts 'tethering ip change...'
2194
-
2195
- # ADB devices 확인
2196
- stdout, stderr, status = Open3.capture3('./adb devices')
2197
- if status.success?
2198
- device_id = stdout.split("\n")[1].split("\t")[0]
2199
- puts device_id
2200
- puts 'adb -s ' + device_id + ' shell svc data disable'
2201
-
2202
- stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2203
- if status2.success?
2204
- sleep(3)
2205
- puts 'adb -s ' + device_id + ' shell svc data enable'
2206
- Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2207
- sleep(3)
2208
- puts 'adb ok'
2209
- sleep(8)
2210
-
2211
- # IP 확인 및 재시도 (반복문 사용)
2212
- retry_count = 0
2213
- max_retries = 5
2214
- current_ip = nil
2215
-
2216
- # 무한 루프 방지
2217
- while retry_count < max_retries
2218
- begin
2219
- http = HTTP.get('https://www.findip.kr/')
2220
- noko = Nokogiri::HTML(http.to_s)
2221
- new_ip = noko.xpath('/html/body/header/h2').text.strip
2222
-
2223
- puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2224
-
2225
- # IP가 변경되었으면 @my_ip를 갱신하고 종료
2226
- if new_ip != @my_ip
2227
- @my_ip = new_ip
2228
- puts "IP 변경됨: #{@my_ip}"
2229
- break
2230
- else
2231
- puts 'IP가 변경되지 않음. 재시도...'
2223
+ puts 'tethering ip change...'
2224
+
2225
+ # ADB devices 확인
2226
+ stdout, stderr, status = Open3.capture3('./adb devices')
2227
+ if status.success?
2228
+ device_id = stdout.split("\n")[1].split("\t")[0]
2229
+ puts device_id
2230
+
2231
+ # ADB 서버 초기화
2232
+ puts 'adb kill-server'
2233
+ Open3.capture3('adb kill-server')
2234
+ sleep(2)
2235
+
2236
+ # 다시 ADB 서버 실행
2237
+ puts 'adb start-server'
2238
+ Open3.capture3('adb start-server')
2239
+ sleep(2)
2240
+
2241
+ # 데이터를 끄고 켜기
2242
+ puts 'adb -s ' + device_id + ' shell svc data disable'
2243
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
2244
+
2245
+ if status2.success?
2246
+ sleep(3)
2247
+ puts 'adb -s ' + device_id + ' shell svc data enable'
2248
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
2249
+ sleep(3)
2250
+ puts 'adb ok'
2251
+ sleep(8)
2252
+
2253
+ # IP 확인 재시도 (반복문 사용)
2254
+ retry_count = 0
2255
+ max_retries = 5
2256
+ current_ip = nil
2257
+
2258
+ # 무한 루프 방지
2259
+ while retry_count < max_retries
2260
+ begin
2261
+ http = HTTP.get('https://www.findip.kr/')
2262
+ noko = Nokogiri::HTML(http.to_s)
2263
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
2264
+
2265
+ puts "Current IP: #{@my_ip}, New IP: #{new_ip}"
2266
+
2267
+ # IP가 변경되었으면 @my_ip를 갱신하고 종료
2268
+ if new_ip != @my_ip
2269
+ @my_ip = new_ip
2270
+ puts "IP 변경됨: #{@my_ip}"
2271
+ break
2272
+ else
2273
+ puts 'IP가 변경되지 않음. 재시도...'
2274
+ retry_count += 1
2275
+ sleep(3) # 3초 후 재시도
2276
+ end
2277
+ rescue => e
2232
2278
  retry_count += 1
2233
2279
  sleep(3) # 3초 후 재시도
2234
2280
  end
2235
- rescue => e
2236
- retry_count += 1
2237
- sleep(3) # 3초 재시도
2238
- end
2239
-
2240
- # 최대 재시도 횟수를 초과하면 예외 발생시키기
2241
- if retry_count >= max_retries
2242
- raise "최대 재시도 횟수 초과. IP 변경 실패."
2281
+
2282
+ # 최대 재시도 횟수를 초과하면 예외 발생시키기
2283
+ if retry_count >= max_retries
2284
+ raise "최대 재시도 횟수 초과. IP 변경 실패."
2285
+ end
2243
2286
  end
2287
+ else
2288
+ puts 'Failed to disable data. Error: ' + stderr2
2244
2289
  end
2245
2290
  else
2246
- puts 'Failed to disable data. Error: ' + stderr2
2291
+ puts 'adb error, unable to get devices. Error: ' + stderr
2247
2292
  end
2248
- else
2249
- puts 'adb error, unable to get devices. Error: ' + stderr
2250
2293
  end
2251
- end
2252
2294
 
2253
2295
 
2254
2296
  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.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