Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
feat: scripts update
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowko committed Nov 24, 2022
1 parent ac8ded4 commit 5dec40d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 43 deletions.
Binary file added engine.bin
Binary file not shown.
45 changes: 6 additions & 39 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
<div class="flex flex-col bg-[#FAFBFB] rounded-md shadow-lg">
<input
v-if="selectedType != 'multiple-imgs'"
class="
w-full
p-3
transition-all
ease-linear
delay-75
border-2
rounded-md
outline-none
focus:outline-none focus:border-primary-200 focus:border-dashed
"
class="w-full p-3 transition-all ease-linear delay-75 border-2 rounded-md outline-none focus:outline-none focus:border-primary-200 focus:border-dashed"
@keyup.enter="generateScreenshot"
placeholder="https://github.com/flowko..."
type="url"
Expand All @@ -22,18 +12,7 @@

<div class="flex items-center justify-center my-4 space-x-10">
<div
class="
flex flex-col
items-center
justify-center
w-32
h-32
text-center
bg-gray-200
cursor-pointer
rounded-2xl
hover:bg-gray-300
"
class="flex flex-col items-center justify-center w-32 h-32 text-center bg-gray-200 cursor-pointer rounded-2xl hover:bg-gray-300"
:class="{
'border-primary-200 border-dashed border-2 shadow-md ':
selectedType == type.value,
Expand Down Expand Up @@ -62,17 +41,7 @@
:key="index"
>
<input
class="
w-full
p-3
transition-all
ease-linear
delay-75
border-2
rounded-md
outline-none
focus:outline-none focus:border-primary-200 focus:border-dashed
"
class="w-full p-3 transition-all ease-linear delay-75 border-2 rounded-md outline-none focus:outline-none focus:border-primary-200 focus:border-dashed"
:placeholder="`URL - ${index}`"
type="url"
v-model="url.url"
Expand Down Expand Up @@ -548,7 +517,7 @@
v-if="result && result.url"
:src="result.url"
width="100%"
style="height: 50vh;object-fit: cover;"
style="height: 50vh; object-fit: cover"
/>
</div>
</div>
Expand Down Expand Up @@ -597,10 +566,8 @@ export default {
format: "resolution",
landscape: false,
},
script: `//console.log('hello world');`,
style: `/* .test {
color: #000;
} */`,
script: "",
style: "",
urls: [
{
url: null,
Expand Down
6 changes: 4 additions & 2 deletions server-middleware/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,19 @@ const internalCaptureWebsiteCore = async (input, options, page, browser) => {
);
}

if (options.scripts) {
if (options.scripts && options.scripts.length > 0) {
await Promise.all(
options.scripts.map((script) =>
page.addScriptTag({
[getInjectKey("js", script)]: script,
})
)
);

await page.waitForNavigation();
}

if (options.styles) {
if (options.styles && options.styles.length > 0) {
await Promise.all(
options.styles.map((style) =>
page.addStyleTag({
Expand Down
4 changes: 2 additions & 2 deletions server-middleware/website-shot.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ app.post("/screenshot", async (req, res) => {
const styles = [];
const scripts = [];

if (params.style) {
if (params.style && params.style.length > 0) {
styles.push(params.style);
}

if (params.script) {
if (params.script && params.script.length > 0) {
scripts.push(params.script);
}

Expand Down

0 comments on commit 5dec40d

Please sign in to comment.