screenshotone-api-sdk 1.0.14 → 1.0.15

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.
package/dist/main.js CHANGED
@@ -1,315 +1,262 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
36
7
  }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
37
24
  };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
27
  };
47
28
  Object.defineProperty(exports, "__esModule", { value: true });
48
29
  exports.TakeOptions = exports.Client = void 0;
49
- var crypto = require("crypto");
50
- var big_js_1 = require("big.js");
51
- var cross_fetch_1 = require("cross-fetch");
30
+ const crypto = __importStar(require("crypto"));
31
+ const big_js_1 = __importDefault(require("big.js"));
32
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
52
33
  /**
53
34
  * Represents an API client for the screenshotone.com API.
54
35
  */
55
- var Client = /** @class */ (function () {
56
- function Client(accessKey, secretKey) {
36
+ class Client {
37
+ constructor(accessKey, secretKey) {
57
38
  this.API_BASE_URL = "https://api.screenshotone.com";
58
39
  this.API_TAKE_PATH = "/take";
59
40
  this.accessKey = accessKey;
60
41
  this.secretKey = secretKey;
61
42
  }
62
- Client.prototype.generateTakeURL = function (options) {
63
- var query = options.toQuery();
43
+ generateTakeURL(options) {
44
+ const query = options.toQuery();
64
45
  query.append("access_key", this.accessKey);
65
- var queryString = query.toString();
66
- var signature = crypto.createHmac("sha256", this.secretKey)
46
+ let queryString = query.toString();
47
+ const signature = crypto.createHmac("sha256", this.secretKey)
67
48
  .update(queryString, 'utf-8')
68
49
  .digest('hex');
69
50
  queryString += '&signature=' + signature;
70
- return "".concat(this.API_BASE_URL).concat(this.API_TAKE_PATH, "?").concat(queryString);
71
- };
72
- Client.prototype.take = function (options) {
73
- return __awaiter(this, void 0, void 0, function () {
74
- var url, response;
75
- return __generator(this, function (_a) {
76
- switch (_a.label) {
77
- case 0:
78
- url = this.generateTakeURL(options);
79
- return [4 /*yield*/, (0, cross_fetch_1.default)(url)];
80
- case 1:
81
- response = _a.sent();
82
- if (!response.ok) return [3 /*break*/, 3];
83
- return [4 /*yield*/, response.blob()];
84
- case 2: return [2 /*return*/, _a.sent()];
85
- case 3: throw new Error("failed to take screenshot, response returned ".concat(response.status, " ").concat(response.statusText));
86
- }
87
- });
88
- });
89
- };
90
- return Client;
91
- }());
51
+ return `${this.API_BASE_URL}${this.API_TAKE_PATH}?${queryString}`;
52
+ }
53
+ async take(options) {
54
+ const url = this.generateTakeURL(options);
55
+ const response = await (0, cross_fetch_1.default)(url);
56
+ if (response.ok) {
57
+ return await response.blob();
58
+ }
59
+ throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}`);
60
+ }
61
+ }
92
62
  exports.Client = Client;
93
63
  /**
94
64
  * Represents options for taking screenshots.
95
65
  */
96
- var TakeOptions = /** @class */ (function () {
97
- function TakeOptions(url) {
98
- var query = new URLSearchParams();
66
+ class TakeOptions {
67
+ constructor(url) {
68
+ const query = new URLSearchParams();
99
69
  query.append("url", url);
100
70
  this.query = query;
101
71
  }
102
72
  /**
103
73
  * Initializes take screenshot options with provided website URL.
104
74
  */
105
- TakeOptions.url = function (url) {
75
+ static url(url) {
106
76
  return new TakeOptions(url);
107
- };
108
- TakeOptions.prototype.put = function (key) {
109
- var values = [];
110
- for (var _i = 1; _i < arguments.length; _i++) {
111
- values[_i - 1] = arguments[_i];
112
- }
113
- for (var _a = 0, values_1 = values; _a < values_1.length; _a++) {
114
- var value = values_1[_a];
77
+ }
78
+ put(key, ...values) {
79
+ for (const value of values) {
115
80
  this.query.append(key, value);
116
81
  }
117
- };
82
+ }
118
83
  ;
119
84
  /**
120
85
  * Renders the full page.
121
86
  */
122
- TakeOptions.prototype.fullPage = function (fullPage) {
87
+ fullPage(fullPage) {
123
88
  this.put("full_page", fullPage ? "true" : "false");
124
89
  return this;
125
- };
90
+ }
126
91
  /**
127
92
  * Sets response format, one of: "png", "jpeg", "webp" or "jpg".
128
93
  */
129
- TakeOptions.prototype.format = function (format) {
94
+ format(format) {
130
95
  this.put("format", format);
131
96
  return this;
132
- };
97
+ }
133
98
  /**
134
99
  * Renders image with the specified quality. Available for the next formats: "jpeg" ("jpg"), "webp".
135
100
  */
136
- TakeOptions.prototype.imageQuality = function (imageQuality) {
101
+ imageQuality(imageQuality) {
137
102
  this.put("image_quality", imageQuality.toString());
138
103
  return this;
139
- };
104
+ }
140
105
  /**
141
106
  * Renders a transparent background for the image. Works only if the site has not defined background color.
142
107
  * Available for the following response formats: "png", "webp".
143
108
  */
144
- TakeOptions.prototype.omitBackground = function (omitBackground) {
109
+ omitBackground(omitBackground) {
145
110
  this.put("omit_background", omitBackground ? "true" : "false");
146
111
  return this;
147
- };
112
+ }
148
113
  /**
149
114
  * Sets the width of the browser viewport (pixels).
150
115
  */
151
- TakeOptions.prototype.viewportWidth = function (viewportWidth) {
116
+ viewportWidth(viewportWidth) {
152
117
  this.put("viewport_width", viewportWidth.toString());
153
118
  return this;
154
- };
119
+ }
155
120
  /**
156
121
  * Sets the height of the browser viewport (pixels).
157
122
  */
158
- TakeOptions.prototype.viewportHeight = function (viewportHeight) {
123
+ viewportHeight(viewportHeight) {
159
124
  this.put("viewport_height", viewportHeight.toString());
160
125
  return this;
161
- };
126
+ }
162
127
  /**
163
128
  * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
164
129
  */
165
- TakeOptions.prototype.deviceScaleFactor = function (deviceScaleFactor) {
130
+ deviceScaleFactor(deviceScaleFactor) {
166
131
  this.put("device_scale_factor", deviceScaleFactor.toString());
167
132
  return this;
168
- };
133
+ }
169
134
  /**
170
135
  * Sets geolocation latitude for the request.
171
136
  * Both latitude and longitude are required if one of them is set.
172
137
  */
173
- TakeOptions.prototype.geolocationLatitude = function (latitude) {
138
+ geolocationLatitude(latitude) {
174
139
  this.put("geolocation_latitude", new big_js_1.default(latitude).toFixed(20).replace(/0+$/, ""));
175
140
  return this;
176
- };
141
+ }
177
142
  /**
178
143
  * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
179
144
  */
180
- TakeOptions.prototype.geolocationLongitude = function (longitude) {
145
+ geolocationLongitude(longitude) {
181
146
  this.put("geolocation_longitude", new big_js_1.default(longitude).toFixed(20).replace(/0+$/, ""));
182
147
  return this;
183
- };
148
+ }
184
149
  /**
185
150
  * Sets the geolocation accuracy in meters.
186
151
  */
187
- TakeOptions.prototype.geolocationAccuracy = function (accuracy) {
152
+ geolocationAccuracy(accuracy) {
188
153
  this.put("geolocation_accuracy", accuracy.toString());
189
154
  return this;
190
- };
155
+ }
191
156
  /**
192
157
  * Blocks ads.
193
158
  */
194
- TakeOptions.prototype.blockAds = function (blockAds) {
159
+ blockAds(blockAds) {
195
160
  this.put("block_ads", blockAds ? "true" : "false");
196
161
  return this;
197
- };
162
+ }
198
163
  /**
199
164
  * Blocks trackers.
200
165
  */
201
- TakeOptions.prototype.blockTrackers = function (blockTrackers) {
166
+ blockTrackers(blockTrackers) {
202
167
  this.put("block_trackers", blockTrackers ? "true" : "false");
203
168
  return this;
204
- };
169
+ }
205
170
  /**
206
171
  * Blocks requests by specifying URL, domain, or even a simple pattern.
207
172
  */
208
- TakeOptions.prototype.blockRequests = function () {
209
- var blockRequests = [];
210
- for (var _i = 0; _i < arguments.length; _i++) {
211
- blockRequests[_i] = arguments[_i];
212
- }
213
- this.put.apply(this, __spreadArray(["block_requests"], blockRequests, false));
173
+ blockRequests(...blockRequests) {
174
+ this.put("block_requests", ...blockRequests);
214
175
  return this;
215
- };
176
+ }
216
177
  /**
217
178
  * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
218
179
  * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
219
180
  */
220
- TakeOptions.prototype.blockResources = function () {
221
- var blockResources = [];
222
- for (var _i = 0; _i < arguments.length; _i++) {
223
- blockResources[_i] = arguments[_i];
224
- }
225
- this.put.apply(this, __spreadArray(["block_resources"], blockResources, false));
181
+ blockResources(...blockResources) {
182
+ this.put("block_resources", ...blockResources);
226
183
  return this;
227
- };
184
+ }
228
185
  /**
229
186
  * Enables caching.
230
187
  */
231
- TakeOptions.prototype.cache = function (cache) {
188
+ cache(cache) {
232
189
  this.put("cache", cache ? "true" : "false");
233
190
  return this;
234
- };
191
+ }
235
192
  /**
236
193
  * Sets cache TTL.
237
194
  */
238
- TakeOptions.prototype.cacheTtl = function (cacheTTL) {
195
+ cacheTtl(cacheTTL) {
239
196
  this.put("cache_ttl", cacheTTL.toString());
240
197
  return this;
241
- };
198
+ }
242
199
  /**
243
200
  * Sets cache key.
244
201
  */
245
- TakeOptions.prototype.cacheKey = function (cacheKey) {
202
+ cacheKey(cacheKey) {
246
203
  this.put("cache_key", cacheKey);
247
204
  return this;
248
- };
205
+ }
249
206
  /**
250
207
  * Sets a user agent for the request.
251
208
  */
252
- TakeOptions.prototype.userAgent = function (userAgent) {
209
+ userAgent(userAgent) {
253
210
  this.put("user_agent", userAgent);
254
211
  return this;
255
- };
212
+ }
256
213
  /**
257
214
  * Sets an authorization header for the request.
258
215
  */
259
- TakeOptions.prototype.authorization = function (authorization) {
216
+ authorization(authorization) {
260
217
  this.put("authorization", authorization);
261
218
  return this;
262
- };
219
+ }
263
220
  /**
264
221
  * Set cookies for the request.
265
222
  */
266
- TakeOptions.prototype.cookies = function () {
267
- var cookies = [];
268
- for (var _i = 0; _i < arguments.length; _i++) {
269
- cookies[_i] = arguments[_i];
270
- }
271
- this.put.apply(this, __spreadArray(["cookies"], cookies, false));
223
+ cookies(...cookies) {
224
+ this.put("cookies", ...cookies);
272
225
  return this;
273
- };
226
+ }
274
227
  /**
275
228
  * Sets extra headers for the request.
276
229
  */
277
- TakeOptions.prototype.headers = function () {
278
- var headers = [];
279
- for (var _i = 0; _i < arguments.length; _i++) {
280
- headers[_i] = arguments[_i];
281
- }
282
- this.put.apply(this, __spreadArray(["headers"], headers, false));
230
+ headers(...headers) {
231
+ this.put("headers", ...headers);
283
232
  return this;
284
- };
233
+ }
285
234
  /**
286
235
  * TimeZone sets time zone for the request.
287
236
  * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
288
237
  * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
289
238
  * "Asia/Tashkent", "Europe/London".
290
239
  */
291
- TakeOptions.prototype.timeZone = function (timeZone) {
240
+ timeZone(timeZone) {
292
241
  this.put("time_zone", timeZone);
293
242
  return this;
294
- };
243
+ }
295
244
  /**
296
245
  * Sets delay.
297
246
  */
298
- TakeOptions.prototype.delay = function (delay) {
247
+ delay(delay) {
299
248
  this.put("delay", delay.toString());
300
249
  return this;
301
- };
250
+ }
302
251
  /**
303
252
  * Sets timeout.
304
253
  */
305
- TakeOptions.prototype.timeout = function (timeout) {
254
+ timeout(timeout) {
306
255
  this.put("timeout", timeout.toString());
307
256
  return this;
308
- };
309
- TakeOptions.prototype.toQuery = function () {
257
+ }
258
+ toQuery() {
310
259
  return new URLSearchParams(this.query.toString());
311
- };
312
- return TakeOptions;
313
- }());
260
+ }
261
+ }
314
262
  exports.TakeOptions = TakeOptions;
315
- //# sourceMappingURL=main.js.map
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.14",
4
+ "version": "1.0.15",
5
5
  "description": "Use ScreenshotOne.com API to generate screenshots of any website.",
6
6
  "repository": {
7
7
  "type": "git",
package/tsconfig.json CHANGED
@@ -8,7 +8,10 @@
8
8
  "strict": true,
9
9
  "esModuleInterop": true,
10
10
  "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true
11
+ "forceConsistentCasingInFileNames": true,
12
+ "outDir": "dist",
13
+ "declarationDir": "dist/@types",
14
+ "declaration": true,
12
15
  },
13
16
  "include": [
14
17
  "src/**/*"
package/src/main.js DELETED
@@ -1,262 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.TakeOptions = exports.Client = void 0;
30
- const crypto = __importStar(require("crypto"));
31
- const big_js_1 = __importDefault(require("big.js"));
32
- const cross_fetch_1 = __importDefault(require("cross-fetch"));
33
- /**
34
- * Represents an API client for the screenshotone.com API.
35
- */
36
- class Client {
37
- constructor(accessKey, secretKey) {
38
- this.API_BASE_URL = "https://api.screenshotone.com";
39
- this.API_TAKE_PATH = "/take";
40
- this.accessKey = accessKey;
41
- this.secretKey = secretKey;
42
- }
43
- generateTakeURL(options) {
44
- const query = options.toQuery();
45
- query.append("access_key", this.accessKey);
46
- let queryString = query.toString();
47
- const signature = crypto.createHmac("sha256", this.secretKey)
48
- .update(queryString, 'utf-8')
49
- .digest('hex');
50
- queryString += '&signature=' + signature;
51
- return `${this.API_BASE_URL}${this.API_TAKE_PATH}?${queryString}`;
52
- }
53
- async take(options) {
54
- const url = this.generateTakeURL(options);
55
- const response = await (0, cross_fetch_1.default)(url);
56
- if (response.ok) {
57
- return await response.blob();
58
- }
59
- throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}`);
60
- }
61
- }
62
- exports.Client = Client;
63
- /**
64
- * Represents options for taking screenshots.
65
- */
66
- class TakeOptions {
67
- constructor(url) {
68
- const query = new URLSearchParams();
69
- query.append("url", url);
70
- this.query = query;
71
- }
72
- /**
73
- * Initializes take screenshot options with provided website URL.
74
- */
75
- static url(url) {
76
- return new TakeOptions(url);
77
- }
78
- put(key, ...values) {
79
- for (const value of values) {
80
- this.query.append(key, value);
81
- }
82
- }
83
- ;
84
- /**
85
- * Renders the full page.
86
- */
87
- fullPage(fullPage) {
88
- this.put("full_page", fullPage ? "true" : "false");
89
- return this;
90
- }
91
- /**
92
- * Sets response format, one of: "png", "jpeg", "webp" or "jpg".
93
- */
94
- format(format) {
95
- this.put("format", format);
96
- return this;
97
- }
98
- /**
99
- * Renders image with the specified quality. Available for the next formats: "jpeg" ("jpg"), "webp".
100
- */
101
- imageQuality(imageQuality) {
102
- this.put("image_quality", imageQuality.toString());
103
- return this;
104
- }
105
- /**
106
- * Renders a transparent background for the image. Works only if the site has not defined background color.
107
- * Available for the following response formats: "png", "webp".
108
- */
109
- omitBackground(omitBackground) {
110
- this.put("omit_background", omitBackground ? "true" : "false");
111
- return this;
112
- }
113
- /**
114
- * Sets the width of the browser viewport (pixels).
115
- */
116
- viewportWidth(viewportWidth) {
117
- this.put("viewport_width", viewportWidth.toString());
118
- return this;
119
- }
120
- /**
121
- * Sets the height of the browser viewport (pixels).
122
- */
123
- viewportHeight(viewportHeight) {
124
- this.put("viewport_height", viewportHeight.toString());
125
- return this;
126
- }
127
- /**
128
- * Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
129
- */
130
- deviceScaleFactor(deviceScaleFactor) {
131
- this.put("device_scale_factor", deviceScaleFactor.toString());
132
- return this;
133
- }
134
- /**
135
- * Sets geolocation latitude for the request.
136
- * Both latitude and longitude are required if one of them is set.
137
- */
138
- geolocationLatitude(latitude) {
139
- this.put("geolocation_latitude", new big_js_1.default(latitude).toFixed(20).replace(/0+$/, ""));
140
- return this;
141
- }
142
- /**
143
- * Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
144
- */
145
- geolocationLongitude(longitude) {
146
- this.put("geolocation_longitude", new big_js_1.default(longitude).toFixed(20).replace(/0+$/, ""));
147
- return this;
148
- }
149
- /**
150
- * Sets the geolocation accuracy in meters.
151
- */
152
- geolocationAccuracy(accuracy) {
153
- this.put("geolocation_accuracy", accuracy.toString());
154
- return this;
155
- }
156
- /**
157
- * Blocks ads.
158
- */
159
- blockAds(blockAds) {
160
- this.put("block_ads", blockAds ? "true" : "false");
161
- return this;
162
- }
163
- /**
164
- * Blocks trackers.
165
- */
166
- blockTrackers(blockTrackers) {
167
- this.put("block_trackers", blockTrackers ? "true" : "false");
168
- return this;
169
- }
170
- /**
171
- * Blocks requests by specifying URL, domain, or even a simple pattern.
172
- */
173
- blockRequests(...blockRequests) {
174
- this.put("block_requests", ...blockRequests);
175
- return this;
176
- }
177
- /**
178
- * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",
179
- * "font", "script", "texttrack", "xhr", "fetch", "eventsource", "websocket", "manifest", "other".
180
- */
181
- blockResources(...blockResources) {
182
- this.put("block_resources", ...blockResources);
183
- return this;
184
- }
185
- /**
186
- * Enables caching.
187
- */
188
- cache(cache) {
189
- this.put("cache", cache ? "true" : "false");
190
- return this;
191
- }
192
- /**
193
- * Sets cache TTL.
194
- */
195
- cacheTtl(cacheTTL) {
196
- this.put("cache_ttl", cacheTTL.toString());
197
- return this;
198
- }
199
- /**
200
- * Sets cache key.
201
- */
202
- cacheKey(cacheKey) {
203
- this.put("cache_key", cacheKey);
204
- return this;
205
- }
206
- /**
207
- * Sets a user agent for the request.
208
- */
209
- userAgent(userAgent) {
210
- this.put("user_agent", userAgent);
211
- return this;
212
- }
213
- /**
214
- * Sets an authorization header for the request.
215
- */
216
- authorization(authorization) {
217
- this.put("authorization", authorization);
218
- return this;
219
- }
220
- /**
221
- * Set cookies for the request.
222
- */
223
- cookies(...cookies) {
224
- this.put("cookies", ...cookies);
225
- return this;
226
- }
227
- /**
228
- * Sets extra headers for the request.
229
- */
230
- headers(...headers) {
231
- this.put("headers", ...headers);
232
- return this;
233
- }
234
- /**
235
- * TimeZone sets time zone for the request.
236
- * Available time zones are: "America/Santiago", "Asia/Shanghai", "Europe/Berlin", "America/Guayaquil",
237
- * "Europe/Madrid", "Pacific/Majuro", "Asia/Kuala_Lumpur", "Pacific/Auckland", "Europe/Lisbon", "Europe/Kiev",
238
- * "Asia/Tashkent", "Europe/London".
239
- */
240
- timeZone(timeZone) {
241
- this.put("time_zone", timeZone);
242
- return this;
243
- }
244
- /**
245
- * Sets delay.
246
- */
247
- delay(delay) {
248
- this.put("delay", delay.toString());
249
- return this;
250
- }
251
- /**
252
- * Sets timeout.
253
- */
254
- timeout(timeout) {
255
- this.put("timeout", timeout.toString());
256
- return this;
257
- }
258
- toQuery() {
259
- return new URLSearchParams(this.query.toString());
260
- }
261
- }
262
- exports.TakeOptions = TakeOptions;