Skip to content

Commit 6e57daa

Browse files
authored
New Components - screenshot_fyi (#15111)
* screenshot_fyi init * new component * pnpm-lock.yaml
1 parent 03f25c5 commit 6e57daa

File tree

4 files changed

+113
-10
lines changed

4 files changed

+113
-10
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import screenshot_fyi from "../../screenshot_fyi.app.mjs";
2+
3+
export default {
4+
key: "screenshot_fyi-create-screenshot",
5+
name: "Create Screenshot",
6+
description: "Takes a screenshot of a webpage using Screenshot.fyi. [See the documentation](https://www.screenshot.fyi/api-docs)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
screenshot_fyi,
11+
url: {
12+
type: "string",
13+
label: "URL",
14+
description: "The URL of the webpage to capture",
15+
},
16+
width: {
17+
type: "integer",
18+
label: "Width",
19+
description: "Width of the viewport in pixels. Default: `1440`",
20+
optional: true,
21+
},
22+
height: {
23+
type: "integer",
24+
label: "Height",
25+
description: "Height of the viewport in pixels. Default: `900`",
26+
optional: true,
27+
},
28+
fullPage: {
29+
type: "boolean",
30+
label: "Full Page",
31+
description: "Capture the full scrollable page. Default: `false`",
32+
optional: true,
33+
},
34+
format: {
35+
type: "string",
36+
label: "Format",
37+
description: "The format of the screenshot. Default: `jpg`",
38+
options: [
39+
"png",
40+
"jpg",
41+
"jpeg",
42+
],
43+
optional: true,
44+
},
45+
disableCookieBanners: {
46+
type: "boolean",
47+
label: "Disable Cookie Banners",
48+
description: "Attempt to remove cookie consent banners. Default: `true`",
49+
optional: true,
50+
},
51+
darkMode: {
52+
type: "boolean",
53+
label: "Dark Mode",
54+
description: "Enable dark mode when taking the screenshot. Default: `false`",
55+
optional: true,
56+
},
57+
},
58+
async run({ $ }) {
59+
const response = await this.screenshot_fyi.takeScreenshot({
60+
$,
61+
params: {
62+
url: this.url,
63+
width: this.width,
64+
height: this.height,
65+
fullPage: this.fullPage,
66+
format: this.format,
67+
disableCookieBanners: this.disableCookieBanners,
68+
darkMode: this.darkMode,
69+
},
70+
});
71+
$.export("$summary", `Screenshot taken for ${this.url}`);
72+
return response;
73+
},
74+
};

components/screenshot_fyi/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/screenshot_fyi",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream screenshot.fyi Components",
55
"main": "screenshot_fyi.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "screenshot_fyi",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://screenshot.fyi/api";
10+
},
11+
_makeRequest({
12+
$ = this,
13+
path,
14+
params,
15+
...otherOpts
16+
}) {
17+
return axios($, {
18+
url: `${this._baseUrl()}${path}`,
19+
params: {
20+
...params,
21+
accessKey: this.$auth.access_key,
22+
},
23+
...otherOpts,
24+
});
25+
},
26+
takeScreenshot(opts = {}) {
27+
return this._makeRequest({
28+
path: "/take",
29+
...opts,
30+
});
931
},
1032
},
1133
};

pnpm-lock.yaml

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)