tg_send_zon 0.0.39 → 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/tg_send_zon.rb +102 -9
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e82c97408ddf66571c8069fd99a67a50710b35bfbc7a6d216b9737201e9ad5b
4
- data.tar.gz: 8a81cb8d346cb24ca70c7380d082df751ce6c822437700334a05620fdcc02cf2
3
+ metadata.gz: 0fb260504003fb978164db7b87ca321452ec83d7b1667df560d54b82f5b23be3
4
+ data.tar.gz: 1f5840ad4299b3269d39b07dcfe2debd434a6b83a677373cbbd70e6e7f9ff386
5
5
  SHA512:
6
- metadata.gz: 598daa5be300f09af2eb89da3188c04f9afe67c81294a8904fd8d5439ac485e1283c9f028c71e7acde1ad7d1dd3f952cea72e28642dfd5b14057c2828b018b23
7
- data.tar.gz: 887ef9ff52c661eaba5bc668ec602a715d1a081f22e61470ea727cd8320de2afca762eae0f70367609cb786f55dddb667257f15f24b9d0fb9ac408a69f83f04d
6
+ metadata.gz: d575913a6a8b2939fdb628d023847d7f989a67537fbefb67cc51bc620dc8047e97e2830b0d3f6961f33e6844c895a68ebb65999892b9257817597f180e394e5a
7
+ data.tar.gz: 4ef48e783c5afff96598e2f11abee15a18e928a9de8c43f889aa9fce9571efbc420b6c47fcaa44b9efc7e2babae9224a80f366ba8ed8266e938663bb95e51b6b
data/lib/tg_send_zon.rb CHANGED
@@ -8,6 +8,7 @@ require 'clipboard'
8
8
  require 'crack'
9
9
  require 'auto_click'
10
10
  require 'rainbow/refinement'
11
+ require 'win32ole'
11
12
  include AutoClickMethods
12
13
  using Rainbow
13
14
  include Glimmer
@@ -17,7 +18,38 @@ class Naver
17
18
 
18
19
  def initialize
19
20
  @seed = 1
21
+ kill_selenium_chrome #기존 창 모두 닫는 명령
22
+ sleep(1)
20
23
  end
24
+
25
+ def kill_selenium_chrome #기존 창 모두 닫는 코드
26
+ wmi = WIN32OLE.connect("winmgmts://")
27
+ chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
28
+
29
+ chrome_procs.each do |proc|
30
+ cmd = proc.CommandLine
31
+ if cmd && cmd.include?("user-data-dir=C:/telegram_cookie")
32
+ puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
33
+ begin
34
+ proc.Terminate
35
+ rescue
36
+ #puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
37
+ end
38
+ end
39
+ end
40
+
41
+ # chromedriver도 같이 종료
42
+ chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
43
+ chromedrivers.each do |proc|
44
+ puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
45
+ begin
46
+ proc.Terminate
47
+ rescue
48
+ #puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
49
+ end
50
+ end
51
+ end
52
+
21
53
  def chrome_setup(telegram_number,proxy)
22
54
  telegram_cookie_dir = "C:/telegram_cookie"
23
55
  FileUtils.mkdir_p(telegram_cookie_dir) unless File.exist?(telegram_cookie_dir)
@@ -33,9 +65,21 @@ class Naver
33
65
  FileUtils.mkdir_p(telegram_cookie_dir) unless File.exist?(telegram_cookie_dir)
34
66
  if proxy == ''
35
67
  begin
36
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
68
+ begin
69
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
70
+ rescue => e
71
+ puts "chromedriver 버전 불일치!!"
72
+ puts "아래 지침을 따라주세요."
73
+ puts "1.프로그램 종료!"
74
+ puts "2.크롬 업데이트!"
75
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
76
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
77
+ puts "5.재 시작"
78
+
79
+ end
37
80
  options = Selenium::WebDriver::Chrome::Options.new
38
-
81
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
82
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
39
83
  options.add_argument('--headless') # 브라우저 UI 없이 실행
40
84
  options.add_argument('--disable-gpu') # GPU 가속을 비활성화 (헤드리스에서 필요할 수 있음)
41
85
  options.add_argument('--no-sandbox')
@@ -49,7 +93,14 @@ class Naver
49
93
  options.add_argument('user-data-dir=C:/telegram_cookie/' + telegram_number)
50
94
 
51
95
 
52
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
96
+ # 'capabilities'과 'options' 배열로 설정
97
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
98
+ capabilities["goog:chromeOptions"] = options.as_json
99
+
100
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
101
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
102
+
103
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
53
104
 
54
105
 
55
106
 
@@ -71,12 +122,25 @@ class Naver
71
122
  @driver.switch_to.window(first_window)
72
123
 
73
124
  rescue
74
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
125
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
75
126
  end
76
127
  else
77
128
  begin
78
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
129
+ begin
130
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
131
+ rescue => e
132
+ puts "chromedriver 버전 불일치!!"
133
+ puts "아래 지침을 따라주세요."
134
+ puts "1.프로그램 종료!"
135
+ puts "2.크롬 업데이트!"
136
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
137
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
138
+ puts "5.재 시작"
139
+
140
+ end
79
141
  options = Selenium::WebDriver::Chrome::Options.new
142
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
143
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
80
144
  options.add_argument('--headless') # 브라우저 UI 없이 실행
81
145
  options.add_argument('--disable-gpu') # GPU 가속을 비활성화 (헤드리스에서 필요할 수 있음)
82
146
  options.add_argument('--no-sandbox')
@@ -88,26 +152,55 @@ class Naver
88
152
  options.add_argument('--disable-notifications')
89
153
  options.add_argument('--remote-debugging-port=9222')
90
154
  options.add_argument('user-data-dir=C:/telegram_cookie/' + telegram_number)
91
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
155
+ # 'capabilities'과 'options' 배열로 설정
156
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
157
+ capabilities["goog:chromeOptions"] = options.as_json
158
+
159
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
160
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
161
+
162
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
163
+
92
164
  rescue => e
93
165
  puts e
94
166
  puts 'proxy error...'
95
167
  begin
96
- Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
168
+ begin
169
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
170
+ rescue => e
171
+ puts "chromedriver 버전 불일치!!"
172
+ puts "아래 지침을 따라주세요."
173
+ puts "1.프로그램 종료!"
174
+ puts "2.크롬 업데이트!"
175
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
176
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
177
+ puts "5.재 시작"
178
+
179
+ end
97
180
  options = Selenium::WebDriver::Chrome::Options.new
98
181
  options.page_load_strategy = :normal
99
182
  options.timeouts = {page_load: 20_000}
100
183
  options.page_load_strategy = 'none'
101
184
  options.add_argument('--disable-notifications')
185
+ options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
186
+ options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
102
187
  options.add_argument('--headless') # 브라우저 UI 없이 실행
103
188
  options.add_argument('--disable-gpu') # GPU 가속을 비활성화 (헤드리스에서 필요할 수 있음)
104
189
  options.add_argument('--no-sandbox')
105
190
  options.add_argument('--disable-popup-blocking')
106
191
  options.add_argument('--remote-debugging-port=9222')
107
192
  options.add_argument('user-data-dir=C:/telegram_cookie/' + telegram_number)
108
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
193
+ # 'capabilities'과 'options' 배열로 설정
194
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome
195
+ capabilities["goog:chromeOptions"] = options.as_json
196
+
197
+ # Selenium 4에서는 'capabilities'만 사용하는 방식
198
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
199
+
200
+ @driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: function(){ return false; }});") # 셀레니움 감지 방지
201
+
109
202
  rescue
110
- @driver = Selenium::WebDriver.for(:chrome, capabilities: options)
203
+ @driver = Selenium::WebDriver.for(:chrome, capabilities: [capabilities, options])
111
204
  end
112
205
  end
113
206
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tg_send_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-24 00:00:00.000000000 Z
10
+ date: 2025-05-29 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: File to Clipboard gem
14
13
  email: mymin26@naver.com
@@ -21,7 +20,6 @@ homepage: ''
21
20
  licenses:
22
21
  - zon
23
22
  metadata: {}
24
- post_install_message:
25
23
  rdoc_options: []
26
24
  require_paths:
27
25
  - lib
@@ -36,8 +34,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
38
36
  requirements: []
39
- rubygems_version: 3.3.7
40
- signing_key:
37
+ rubygems_version: 3.6.7
41
38
  specification_version: 4
42
39
  summary: file to clipboard
43
40
  test_files: []