screenshotone-api-sdk 1.0.31 → 1.0.33

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.
@@ -459,6 +459,10 @@ export declare class AnimateOptions {
459
459
  * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
460
460
  */
461
461
  blockResources(...blockResources: string[]): AnimateOptions;
462
+ /**
463
+ * Blocks banners by heuristics.
464
+ */
465
+ blockBannersByHeuristics(block: boolean): AnimateOptions;
462
466
  /**
463
467
  * Enables caching.
464
468
  */
package/dist/main.js CHANGED
@@ -192,7 +192,12 @@ class TakeOptions {
192
192
  }
193
193
  put(key, ...values) {
194
194
  for (const value of values) {
195
- this.query.append(key, value);
195
+ if (values.length == 1) {
196
+ this.query.set(key, value);
197
+ }
198
+ else {
199
+ this.query.append(key, value);
200
+ }
196
201
  }
197
202
  }
198
203
  ;
@@ -836,6 +841,13 @@ class AnimateOptions {
836
841
  this.put("block_resources", ...blockResources);
837
842
  return this;
838
843
  }
844
+ /**
845
+ * Blocks banners by heuristics.
846
+ */
847
+ blockBannersByHeuristics(block) {
848
+ this.put("block_banners_by_heuristics", block ? "true" : "false");
849
+ return this;
850
+ }
839
851
  /**
840
852
  * Enables caching.
841
853
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "screenshotone-api-sdk",
3
3
  "homepage": "https://screenshotone.com",
4
- "version": "1.0.31",
4
+ "version": "1.0.33",
5
5
  "description": "Use ScreenshotOne.com API to generate screenshots of any website.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -42,6 +42,7 @@
42
42
  "cross-fetch": "^3.1.5"
43
43
  },
44
44
  "scripts": {
45
+ "test": "jest",
45
46
  "build": "tsc",
46
47
  "prepare": "npm run build"
47
48
  }
package/src/main.ts CHANGED
@@ -205,10 +205,15 @@ export class TakeOptions {
205
205
 
206
206
  private put(key: string, ...values: string[]) {
207
207
  for (const value of values) {
208
- this.query.append(key, value);
208
+ if (values.length == 1) {
209
+ this.query.set(key, value);
210
+ } else {
211
+ this.query.append(key, value);
212
+ }
209
213
  }
210
214
  };
211
215
 
216
+
212
217
  /**
213
218
  * Selector is a CSS-like selector of the element to take a screenshot of.
214
219
  */
@@ -1012,6 +1017,15 @@ export class AnimateOptions {
1012
1017
  return this;
1013
1018
  }
1014
1019
 
1020
+ /**
1021
+ * Blocks banners by heuristics.
1022
+ */
1023
+ blockBannersByHeuristics(block: boolean): AnimateOptions {
1024
+ this.put("block_banners_by_heuristics", block ? "true" : "false");
1025
+
1026
+ return this;
1027
+ }
1028
+
1015
1029
  /**
1016
1030
  * Enables caching.
1017
1031
  */
@@ -1,4 +1,4 @@
1
- import { TakeOptions, Client } from '../src/main';
1
+ import { TakeOptions, Client, AnimateOptions } from '../src/main';
2
2
 
3
3
  describe('testing client', () => {
4
4
  const client = new Client('RcLsdM6uhIN6gw', 'MW2vfkkgLTzGGw');
@@ -17,5 +17,18 @@ describe('testing client', () => {
17
17
  .userAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36');
18
18
 
19
19
  expect(client.generateTakeURL(options)).toBe('https://api.screenshotone.com/take?url=https%3A%2F%2Fexample.com&block_ads=true&full_page=true&user_agent=Mozilla%2F5.0+%28X11%3B+Linux+x86_64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F51.0.2704.103+Safari%2F537.36&access_key=RcLsdM6uhIN6gw&signature=ea217db7d746c8bf9b710257d62ef09670b003137d239ee4c81eae3645b4a901');
20
- });
20
+ });
21
+
22
+ test('setting an option twice doesn`t convert it to an array parameter (TakeOptions)', () => {
23
+ const options = TakeOptions.url("https://example.com").blockAds(true).blockAds(true);
24
+
25
+ expect(options.toQuery().getAll("block_ads").length).toBe(1);
26
+ });
27
+
28
+ test('setting an option twice doesn`t convert it to an array parameter (AnimateOptions)', () => {
29
+ const options = AnimateOptions.url("https://example.com").blockAds(true).blockAds(true);
30
+
31
+ expect(options.toQuery().getAll("block_ads").length).toBe(1);
32
+ });
33
+
21
34
  });