mass-client 1.0.15 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/first-line/profile_rpa.rb +29 -2
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53ba01f6dc72c15098bf26fa1ddd656acf3c81b259d53f0d544664fef62d6f94
4
- data.tar.gz: b446332f82fc89b30a93c6f682c5562d1ba2e175e407aad431ae09a03d98a6f5
3
+ metadata.gz: 15fc20e0e46b85a66c45cbabbf3862fd1db6bff5fc254ec8b94414a0c5f086da
4
+ data.tar.gz: 6cd0e9274b472a4e64a07d3f9f0d846b5499b2bbb3384e3e45a322d3a1210202
5
5
  SHA512:
6
- metadata.gz: 88acec54a80b2eaf25e443a160473f0e325df2335866097d7626cf829f9bc69f881e2dcaa81cf7d69b8fc53d4a8af0e95b386b900d4425af3504297e277c5ef6
7
- data.tar.gz: 5b3bd557a39e38ef55cce0a5118c1cda8c8ee6a0e7cbdf4765ce798670c3d424ced8f5f676b21b8dc61a713597ea18c0acd4ab076a5626f8bae0582baf470a99
6
+ metadata.gz: 663c292587112ca68d8a29643d7348d4510cf7028d1564d7f24c9259c518e1e25de0dfffc8bfef889f90f2f8e7a9d4625e80e4d95e8344ce81db83387c84cb66
7
+ data.tar.gz: 176098ed2b937fc66af21da5e0d2d585a1960c209ab0eaa2be6579aa2a05fe866f532b36011c2bcb01043e51af202e1026235e870116f519191ecc04cd954e9b
@@ -192,9 +192,10 @@ module Mass
192
192
  tmp_paths = Mass.download_path.map { |s| "#{s}/#{filename}" } if Mass.download_path.is_a?(Array)
193
193
 
194
194
  # excute JavaScript function downloadImage with the parameter src
195
-
195
+ #binding.pry
196
196
  # this function is to download images from the same browser, using the proxy of the browser.
197
197
  # never download images from the server, because sites can track the IP.
198
+ =begin
198
199
  js0 = "
199
200
  async function downloadImage(imageSrc, filename) {
200
201
  const image = await fetch(imageSrc)
@@ -210,9 +211,35 @@ module Mass
210
211
  }
211
212
  downloadImage('#{url}', '#{filename}')
212
213
  "
214
+ =end
215
+ # Promise Handling: By returning a Promise in the JavaScript code, Selenium will wait for the asynchronous operation to complete.
216
+ # Reference: https://github.com/MassProspecting/docs/issues/253
217
+ js0 = "
218
+ function downloadImage(imageSrc, filename) {
219
+ return new Promise(async (resolve, reject) => {
220
+ try {
221
+ const image = await fetch(imageSrc);
222
+ const imageBlob = await image.blob();
223
+ const imageURL = URL.createObjectURL(imageBlob);
224
+
225
+ const link = document.createElement('a');
226
+ link.href = imageURL;
227
+ link.download = filename;
228
+ document.body.appendChild(link);
229
+ link.click();
230
+ document.body.removeChild(link);
231
+
232
+ resolve('Download initiated');
233
+ } catch (error) {
234
+ reject(error);
235
+ }
236
+ });
237
+ }
238
+ return downloadImage('#{url}', '#{filename}');
239
+ "
213
240
  #binding.pry
214
241
  driver.execute_script(js0)
215
-
242
+ sleep(10)
216
243
  # code
217
244
  year = Time.now.year.to_s.rjust(4,'0')
218
245
  month = Time.now.month.to_s.rjust(2,'0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mass-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-06 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.1.2
153
- description: Ruby library for Mass API.
153
+ description: Ruby library for MassProspecting API.
154
154
  email: leandro@massprospecting.com
155
155
  executables: []
156
156
  extensions: []
@@ -206,5 +206,5 @@ requirements: []
206
206
  rubygems_version: 3.3.7
207
207
  signing_key:
208
208
  specification_version: 4
209
- summary: Ruby library for Mass API.
209
+ summary: Ruby library for MassProspecting API.
210
210
  test_files: []