From ae54c490d5a638f8f257f6f7d73bb6b5a630d40b Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 24 Apr 2022 20:04:45 +0200 Subject: [PATCH] Live preview --- .../get-text-position.py | 0 Docker/script3.sh | 18 +++++++----------- Docker/utils.sh | 5 ++--- index.js | 4 ++++ run.sh | 4 ++++ 5 files changed, 17 insertions(+), 14 deletions(-) rename get-text-position.py => Docker/get-text-position.py (100%) create mode 100755 run.sh diff --git a/get-text-position.py b/Docker/get-text-position.py similarity index 100% rename from get-text-position.py rename to Docker/get-text-position.py diff --git a/Docker/script3.sh b/Docker/script3.sh index 564f43d..51eea0c 100755 --- a/Docker/script3.sh +++ b/Docker/script3.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash INPUT="$1" ID=$2 @@ -10,17 +10,15 @@ unquote(){ URL=$(unquote $(echo $INPUT | jq .url)) DOMAINS=`node array-to-lines.js "$(echo $INPUT | jq .third_party_domains)"` -echo "$DOMAINS" - source ./ephemeral-x.sh source ./annotate_header.sh source ./utils.sh -# (while true; do -# grab_screen_to_public $ID -# sleep 1 -# done) & -# refresher_pid=$!; +(while true; do + grab_screen_to_public $ID + sleep 1 + done) & +refresher_pid=$!; start_firefox grab start_firefox @@ -36,8 +34,6 @@ grab open_network_inspector declare -a pids; pids=() -echo DOMAINS: "$DOMAINS" - index=0 mkdir -p "/opt/static/$ID" @@ -71,7 +67,7 @@ while IFS= read -r DOMAIN; do done done <<< "$DOMAINS" -# kill $refresher_pid; +kill $refresher_pid; echo "starting wait..." diff --git a/Docker/utils.sh b/Docker/utils.sh index 4eaf77d..ba26708 100644 --- a/Docker/utils.sh +++ b/Docker/utils.sh @@ -102,10 +102,9 @@ load_website(){ printf "." scrot times=$((times + 1)) - if [ $times -eq 60 ] + if [ $times -eq 30 ] then - echo "Could not load website in time" - exit 1; + echo "Could not load website in time, trying anyway" break; fi done diff --git a/index.js b/index.js index c3da7e3..22ccf7f 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,10 @@ function attach(docker_id, output_stream) { output_stream.push(d); console.log("DATA!", d.toString()); }); + task.stderr.on("data", (d) => { + /* output_stream.push(d); */ + console.log("STDERR!", d.toString()); + }); task.stdout.on("error", (d) => { output_stream.push(d); }); diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..2e0c2e0 --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + + +docker run -i -v $PWD/static:/opt/static headless-fox ./script3.sh '{"url": "pearson.pl", "third_party_domains": ["hotjar.com", "cookielaw.org"]}' 12345