-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimageGenerator.js
377 lines (328 loc) · 23.8 KB
/
imageGenerator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import nodeHtmlToImage from "node-html-to-image";
import fs from "node:fs";
import { tagsDisplayText } from "./src/content/tags";
import target_image from "./assets/help/cat-animal-eyes-grey-54632.jpeg";
import logo_small from "./assets/logo/logosmall.png";
const assetPath = "./assets/help";
const target_image_data = `data:image/png;base64,${new Buffer.from(fs.readFileSync(String(target_image))).toString("base64")}`;
const logo_small_data = `data:image/png;base64,${new Buffer.from(fs.readFileSync(String(logo_small))).toString("base64")}`;
const cursors = {
default: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9bpSItDnZQEcxQnexSRRxrFYpQIdQKrTqYXPoFTRqSFBdHwbXg4Mdi1cHFWVcHV0EQ/ABxdnBSdJES/5cUWsR4cNyPd/ced+8Af7PKVLMnAaiaZWRSSSGXXxWCrwhgGGHEMSYxU58TxTQ8x9c9fHy9i/Es73N/jrBSMBngE4gTTDcs4g3imU1L57xPHGFlSSE+J5406ILEj1yXXX7jXHLYzzMjRjYzTxwhFkpdLHcxKxsq8TRxVFE1yvfnXFY4b3FWq3XWvid/YaigrSxzneYoUljEEkQIkFFHBVVYiNGqkWIiQ/tJD/+I4xfJJZOrAkaOBdSgQnL84H/wu1uzOBV3k0JJoPfFtj/GgeAu0GrY9vexbbdOgMAzcKV1/LUmMPtJeqOjRY+AgW3g4rqjyXvA5Q4w9KRLhuRIAZr+YhF4P6NvygODt0D/mttbex+nD0CWukrfAAeHwESJstc93t3X3du/Z9r9/QDOg3LL1UFSVgAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+gDGQ0zNfZyY8oAAAuqSURBVHja7Z1/cBTVHcA/l7v8kDMQEjAJJGIhEKxAixRU0IhDUVuLbQOGGistFmnBialFKS2/MobSyQxalBmcSh1aIcQAQgaYkREdtQwwMoU/nDrgEB2FjFYwaGIuudzd3vaP+27ydnPJHZqEvWTfzJvkNm/fbr6f/b73/fHuLTjlqhZXL56nO+LsewDxtHdA9AEAVxzn6A6IvgfgslRV2Gp1IMRZkq5Q+Emtra2lgBvwAMny0yPHkqS6vuUc4xQLgCQRcoqu66GLFy8+CgwFMqQOBbxAmgIlKYqmOOVbAEgG0vRICX344YePAblSrwOyBMQQIMWB0LvDlAdIBbx6ZwmdPn16BVAAfAfIEx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HgP8DugllhkWdeN0AAAAASUVORK5CYII=",
};
const gvpReportHTML = fs.readFileSync("./htmlresources/gvp-report.html", "utf8");
const gvpReportCSS = fs.readFileSync("./htmlresources/gvp-report-style.css", "utf8");
const gvpRevealImageHTML = fs.readFileSync("./htmlresources/gvp-revealimage.html", "utf8");
const gvpRevealImageCSS = fs.readFileSync("./htmlresources/gvp-revealimage-style.css", "utf8");
const installMouseHelper = async (page, cursor_data) => {
await page.evaluate((cursor) => {
const box = document.createElement("puppeteer-mouse-pointer");
const styleElement = document.createElement("style");
styleElement.innerHTML = `
puppeteer-mouse-pointer {
pointer-events: none;
position: absolute;
content: url(${cursor});
top: 0;
left: 0;
z-index: 1;
aspect-ratio: 1/1;
height: 24px;
}
`;
document.head.appendChild(styleElement);
document.body.appendChild(box);
document.addEventListener("mousemove", event => {
box.style.left = `${event.pageX}px`;
box.style.top = `${event.pageY}px`;
});
}, cursor_data);
};
if (!fs.existsSync(assetPath)) {
fs.mkdirSync(assetPath);
}
nodeHtmlToImage({
output: `${assetPath}/report3.png`,
html: `
<html lang="en">
<body>
<img id="gvp-target-image" src="{{target}}" alt="" style="position: fixed; transform: translate(-50%, -50%);">
${gvpReportHTML}
<style>${gvpReportCSS}</style>
</body>
</html>
`,
transparent: true,
selector: "#gvp-background",
beforeScreenshot: async page => {
await installMouseHelper(page, cursors.pointer);
await page.setViewport({ width: 2560, height: 1440 });
await page.$eval("#gvp-report-preview-image", (node, logo) => node.src = logo, target_image_data);
for (const [key, value] of tagsDisplayText) {
await page.evaluate((tag, text) => {
const tagsSection = document.querySelector(".gvp-tags-section");
const container = document.createElement("div");
container.className = "gvp-tag-container";
const input = document.createElement("input");
input.type = "checkbox";
input.className = "gvp-checkbox";
input.id = `gvp-${tag}-checkbox`;
input.checked = true;
const label = document.createElement("label");
label.htmlFor = input.id;
label.innerText = text;
container.appendChild(input);
container.appendChild(label);
tagsSection.appendChild(container);
}, key, value);
}
await page.evaluate(() => {
const padding = 20;
const background = document.getElementById("gvp-background");
background.style.position = "relative";
const alert = document.getElementById("gvp-alert");
alert.style.top = "50%";
alert.style.left = "50%";
alert.style.transform = "translate(-50%, -50%)";
const alertRect = alert.getBoundingClientRect();
background.style.width = `${alertRect.width + padding}px`;
background.style.height = `${alertRect.height + padding}px`;
const image = document.getElementById("gvp-target-image");
image.style.top = `${(alertRect.height + padding) * 0.5}px`;
image.style.left = `${(alertRect.width + padding) * 0.5}px`;
});
await page.hover(`#gvp-${tagsDisplayText.keys().next().value}-checkbox + label`);
const node = await page.$("#gvp-background");
await node.screenshot({
path: `${assetPath}/report2.png`,
omitBackground: true,
});
await page.hover("#gvp-submit-button");
},
content: { target: target_image_data },
});
nodeHtmlToImage({
output: `${assetPath}/report5.png`,
html: `
<html lang="en">
<body>
<img id="gvp-target-image" src="{{target}}" alt="" style="position: fixed; transform: translate(-50%, -50%);">
${gvpRevealImageHTML}
<style>${gvpRevealImageCSS}</style>
</body>
</html>
`,
transparent: true,
selector: "#gvp-background",
beforeScreenshot: async page => {
await installMouseHelper(page, cursors.pointer);
await page.setViewport({ width: 2560, height: 1440 });
await page.$eval("#gvp-image-preview", (node, logo) => node.src = logo, target_image_data);
const imageTagArray = [...tagsDisplayText.values()];
await page.$eval("#gvp-image-preview-tags", (node, text) => node.textContent = text, imageTagArray.join(", "));
for (const [key, value] of tagsDisplayText) {
await page.evaluate((tag, text) => {
const feedback = document.querySelector(".gvp-feedback-checkboxes");
const tagbox = document.createElement("div");
tagbox.className = "gvp-tagbox";
const label = document.createElement("label");
label.innerText = text;
const reveal = document.createElement("div");
reveal.className = "gvp-reveal-checkbox";
const positive = document.createElement("img");
positive.id = `gvp-positive-checkbox-${tag}`;
positive.className = "gvp-positive-checkbox";
const negative = document.createElement("img");
negative.id = `gvp-negative-checkbox-${tag}`;
negative.className = "gvp-negative-checkbox";
negative.style.backgroundColor = "rgb(179, 0, 0)";
reveal.appendChild(positive);
reveal.appendChild(negative);
tagbox.appendChild(label);
tagbox.appendChild(reveal);
feedback.appendChild(tagbox);
}, key, value);
}
await page.evaluate(() => {
const padding = 20;
const background = document.getElementById("gvp-background");
background.style.position = "relative";
const reveal = document.getElementById("gvp-reveal-image");
reveal.style.top = "50%";
reveal.style.left = "50%";
reveal.style.transform = "translate(-50%, -50%)";
const revealRect = reveal.getBoundingClientRect();
background.style.width = `${revealRect.width + padding}px`;
background.style.height = `${revealRect.height + padding}px`;
const image = document.getElementById("gvp-target-image");
image.style.top = `${(revealRect.height + padding) * 0.5}px`;
image.style.left = `${(revealRect.width + padding) * 0.5}px`;
});
await page.hover(`#gvp-negative-checkbox-${tagsDisplayText.keys().next().value}`);
let node = await page.$("#gvp-background");
await node.screenshot({
path: `${assetPath}/voting.png`,
omitBackground: true,
});
await page.hover("#gvp-whitelist-checkbox");
node = await page.$(".gvp-whitelist");
await node.screenshot({
path: `${assetPath}/whitelisting.png`,
omitBackground: true,
});
await page.mouse.move(-96, -96);
await page.evaluate(() => {
document.getElementById("gvp-user-feedback").remove();
const padding = 20;
const background = document.getElementById("gvp-background");
const revealRect = document.getElementById("gvp-reveal-image").getBoundingClientRect();
background.style.width = `${revealRect.width + padding}px`;
background.style.height = `${revealRect.height + padding}px`;
const image = document.getElementById("gvp-target-image");
image.style.top = `${(revealRect.height + padding) * 0.5}px`;
image.style.left = `${(revealRect.width + padding) * 0.5}px`;
});
},
content: { target: target_image_data },
});
nodeHtmlToImage({
output: `${assetPath}/report4.png`,
html: `
<html lang="en">
<body>
<img id="gvp-filtered-image" src="{{target}}" alt="" />
</body>
</html>
`,
transparent: true,
selector: "#gvp-filtered-image",
beforeScreenshot: async page => {
await installMouseHelper(page, cursors.pointer);
await page.setViewport({ width: 2560, height: 1440 });
await page.evaluate(() => {
const target = document.getElementById("gvp-filtered-image");
const width = (target.naturalWidth > 0) ? target.naturalWidth : 960;
const height = (target.naturalHeight > 0) ? target.naturalHeight : 540;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const canvasContext = canvas.getContext("2d");
if (canvasContext) {
const gradient = canvasContext.createLinearGradient(0, 0, width, height);
gradient.addColorStop(0, "rgb(10,10,10)");
gradient.addColorStop(1, "rgb(55,55,55)");
canvasContext.fillStyle = gradient;
canvasContext.fillRect(0, 0, width, height);
}
document.getElementById("gvp-filtered-image").src = canvas.toDataURL("image/png");
});
await page.hover("#gvp-filtered-image");
},
content: { target: target_image_data },
});
nodeHtmlToImage({
output: `${assetPath}/report1.png`,
html: `
<html lang="en">
<body>
<div id="gvp-context">
<img id="gvp-image" src="{{target}}" alt="" />
</div>
</body>
</html>
`,
transparent: true,
selector: "#gvp-context",
beforeScreenshot: async page => {
await installMouseHelper(page, cursors.pointer);
await page.setViewport({ width: 2560, height: 1440 });
await page.evaluate((logo) => {
const menu = document.createElement("div");
menu.id = "gvp-context-menu";
menu.style.position = "fixed";
menu.style.color = "rgb(255, 253, 244)";
menu.style.fontFamily = "Open Sans";
menu.style.fontWeight = "light";
menu.style.fontSize = "14.5px";
menu.style.borderRadius = "8px";
menu.style.marginInline = "5px";
menu.style.backgroundColor = "rgb(49, 50, 68)";
menu.style.boxShadow = "0 0 1px rgba(255, 255, 255, 0.5) inset";
menu.style.zIndex = "1";
const list = document.createElement("div");
list.style.padding = "5px";
[
"Open Image in New Tab",
"Save Image As...",
"Copy Image",
"Copy Image Link",
"Email Image...",
"hr",
"Set Image as Desktop Background...",
"hr",
"Inspect Accessibility Properties",
"Inspect (Q)",
"hr",
].forEach(item => {
if (item === "hr") {
const line = document.createElement("hr");
line.style.height = "1px";
line.style.margin = "5px 0";
line.style.border = "none";
line.style.backgroundColor = "rgba(101, 102, 115, 0.75)";
list.appendChild(line);
return;
}
const element = document.createElement("div");
element.style.margin = "0";
element.style.padding = "5px 12px 5px 27px";
element.style.lineHeight = "15px";
element.innerText = item;
list.appendChild(element);
});
const report = document.createElement("div");
report.style.display = "flex";
report.style.alignItems = "center";
report.style.margin = "0";
report.style.padding = "5px 12px 5px 27px";
report.style.lineHeight = "15px";
report.style.backgroundColor = "rgb(65, 66, 82)";
report.style.borderRadius = "3px";
report.innerText = "Report Image";
const icon = document.createElement("img");
icon.style.aspectRatio = "1/1";
icon.style.height = "16px";
icon.style.position = "absolute";
icon.style.left = "11px";
icon.src = logo;
report.appendChild(icon);
list.appendChild(report);
menu.appendChild(list);
document.getElementById("gvp-context").appendChild(menu);
const rect = document.getElementById("gvp-image").getBoundingClientRect();
menu.style.top = String(rect.y + (rect.height * 0.5));
menu.style.left = String(rect.x + (rect.width * 0.5));
const pointer = document.querySelector("puppeteer-mouse-pointer");
pointer.style.zIndex = 2;
}, logo_small_data);
const target = await page.$eval("#gvp-context-menu", node => {
const rect = node.getBoundingClientRect();
const image = document.getElementById("gvp-image");
const context = document.getElementById("gvp-context");
context.style.width = `${image.naturalWidth}px`;
if (image.naturalWidth < rect.right) {
context.style.width = `${rect.right}px`;
}
context.style.height = `${image.naturalHeight}px`;
if (image.naturalHeight < rect.bottom) {
context.style.height = `${rect.bottom}px`;
}
return {
x: rect.x + (rect.width * 0.5), // left + midpoint
y: rect.y + rect.height - (36 * 0.5), // top + height - element midpoint
};
});
await page.mouse.move(target.x, target.y);
},
content: { target: target_image_data },
});