tblog_duopack 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/tblog_duopack.rb +231 -44
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb08b4c28392011498f8a6683f49c393d6a5fe70d83839f5185719143c1954d1
4
- data.tar.gz: ab184f85d87dbea4323e2c4c8a2ac558ddd6d3dce2cf22fd476e737c276a43cc
3
+ metadata.gz: 5e2bfd10d034977a468d952d911ad19959c7f20de9d25f93cece0693ff7b9e68
4
+ data.tar.gz: a736c3c9ea1bc59d2d3bbe389bb85b661a915c5c1a7d4cf5bdeeb3832766ae83
5
5
  SHA512:
6
- metadata.gz: 86af3d2f53bb272ae1be71a518aa8df37b62fd9ba9b344c1f308d3b64aa5fe0257e09cc7cf1836e5d95e03edf7ad79830467c65b2c0495a46814cb6378e09397
7
- data.tar.gz: 3469d71fd2b555ec39f895870e3c68c1f245c274058e86b957a9845b7a91cdf702b2db96cf1133c81ccd09f34eb58102b4a0a792521e828fc123ffe76dda25f2
6
+ metadata.gz: f8513736ced216ea88171f0fd0c5415922dd9bbd0f1bb90d0cd51e53d199c36e5e19f69a5b488e9ee69853c584c8796accfa2f13db1991987e51acf0070364fb
7
+ data.tar.gz: b6be12682ea565e3dbdbf7754f9525060ebb828f6078f21673c43917fa2eab88c9f15540557b398c0fc80467e5ea27e8be19c4bd4e3dd70122e4f1cba0d9c254
data/lib/tblog_duopack.rb CHANGED
@@ -16,6 +16,7 @@ require 'cgi'
16
16
  require 'auto_click'
17
17
  require 'rainbow/refinement'
18
18
  require 'httpclient'
19
+ require 'win32ole'
19
20
  include AutoClickMethods
20
21
  using Rainbow
21
22
  include Glimmer
@@ -242,9 +243,50 @@ end
242
243
 
243
244
  class Naver
244
245
  def initialize
245
- @seed = 1
246
- @cookie = ''
246
+ @seed = 1
247
+ @cookie = ''
248
+ #kill_selenium_chrome #기존 창 모두 닫는 명령
249
+ #sleep(1)
247
250
  end
251
+
252
+ #def kill_selenium_chrome
253
+ # wmi = WIN32OLE.connect("winmgmts://")
254
+
255
+ # # chromedriver 프로세스 목록을 Ruby 배열로 변환
256
+ # chromedrivers_ole = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
257
+ # chromedrivers = []
258
+ # chromedrivers_ole.each { |proc| chromedrivers << proc }
259
+ # chromedriver_pids = chromedrivers.map { |proc| proc.ProcessId }
260
+
261
+ # chrome.exe 프로세스 목록을 Ruby 배열로 변환
262
+ # chrome_procs_ole = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
263
+ # chrome_procs = []
264
+ # chrome_procs_ole.each { |proc| chrome_procs << proc }
265
+
266
+ # chromedriver가 띄운 크롬 종료
267
+ # chrome_procs.each do |proc|
268
+ # if chromedriver_pids.include?(proc.ParentProcessId)
269
+ # puts "→ chromedriver가 띄운 크롬 종료: PID #{proc.ProcessId}"
270
+ # begin
271
+ # proc.Terminate
272
+ # rescue => e
273
+ # puts "→ 종료 실패: PID #{proc.ProcessId} / 오류: #{e.message}"
274
+ # end
275
+ # end
276
+ # end
277
+
278
+ # chromedriver 자체도 종료
279
+ # chromedrivers.each do |proc|
280
+ # puts "→ chromedriver 종료: PID #{proc.ProcessId}"
281
+ # begin
282
+ # proc.Terminate
283
+ # rescue => e
284
+ # puts "→ chromedriver 종료 실패: #{proc.ProcessId} / 오류: #{e.message}"
285
+ # end
286
+ # end
287
+ #end
288
+
289
+
248
290
 
249
291
  def chrome_start(proxy)
250
292
  # 공통 옵션 설정
@@ -262,7 +304,6 @@ class Naver
262
304
  end
263
305
  options = Selenium::WebDriver::Chrome::Options.new
264
306
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
265
- options.add_extension('./crx/app.crx') # 확장 프로그램을 첫 번째 탭에 추가
266
307
  options.add_argument('--disable-blink-features=AutomationControlled')
267
308
  options.add_argument('--disable-popup-blocking')
268
309
  options.add_argument('--dns-prefetch-disable')
@@ -371,25 +412,103 @@ class Naver
371
412
  @driver.switch_to.new_window(:tab)
372
413
  sleep(1.5)
373
414
  @driver.switch_to.window(@driver.window_handles[1])
374
- @driver.navigate.to("chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html")
415
+ @driver.navigate.to("https://chromewebstore.google.com/detail/captcha-solver-auto-recog/ifibfemgeogfhoebkmokieepdoobkbpo?hl=ko")
375
416
  sleep(3)
376
- @driver.find_element(:xpath, '//*[@name="apiKey"]').click
377
- Clipboard.copy(captcha_api_key)
378
- sleep(0.5)
379
- @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
380
- sleep(0.5)
381
- @driver.find_element(:xpath, '//*[@data-lang="login"]').click
382
-
383
417
  begin
384
- sleep(2)
385
- @driver.switch_to.alert.dismiss
386
- sleep(1)
418
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
419
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="ajZLRd"]') } #추가 되어 있음
420
+ captcha_solver = 0
421
+ puts'[Step.01] CAPTCHA 세션 및 브라우저 설정 완료 상태 확인!!.......'.yellow
387
422
  rescue
388
- end
389
- @driver.close
390
- sleep(1)
391
- @driver.switch_to.window(@driver.window_handles[0])
392
- sleep(2)
423
+ begin
424
+ wait = Selenium::WebDriver::Wait.new(:timeout => 3)
425
+ wait.until { @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]') } #추가 안되어 있음
426
+ sleep(1.5)
427
+ @driver.find_element(xpath: '//section[@class="lwrbTd"]//button[@jsname="wQO0od"]').click
428
+ puts'[Step.01] CAPTCHA 세션 연결 없음!! 브라우저 필요 설정 미 완료 상태!!.......'.red
429
+ puts'[Step.02] CAPTCHA 세션 연결 및 브라우저 필요 설정 진행 시작!!.......'.red
430
+ sleep(1.5)
431
+ shell = WIN32OLE.new('WScript.Shell')
432
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
433
+ shell.AppActivate("Captcha Solver: Auto Recognition and Bypass")
434
+ sleep(1)
435
+ shell.SendKeys("{TAB}")
436
+ sleep(0.5)
437
+ shell.SendKeys("{ENTER}")
438
+
439
+ captcha_solver = 1
440
+ sleep(1)
441
+ rescue
442
+ @driver.quit
443
+ sleep(1)
444
+ @driver.close
445
+ return 0
446
+ sleep(1)
447
+ end
448
+ end
449
+ if captcha_solver == 1
450
+ begin
451
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
452
+ sleep(5)
453
+ @driver.get('chrome-extension://ifibfemgeogfhoebkmokieepdoobkbpo/options/options.html')
454
+ sleep(1)
455
+ # 요소 찾기 타임아웃을 10초로 설정
456
+ wait = Selenium::WebDriver::Wait.new(:timeout => 5)
457
+ #요소가 나타날 때까지 60초 동안 기다립니다.
458
+ wait.until { @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input') }
459
+ @driver.find_element(:xpath, '/html/body/div/div[1]/table/tbody/tr[1]/td[2]/input').click
460
+ sleep(1)
461
+ Clipboard.copy(captcha_api_key)
462
+ @driver.action.key_down(:control).send_keys('v').key_up(:control).perform
463
+ sleep(1)
464
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
465
+ sleep(1)
466
+
467
+ begin
468
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
469
+ wait.until do
470
+ begin
471
+ alert = @driver.switch_to.alert
472
+ alert.accept
473
+ sleep(1)
474
+ true
475
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
476
+ false
477
+ end
478
+ end
479
+ sleep(1)
480
+ @driver.close
481
+ sleep(1)
482
+ @driver.switch_to.window(@driver.window_handles[0])
483
+ sleep(2)
484
+ rescue Selenium::WebDriver::Error::TimeoutError
485
+ @driver.find_element(:xpath, '//*[@id="connect"]').click
486
+ begin
487
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
488
+ wait.until do
489
+ begin
490
+ alert = @driver.switch_to.alert
491
+ alert.accept
492
+ sleep(1)
493
+ true
494
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
495
+ false
496
+ end
497
+ end
498
+ rescue Selenium::WebDriver::Error::TimeoutError
499
+ puts "캡챠 기능이 완벽하게 세팅되지않아 캡챠 발생시 해제가 안될수있습니다.".red
500
+ puts "가급적 캡챠 기능 세팅시 PC 사용을 멈춰주세요!".red
501
+ sleep(1)
502
+ @driver.close
503
+ sleep(1)
504
+ @driver.switch_to.window(@driver.window_handles[0])
505
+ sleep(2)
506
+ end
507
+ end
508
+ rescue
509
+ end
510
+ else
511
+ end
393
512
  else
394
513
  end
395
514
 
@@ -1772,40 +1891,84 @@ class Wordpress
1772
1891
  img.write('./image/memory.png')
1773
1892
  end
1774
1893
 
1894
+ def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
1895
+ size = initial_size
1896
+ draw.font = font_path
1897
+
1898
+ loop do
1899
+ draw.pointsize = size
1900
+ words = text.chars # 글자 단위로 자름 (한국어 기준)
1901
+ lines = []
1902
+ line = ""
1903
+
1904
+ words.each do |char|
1905
+ test_line = line + char
1906
+ metrics = draw.get_type_metrics(test_line)
1907
+ if metrics.width > max_width
1908
+ lines << line
1909
+ line = char
1910
+ else
1911
+ line = test_line
1912
+ end
1913
+ end
1914
+ lines << line unless line.empty?
1915
+
1916
+ line_height = draw.get_type_metrics("가").height
1917
+ total_height = line_height * lines.size
1918
+
1919
+ # 세로 초과 안 하면 성공
1920
+ if total_height <= max_height || size <= 10
1921
+ return [lines.join("\n"), size]
1922
+ else
1923
+ size -= 2
1924
+ end
1925
+ end
1926
+ end
1927
+
1928
+
1775
1929
  def image_text(text1, text2)
1776
1930
  begin
1777
1931
  color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
1778
- font = Dir.entries('./fonts')
1779
- img = Magick::Image.read('./image/memory.png').first
1780
- text = Magick::Draw.new
1932
+ font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
1933
+ font2 = './fonts/' + font_files.sample
1781
1934
  color2 = color.sample
1782
- font2 = './fonts/'+font.sample
1783
- message = text1.to_s+"\n"+text2.to_s
1935
+
1936
+ img = Magick::Image.read('./image/memory.png').first
1937
+ draw = Magick::Draw.new
1938
+
1939
+ raw_message = "#{text1}\n#{text2}".strip
1940
+ max_width = img.columns * 0.85
1941
+ max_height = img.rows * 0.6
1942
+
1784
1943
  begin
1785
1944
  size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
1786
1945
  rescue
1787
1946
  size = 30
1788
1947
  end
1948
+
1949
+ wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
1950
+
1789
1951
  if @data['이미지설정']['글자그림자'].checked?
1790
- img.annotate(text, 0,0, +3,+3, message) do
1791
- text.gravity = Magick::CenterGravity
1792
- text.pointsize = size
1793
- text.fill = '#000000'
1794
- text.font = font2
1952
+ img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
1953
+ draw.gravity = Magick::CenterGravity
1954
+ draw.pointsize = adjusted_size
1955
+ draw.fill = '#000000'
1956
+ draw.font = font2
1795
1957
  end
1796
1958
  end
1797
-
1798
- img.annotate(text, 0,0,0,0, message) do
1799
- text.gravity = Magick::CenterGravity
1800
- text.pointsize = size
1959
+
1960
+ draw2 = Magick::Draw.new
1961
+ img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
1962
+ draw2.gravity = Magick::CenterGravity
1963
+ draw2.pointsize = adjusted_size
1964
+ draw2.fill = color2
1965
+ draw2.font = font2
1801
1966
  if @data['이미지설정']['글자테두리'].checked?
1802
- text.stroke_width = 2
1803
- text.stroke = '#000000'
1967
+ draw2.stroke_width = 2
1968
+ draw2.stroke = '#000000'
1804
1969
  end
1805
- text.fill = color2
1806
- text.font = font2
1807
1970
  end
1808
-
1971
+
1809
1972
  img.write('./image/memory.png')
1810
1973
  rescue
1811
1974
  puts '이미지 폰트 불러오기 오류 재시도...'
@@ -1867,18 +2030,40 @@ class Wordpress
1867
2030
  image_filter()
1868
2031
  end
1869
2032
 
1870
- insert_image_text1 = ''
1871
- insert_image_text2 = ''
1872
2033
  if @data['이미지설정']['글자삽입1'].checked?
1873
- insert_image_text1 = @data['이미지설정']['이미지글자1'].sample
2034
+ if @data['이미지설정']['이미지글자1'].length == 0
2035
+ image_text_path1 = ''
2036
+ else
2037
+ if @data['이미지설정']['글자랜덤'].checked?
2038
+ image_text_path1 = @data['이미지설정']['이미지글자1'].sample
2039
+ else
2040
+ image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
2041
+ @image_text_soon1 += 1
2042
+ if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
2043
+ @image_text_soon1 = 0
2044
+ end
2045
+ end
2046
+ end
1874
2047
  end
1875
2048
 
1876
2049
  if @data['이미지설정']['글자삽입2'].checked?
1877
- insert_image_text2 = @data['이미지설정']['이미지글자2'].sample
2050
+ if @data['이미지설정']['이미지글자2'].length == 0
2051
+ image_text_path2 = ''
2052
+ else
2053
+ if @data['이미지설정']['글자랜덤'].checked?
2054
+ image_text_path2 = @data['이미지설정']['이미지글자2'].sample
2055
+ else
2056
+ image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
2057
+ @image_text_soon2 += 1
2058
+ if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
2059
+ @image_text_soon2 = 0
2060
+ end
2061
+ end
2062
+ end
1878
2063
  end
1879
-
2064
+
1880
2065
  if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
1881
- image_text(insert_image_text1, insert_image_text2)
2066
+ image_text(image_text_path1, image_text_path2)
1882
2067
  end
1883
2068
 
1884
2069
  if @data['이미지설정']['테두리사용'].checked?
@@ -1942,6 +2127,8 @@ class Wordpress
1942
2127
  title_soon = 0
1943
2128
  keyword_soon = 0
1944
2129
  content_soon = 0
2130
+ @image_text_soon1 = 0
2131
+ @image_text_soon2 = 0
1945
2132
  @my_ip = 'init'
1946
2133
  @image_counter = 0
1947
2134
  @inumber2 = 0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tblog_duopack
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
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-23 00:00:00.000000000 Z
10
+ date: 2025-05-30 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com