More accurate highlighting
This commit is contained in:
parent
c1a2ff6200
commit
8661cf88c7
88
annotate_header.sh
Executable file
88
annotate_header.sh
Executable file
|
@ -0,0 +1,88 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
get_size(){
|
||||||
|
filename=$1
|
||||||
|
magick "$filename" -format "%[w]x%[h]" info:
|
||||||
|
}
|
||||||
|
|
||||||
|
get_width(){
|
||||||
|
filename=$1
|
||||||
|
magick "$filename" -format "%[w]" info:
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
annotate_header(){
|
||||||
|
header=$1
|
||||||
|
d=$(date "+%Y-%m-%d__%H_%M_%S")
|
||||||
|
filename="${d}__$header.png"
|
||||||
|
#filename="2022-03-10__19_33_55__set-cookie.png"
|
||||||
|
cropped_filename="${filename}__cropped.png"
|
||||||
|
overlay_filename="${cropped_filename}__overlay.png"
|
||||||
|
hardoverlay_filename="${cropped_filename}__hardoverlay.png"
|
||||||
|
annotated_filename="${cropped_filename}__annotated.png"
|
||||||
|
|
||||||
|
# crop
|
||||||
|
left=2056
|
||||||
|
top=330
|
||||||
|
width=824
|
||||||
|
height=1260
|
||||||
|
scrot $filename
|
||||||
|
vips extract_area "$filename" "$cropped_filename" $left $top $width $height
|
||||||
|
|
||||||
|
# prepare overlay canvases
|
||||||
|
convert -size $(get_size "$filename") xc:none -fill white "$overlay_filename"
|
||||||
|
convert -size $(get_size "$filename") xc:none -fill transparent "$hardoverlay_filename"
|
||||||
|
|
||||||
|
all_positions=$(python ./get-text-position.py "$cropped_filename" )
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]
|
||||||
|
do
|
||||||
|
header=$1
|
||||||
|
description=$2
|
||||||
|
matching_line=$(echo "$all_positions" | grep "$header" | head -n 1)
|
||||||
|
if [ "$matching_line" = "" ]; then
|
||||||
|
shift;
|
||||||
|
shift;
|
||||||
|
continue
|
||||||
|
fi;
|
||||||
|
coords=$(echo $matching_line | awk '{print $1 " " $2 " " $3 " " $4}')
|
||||||
|
echo "Matched coords for" $header ", " $coords
|
||||||
|
echo "^ matching line: " $matching_line
|
||||||
|
highlight_margin=5
|
||||||
|
rect_x1=$(($(echo "$coords" | awk '{print $1}') - highlight_margin + left))
|
||||||
|
rect_y1=$(($(echo "$coords" | awk '{print $2}') - highlight_margin + top))
|
||||||
|
rect_h=$(($(echo "$coords" | awk '{print $4}') + 2 * highlight_margin))
|
||||||
|
rect_x2=$((796 + left))
|
||||||
|
rect_y2=$((rect_y1 + rect_h))
|
||||||
|
convert "$overlay_filename" \
|
||||||
|
-fill "#ff000066" \
|
||||||
|
-stroke "#ff000066" \
|
||||||
|
-draw "rectangle $rect_x1,$rect_y1 $rect_x2,$rect_y2" \
|
||||||
|
"$overlay_filename" &
|
||||||
|
first_job=$!
|
||||||
|
|
||||||
|
triangle_height=30
|
||||||
|
triangle_width=30
|
||||||
|
|
||||||
|
convert "$hardoverlay_filename" \
|
||||||
|
-fill "red" \
|
||||||
|
-draw "path 'M $((rect_x1 - 10)),$((rect_y1 + rect_h / 2)) L $((rect_x1 - triangle_width - 10)),$((rect_y1 - triangle_height + rect_h / 2)) L $((rect_x1 - triangle_width - 10)),$((rect_y1 + triangle_height + rect_h / 2)) Z' " \
|
||||||
|
-draw "rectangle $((rect_x1-20)),$rect_y1 $((rect_x1 - 200)),$rect_y2" \
|
||||||
|
-gravity NorthEast \
|
||||||
|
-pointsize 50 \
|
||||||
|
-undercolor White \
|
||||||
|
-font "Noto-Sans-Regular" \
|
||||||
|
-draw "text 985,$((rect_y1 - 30)) '$description'" \
|
||||||
|
"$hardoverlay_filename" &
|
||||||
|
second_job=$!
|
||||||
|
wait $first_job;
|
||||||
|
wait $second_job;
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
convert "$filename" "$overlay_filename" -compose Darken -composite "$annotated_filename.step.png"
|
||||||
|
convert "$annotated_filename.step.png" "$hardoverlay_filename" -compose src-over -composite "$annotated_filename"
|
||||||
|
rm "$overlay_filename" "$annotated_filename.step.png" "$hardoverlay_filename" "$cropped_filename" "$filename"
|
||||||
|
}
|
||||||
|
|
||||||
|
#annotate_header "set-cookie" "identyfikator internetowy z cookie" "Cookie" "identyfikator internetowy z cookie"
|
3
draw_rect.sh
Executable file
3
draw_rect.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
vips copy cropped.png k2.v
|
||||||
|
vips draw_rect k2.v "255 0 0" 0 0 50 50
|
||||||
|
vips copy k2.v drawed.png
|
37
script3.sh
37
script3.sh
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/bash -x
|
#!/bin/bash
|
||||||
|
|
||||||
source ./ephemeral-x.sh
|
source ./ephemeral-x.sh
|
||||||
|
source ./annotate_header.sh
|
||||||
|
|
||||||
get_pixel_color(){
|
get_pixel_color(){
|
||||||
x=$1;
|
x=$1;
|
||||||
|
@ -48,28 +49,6 @@ keycombo(){
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
annotate_header(){
|
|
||||||
header=$1
|
|
||||||
d=$(date "+%Y-%m-%d__%H_%M_%S")
|
|
||||||
filename="${d}__$header.png"
|
|
||||||
cropped_filename="${filename}__cropped.png"
|
|
||||||
left=2056
|
|
||||||
top=330
|
|
||||||
width=824
|
|
||||||
height=1260
|
|
||||||
scrot $filename
|
|
||||||
vips extract_area "$filename" "$cropped_filename" $left $top $width $height
|
|
||||||
coords=$(python ./get-text-position.py "$cropped_filename" | grep set-cookie | awk '{print $1 " " $2 " " $3 " " $4}')
|
|
||||||
rect_x1=$(echo "$coords" | awk '{print $1}')
|
|
||||||
rect_y1=$(echo "$coords" | awk '{print $2}')
|
|
||||||
rect_w=$(echo "$coords" | awk '{print $3}')
|
|
||||||
rect_h=$(echo "$coords" | awk '{print $4}')
|
|
||||||
rect_x2=$((rect_x1 + rect_w))
|
|
||||||
rect_y2=$((rect_y1 + rect_h))
|
|
||||||
annotated_filename="${cropped_filename}__annotated.png"
|
|
||||||
convert "$cropped_filename" -fill transparent -stroke red -draw "rectangle $rect_x1,$rect_y1 $rect_x2,$rect_y2" "$annotated_filename"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rm -rf /root/.mozilla/firefox/bifup8k5.docker/sessionstore-backups
|
rm -rf /root/.mozilla/firefox/bifup8k5.docker/sessionstore-backups
|
||||||
#echo 'user_pref("layout.css.devPixelsPerPx", "1.5");' >> /root/.mozilla/firefox/bifup8k5.docker/prefs.js
|
#echo 'user_pref("layout.css.devPixelsPerPx", "1.5");' >> /root/.mozilla/firefox/bifup8k5.docker/prefs.js
|
||||||
|
@ -126,7 +105,7 @@ xdotool key Return
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
scrot
|
# scrot
|
||||||
|
|
||||||
|
|
||||||
echo "waiting for the website to load..."
|
echo "waiting for the website to load..."
|
||||||
|
@ -135,7 +114,7 @@ while [ $(get_pixel_color 143 122) = "2E3436" ] # the center of the X icon that
|
||||||
do
|
do
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
printf "."
|
printf "."
|
||||||
scrot
|
#scrot
|
||||||
times=$((times + 1))
|
times=$((times + 1))
|
||||||
if [ $times -eq 10 ]
|
if [ $times -eq 10 ]
|
||||||
then
|
then
|
||||||
|
@ -150,6 +129,7 @@ sleep 1
|
||||||
echo "sleep 1"
|
echo "sleep 1"
|
||||||
keycombo Control_L Shift_L e
|
keycombo Control_L Shift_L e
|
||||||
echo ctrl shift e
|
echo ctrl shift e
|
||||||
|
scrot
|
||||||
keycombo Control_L f
|
keycombo Control_L f
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
xdotool type "method:GET domain:adocean.pl" # can filter with more granularity: https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor/request_list#filtering_by_properties
|
xdotool type "method:GET domain:adocean.pl" # can filter with more granularity: https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor/request_list#filtering_by_properties
|
||||||
|
@ -164,15 +144,18 @@ xdotool key Down
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
xdotool key Up
|
xdotool key Up
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
scrot
|
#scrot
|
||||||
|
|
||||||
while [ $(get_pixel_color 1267 1572) = "F9F9FA" ]
|
while [ $(get_pixel_color 1267 1572) = "F9F9FA" ]
|
||||||
do
|
do
|
||||||
|
annotate_header \
|
||||||
|
"set-cookie" "identyfikator internetowy z cookie" \
|
||||||
|
"Cookie" "identyfikator internetowy z cookie" \
|
||||||
|
"Referer" "Część mojej historii przeglądania"
|
||||||
xdotool key Tab
|
xdotool key Tab
|
||||||
sleep 0.05
|
sleep 0.05
|
||||||
xdotool key Down
|
xdotool key Down
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
annotate_header set-cookie
|
|
||||||
# use python script ^here to annotate the cropped png
|
# use python script ^here to annotate the cropped png
|
||||||
# scrot
|
# scrot
|
||||||
# echo "########## EXTRACTED TEXT: "
|
# echo "########## EXTRACTED TEXT: "
|
||||||
|
|
Loading…
Reference in New Issue
Block a user